Ejemplo n.º 1
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="******")
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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
Ejemplo n.º 8
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
Ejemplo n.º 9
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
Ejemplo n.º 10
0
def testset_account(driver):
	print "********************************************---Accounts---********************************************"
	registername = random_str(8)
	# registername = "my_autotest"

	print "------------------------------------------------------------------------------------------------------------------"
	test_create_new_user(driver, registername, "1")
	print "------------------------------------------------------------------------------------------------------------------"
	restHelper.create_group("offline_msg_Group", True, registername, memberlist = [])
	groupid = restHelper.get_groupid(registername, "offline_msg_Group")
	test_offline_msg(driver, fromname="rest", toname=registername, togroupid=groupid, msgnum=5)
	print "------------------------------------------------------------------------------------------------------------------"
	test_online_msg(driver, fromname="rest", toname=registername, togroupid=groupid, msgnum=5)
	print "------------------------------------------------------------------------------------------------------------------"
	gotoSetting(driver)
	test_logout(driver)

	restHelper.del_user(registername)
	print "------------------------------------------------------------------------------------------------------------------"