예제 #1
0
def test_dismiss_group(driver1, groupname, grouptype):
    ret_status = False
    print "< case satart: dismiss group >"

    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    goto_groupinfo(driver1)

    text = "dismiss group"
    xpath_id = "com.hyphenate.chatuidemo:id/btn_exitdel_grp"
    elem = case_common.findelem_swipe(driver1, xpath_id, text)
    elem.click()  # 点击解散群组按钮
    driver1.find_element_by_id(
        "com.hyphenate.chatuidemo:id/btn_exit").click()  # 确认解散群组

    sleep(3)
    mygrouplist = get_grouplist(driver1)
    if groupname not in mygrouplist:
        ret_status = True
        print "group: %s dismiss success!" % groupname
        print "< case end: pass >"
    else:
        print "< case end: fail >"
    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    case_status[sys._getframe().f_code.co_name + "_" + grouptype] = ret_status
    return ret_status
예제 #2
0
def test_sendrcv_msg(driver1, driver2, groupname):
    ret_status = False
    print "< case start: send and receive msg in %s group >" % groupname

    msgtype = "text"
    chattype = "group_chat"
    msgcontent = case_common.random_str(8)

    case_common.gotoContact(driver2)
    case_common.gotoGroup(driver2)
    find_group(driver2, groupname)
    case_common.click_name(driver2, groupname)
    case_chat.send_msg_txt(driver2, msgcontent)
    if case_chat.check_if_receivemsg(driver1, groupname, msgcontent):
        print "< case end: pass >"
        ret_status = True
    else:
        print "< case end: fail >"

    case_common.back(driver2)
    sleep(1)
    case_common.back(driver2)
    sleep(1)
    case_common.gotoConversation(driver2)

    case_status[sys._getframe().f_code.co_name + "_" + groupname] = ret_status
    return ret_status
예제 #3
0
def multi_devices_chat(driver1, driver2, fromname, toname, groupname):
    print "********************************************---Multi devices Chat---********************************************"
    chattype = "single_chat"
    msgtype = "text"
    msgnum = 1
    groupid = restHelper.get_groupid(fromname, groupname)
    case_account.switch_user(driver2, fromname)

    if not kick_by_other(driver1):

        case_common.del_conversation(driver2)

        restHelper.sendmsg(fromname, "rest", msgnum, msgtype='users')
        print "------------------------------------------------------------------------------------------------------------------"
        test_multidev_rcv(driver1, driver2, "rest", "testmsg0", msgtype,
                          chattype)

        chattype = "group_chat"
        restHelper.sendmsg(groupid, "rest", msgnum, msgtype="chatgroups")
        print "------------------------------------------------------------------------------------------------------------------"
        test_multidev_rcv(driver1, driver2, "rest", "testmsg0", msgtype,
                          chattype)

        case_common.gotoContact(driver1)
        case_common.click_name(driver1, toname)
        msgcontent = case_common.random_str(8)
        chattype = "single_chat"
        msgtype = "text"

        if test_send_msg_txt(driver1, chattype, msgcontent):
            print "------------------------------------------------------------------------------------------------------------------"
            test_multidev_send(driver2, toname, msgcontent, msgtype, chattype)
            print "------------------------------------------------------------------------------------------------------------------"

        case_common.back(driver1)
        case_common.gotoGroup(driver1)
        case_group.find_group(driver1, groupname)
        case_common.click_name(driver1, groupname)
        chattype = "group_chat"
        msgcontent = case_common.random_str(8)

        if test_send_msg_txt(driver1, chattype, msgcontent):
            test_multidev_send(driver2, groupname, msgcontent, msgtype,
                               chattype)

        case_common.back(driver1)
        sleep(1)
        case_common.back(driver1)
        sleep(1)
        case_common.gotoConversation(driver1)
        case_account.switch_user(driver2, toname)
    else:
        case_account.switch_user(driver2, toname)
        case_account.test_login(driver1, fromname, password="******")
예제 #4
0
def test_add_groupmember_agree(driver1, driver2, groupname, testaccount,
                               memberlist, isadmincase, ismemberinvite):
    ret_status = False
    print "< case start: add group member->agree >"

    groupid = restHelper.get_groupid(testaccount, groupname)

    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    case_common.swipeDown(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    sleep(1)
    goto_groupinfo(driver1)
    add_groupmember(driver1, memberlist)
    sleep(2)

    case_common.gotoContact(driver2)
    if case_common.find_notice(driver2, groupid):
        accept_groupinvite(driver2, groupid)
        sleep(3)
        namelist = get_all_people(driver1)
        for i in memberlist:
            if i in namelist:
                ret_status = True
                break
    else:
        print "B not receive group Invitation, cannot complete agree operation!"

    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    case_common.gotoConversation(driver1)
    case_common.back(driver2)
    case_common.gotoConversation(driver2)

    if ret_status == True:
        print "< case end: pass >"
    else:
        print "< case end: fail >"

    if isadmincase == 1:
        mystr = ":groupAdmin"
    else:
        if ismemberinvite == 1:
            mystr = ":memberinvite"
        else:
            mystr = ":groupOwner"
    case_status[sys._getframe().f_code.co_name + mystr] = ret_status
    return ret_status
예제 #5
0
def test_join_group(driver1, driver2, applyer, owner, groupname,
                    approval_type):
    ret_status = False
    print "< case start: join group >"

    groupid = restHelper.get_groupid(owner, groupname)

    case_common.gotoContact(driver2)
    case_common.gotoGroup(driver2)
    find_group(driver2, groupname)
    case_common.click_name(driver2, "Add public group")
    search_group(driver2, groupid).click()
    button_join_group(driver2).click()
    print "B sended join group apply."
    sleep(2)
    case_common.back(driver2)
    sleep(0.5)
    case_common.back(driver2)
    sleep(0.5)
    case_common.back(driver2)

    if approval_type == "approval":
        case_common.gotoContact(driver1)
        case_common.gotoInvitation(driver1)
        if check_groupapply(driver1, groupname, applyer):
            print "A received group join apply."
            accept_groupapply(driver1, groupname)
            print "A agreed apply."
        else:
            print "A not receive B join apply"
        sleep(3)
        case_common.back(driver1)
        case_common.gotoConversation(driver1)

    try:
        WebDriverWait(driver2, 10).until(
            EC.visibility_of_element_located(
                (By.XPATH,
                 "//android.widget.TextView[@text='%s']" % groupname)))
        print "B join group success!"
        print "< case end: pass >"
        ret_status = True
    except:
        print "B join group fail!"
        print "<case end: fail >"

    case_common.back(driver2)
    case_common.gotoConversation(driver2)

    case_status[sys._getframe().f_code.co_name + "_" + groupname] = ret_status
    return ret_status
예제 #6
0
def test_trans_owner(driver1, driver2, groupname, testaccount, adm_name):
    ret_status = False
    print "<case start: transfer owner >"

    groupid = restHelper.get_groupid(testaccount, groupname)

    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    goto_groupinfo(driver1)

    case_common.gotoContact(driver2)
    case_common.gotoGroup(driver2)
    find_group(driver2, groupname)
    case_common.click_name(driver2, groupname)
    goto_groupinfo(driver2)

    # 操作:A从管理员列表里选中B,并设定为群主
    elem = find_adminElement(driver1, adm_name)
    elem.click()
    trans_owner(driver1)
    sleep(5)
    # 操作完成

    mydic = get_group_roles(driver2)
    if adm_name in mydic["owner"]:
        ret_status = True
        print "B received trans_owner notice sucess!"
        print "< case end: pass >"
    else:
        print "B not receive trans_owner notice, fail!"
        print "< case end: fail >"

    case_common.back(driver2)
    sleep(1)
    case_common.back(driver2)
    sleep(1)
    case_common.back(driver2)
    case_common.gotoConversation(driver2)

    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    case_status[sys._getframe().f_code.co_name] = ret_status
    return ret_status
예제 #7
0
def test_del_groupmember(driver1, driver2, groupname, testaccount, dellist,
                         isadmincase):
    ret_status = False
    print "< case start: del groupmember >"

    groupid = restHelper.get_groupid(testaccount, groupname)
    case_common.gotoContact(driver2)
    case_common.gotoGroup(driver2)
    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    goto_groupinfo(driver1)

    for i in dellist:
        elem = find_memberElement(driver1, i)
        elem.click()
        del_member(driver1)
    sleep(3)
    namelist = get_all_people(driver1)
    for name in dellist:
        if name not in namelist:
            print "deleted user: "******"del groupmember failed!"
                print "< case end: fail >"
            else:
                print "del group member sucess!"
                ret_status = True
                print "< case end: pass >"

    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    case_common.back(driver2)
    case_common.gotoConversation(driver2)

    if isadmincase == 1:
        mystr = ":groupAdmin"
    else:
        mystr = ":groupOwner"

    case_status[sys._getframe().f_code.co_name + mystr] = ret_status
    return ret_status
예제 #8
0
def testset_group_chat(driver1, driver2, fromname, groupname):
    chattype = "group_chat"
    print "********************************************---Group Chat---********************************************"
    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    case_group.find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)

    print "------------------------------------------------------------------------------------------------------------------"
    msgcontent = case_common.random_str(8)
    msgtype = "text"
    clear_groupmsg(driver1)
    if test_send_msg_txt(driver1, chattype, msgcontent):
        print "------------------------------------------------------------------------------------------------------------------"
        test_rcv_msg(driver2, groupname, msgcontent, msgtype, chattype)
        print "------------------------------------------------------------------------------------------------------------------"
        case_common.click_name(driver2, groupname)
        test_recall_message(driver1, driver2, fromname, msgcontent, chattype)
        case_common.back(driver2)
    print "------------------------------------------------------------------------------------------------------------------"
    msgcontent = u"[语音]"
    msgtype = "audio"

    clear_groupmsg(driver1)
    if test_send_msg_audio(driver1, chattype):
        print "------------------------------------------------------------------------------------------------------------------"
        test_rcv_msg(driver2, groupname, msgcontent, msgtype, chattype)
        print "------------------------------------------------------------------------------------------------------------------"

    case_common.switch_messageroaming(driver2)
    msgcontent1 = case_common.random_str(8)
    msgcontent2 = case_common.random_str(8)
    case_common.mode_keyboard(driver1)

    if test_send_msg_txt(driver1, chattype, msgcontent1) and test_send_msg_txt(
            driver1, chattype, msgcontent2):
        click_conversation(driver2, groupname)
        clear_groupmsg(driver2)
        sleep(2)
        case_common.swipeUp(driver2)
        print "------------------------------------------------------------------------------------------------------------------"
        test_roaming_message(driver2, msgcontent1, msgcontent2, chattype)
        case_common.back(driver2)

    case_common.switch_messageroaming(driver2)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(1)
    case_common.gotoConversation(driver1)
예제 #9
0
def test_add_admin(driver1, driver2, groupname, testaccount, adm_name):
    ret_status = False
    print "< case start: add group admin >"

    groupid = restHelper.get_groupid(testaccount, groupname)

    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    goto_groupinfo(driver1)

    case_common.gotoContact(driver2)
    case_common.gotoGroup(driver2)
    find_group(driver2, groupname)
    case_common.click_name(driver2, groupname)
    goto_groupinfo(driver2)

    elem = find_memberElement(driver1, adm_name)
    elem.click()
    add_admin(driver1)
    print "A added B as admin."
    sleep(5)

    mydic = get_group_roles(driver2)
    if adm_name in mydic["adminlist"]:
        ret_status = True
        print "B received +admin notice sucess!"
        print "< case end: pass >"
    else:
        print "B not receive +admin notice, fail!"
        print "< case end: fail >"

    case_common.back(driver2)
    sleep(1)
    case_common.back(driver2)
    sleep(1)
    case_common.back(driver2)
    case_common.gotoConversation(driver2)

    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    case_status[sys._getframe().f_code.co_name] = ret_status
    return ret_status
예제 #10
0
def test_unmute_groupmember(driver1, driver2, groupname, testaccount,
                            unmute_name, isadmincase):
    ret_status = False
    print "< case start: unmute >"

    groupid = restHelper.get_groupid(testaccount, groupname)

    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    goto_groupinfo(driver1)

    elem = find_memberElement(driver1, unmute_name)
    elem.click()
    unmute(driver1)

    case_common.gotoContact(driver2)
    case_common.gotoGroup(driver2)
    find_group(driver2, groupname)
    case_common.click_name(driver2, groupname)
    case_chat.clear_groupmsg(driver2)

    if case_chat.send_msg_txt(driver2, content="test msg!"):
        print "Unmute B sucess!"
        ret_status = True
        print "< case end: pass> "
    else:
        print "< case end: fail >"

    case_common.back(driver2)
    sleep(1)
    case_common.back(driver2)
    case_common.gotoConversation(driver2)

    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    if isadmincase == 1:
        mystr = ":groupAdmin"
    else:
        mystr = ":groupOwner"
    case_status[sys._getframe().f_code.co_name + mystr] = ret_status
    return ret_status
예제 #11
0
def test_exit_group(driver1, driver2, membername, groupname):
    ret_status = False
    print "< case start: exit group >"

    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    goto_groupinfo(driver1)

    case_common.gotoContact(driver2)
    case_common.gotoGroup(driver2)
    find_group(driver2, groupname)
    case_common.click_name(driver2, groupname)
    goto_groupinfo(driver2)
    sleep(1)
    case_common.swipeUp(driver2)
    driver2.find_element_by_id(
        "com.hyphenate.chatuidemo:id/btn_exit_grp").click()  # 点击退出群组按钮
    driver2.find_element_by_id(
        "com.hyphenate.chatuidemo:id/btn_exit").click()  # 确认退出
    sleep(5)

    mygrouplist = get_grouplist(driver2)
    if groupname not in mygrouplist:
        print "%s exited from group:%s" % (membername, groupname)

    A_memberlist = get_all_people(driver1)
    if membername not in A_memberlist:
        print "A received B exit group notice success!"
        print "< case end: pass >"
        ret_status = True
    else:
        print "< case end: fail >"

    case_common.back(driver2)
    case_common.gotoConversation(driver2)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(2)
    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    case_status[sys._getframe().f_code.co_name] = ret_status
    return ret_status
예제 #12
0
def test_block_groupmember(driver1, driver2, groupname, testaccount, blockname,
                           isadmincase):
    ret_status = False
    print "< case start: block groupmember>"

    groupid = restHelper.get_groupid(testaccount, groupname)

    case_common.gotoContact(driver2)
    case_common.gotoGroup(driver2)
    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    goto_groupinfo(driver1)

    elem = find_memberElement(driver1, blockname)
    elem.click()
    add_group_blacklist(driver1)

    sleep(5)
    Bgrouplist = get_grouplist(driver2)
    if groupname not in Bgrouplist:
        print "Received beBlocked notice!"
        print "< case end: pass >"
        ret_status = True
    else:
        print "Not eceived beBlocked notice!"
        print "< case end: fail >"

    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    case_common.back(driver2)
    case_common.gotoConversation(driver2)

    if isadmincase == 1:
        mystr = ":groupAdmin"
    else:
        mystr = ":groupOwner"
    case_status[sys._getframe().f_code.co_name + mystr] = ret_status
    return ret_status
예제 #13
0
def test_add_groupmember_refuse(driver1, driver2, groupname, testaccount,
                                memberlist, isadmincase):
    ret_status = False
    print "< case start: add group member->refuse >"

    groupid = restHelper.get_groupid(testaccount, groupname)
    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    goto_groupinfo(driver1)
    add_groupmember(driver1, memberlist)
    case_common.gotoContact(driver2)
    if check_groupinvite(driver2, groupid):
        refuse_groupinvite(driver2, groupid)

    sleep(3)
    namelist = get_all_people(driver1)
    for i in memberlist:
        if i not in namelist:
            ret_status = True
            break

    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    case_common.back(driver2)
    case_common.gotoConversation(driver2)

    if ret_status == True:
        print "< case end: pass! >"
    else:
        print "< case end: failed! >"

    if isadmincase == 1:
        mystr = ":groupAdmin"
    else:
        mystr = ":groupOwner"

    case_status[sys._getframe().f_code.co_name + mystr] = ret_status
    return ret_status
예제 #14
0
def test_create_group(driver1, groupname, grouptype):
    print "< case start: create %s group >" % grouptype
    ret_status = False

    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    case_common.click_name(driver1, "Create new group")
    driver1.find_element_by_id(
        "com.hyphenate.chatuidemo:id/edit_group_name").send_keys(groupname)
    if grouptype == "gknotapproval":
        driver1.find_element_by_id(
            "com.hyphenate.chatuidemo:id/cb_public").click()
    elif grouptype == "gkapproval":
        driver1.find_element_by_id(
            "com.hyphenate.chatuidemo:id/cb_public").click()
        driver1.find_element_by_id(
            "com.hyphenate.chatuidemo:id/cb_member_inviter").click()
    elif grouptype == "syinvite":
        driver1.find_element_by_id(
            "com.hyphenate.chatuidemo:id/cb_member_inviter").click()

    sleep(1)

    driver1.find_element_by_xpath(
        "//android.widget.Button[@text='Save']").click()
    sleep(2)
    driver1.find_element_by_xpath(
        "//android.widget.Button[@text='Save']").click()

    if find_group(driver1, groupname):
        ret_status = True
        print "group: %s created success!" % groupname
        print "< case end: pass >"
    else:
        print "< case end: fail >"

    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    case_status[sys._getframe().f_code.co_name + "_" + grouptype] = ret_status
    return ret_status
예제 #15
0
def test_unblock_groupmember(driver1, groupname, unblock_name, isadmincase):
    ret_status = False

    print "< case start: ublock groupmember >"
    case_common.gotoContact(driver1)
    case_common.gotoGroup(driver1)
    find_group(driver1, groupname)
    case_common.click_name(driver1, groupname)
    goto_groupinfo(driver1)

    elem = find_memberElement(driver1, unblock_name)
    elem.click()
    rm_group_blacklist(driver1)

    case_common.back(driver1)
    goto_groupinfo(driver1)

    mylist = get_all_people(driver1)
    if unblock_name not in mylist:
        print "unblock success!"
        ret_status = True
        print "< case end: pass>"
    else:
        print "< case end: fail >"

    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    sleep(1)
    case_common.back(driver1)
    case_common.gotoConversation(driver1)

    if isadmincase == 1:
        mystr = ":groupAdmin"
    else:
        mystr = ":groupOwner"

    case_status[sys._getframe().f_code.co_name + mystr] = ret_status
    return ret_status