Exemple #1
0
    def _setCameraMode(self, mode, setting, option):
        d(description='Camera settings').click.wait()
        print dict_for_settings.get(mode).index(setting)
        if dict_for_settings.get(mode).index(setting) < MAX_SETTINGS_IN_A_SCREEN:
            print 'if'
            d(resourceId="com.intel.camera22:id/hori_list_button")[dict_for_settings.get(mode).index(setting)].click.wait()
            print len(dict_for_settings.get(mode))
            print dict_for_options.get(mode).get(setting).index(option)
            if len(dict_for_settings.get(mode)) > MAX_SETTINGS_IN_A_SCREEN:
                d(resourceId="com.intel.camera22:id/hori_list_button")[MAX_SETTINGS_IN_A_SCREEN + dict_for_options.get(mode).get(setting).index(option)].click.wait()
            else:
                d(resourceId="com.intel.camera22:id/hori_list_button")[len(dict_for_settings.get(mode)) + dict_for_options.get(mode).get(setting).index(option)].click.wait()

        else:
            print 'else'
            # d(resourceId="com.intel.camera22:id/hori_list_button")[6].drag.to(resourceId="com.intel.camera22:id/hori_list_button")[0]
            d.swipe(640,180,100,180,steps=10)
            print dict_for_settings.get(mode).index(setting)
            print len(dict_for_settings.get(mode))
            d(resourceId="com.intel.camera22:id/hori_list_button")[dict_for_settings.get(mode).index(setting) - (len(dict_for_settings.get(mode)) - MAX_SETTINGS_IN_A_SCREEN)].click.wait()
            d(resourceId="com.intel.camera22:id/hori_list_button")[MAX_SETTINGS_IN_A_SCREEN + dict_for_options.get(mode).get(setting).index(option)].click.wait()
        

        print dict_for_settings_keys.get(setting)
        if setting == 'Geo':
            result = commands.getoutput('adb shell cat /data/data/com.intel.camera22/shared_prefs/com.intel.camera22_preferences_0.xml | grep ' + dict_for_settings_keys.get(setting))
        else:
            result = commands.getoutput('adb shell cat /data/data/com.intel.camera22/shared_prefs/com.intel.camera22_preferences_0_0.xml | grep ' + dict_for_settings_keys.get(setting))
        
        print result
        return result
Exemple #2
0
def test():
    launch_tb_activity()
    Facial_x = 338
    Facial_y = 270
    # apply_one(Facial_x,Facial_y)

    Cloth_x = 551
    Cloth_y = 270
    #apply_one(Cloth_x,Cloth_y)

    Tech_x = 820
    Tech_y = 270
    #apply_one(Tech_x,Tech_y)

    time.sleep(5)
    d.swipe(900, 270, 10, 270)
    time.sleep(8)

    Eletronic_x = 108
    Eletronic_y = 270
    apply_one(Eletronic_x, Eletronic_y)

    House_x = 270
    House_y = 270
    apply_one(House_x, House_y)

    time.sleep(2)
    d.press("home")
    print("Done")
Exemple #3
0
    def testCallFromPhoneBook(self):
        """
        Summary:testCallFromPhoneBook: Make a call from phonebook.
        Steps:1. Launch phone app
              2. Touch Contacts tab
              3. Touch the first contact
              4. Touch call button to make a call
              5. End the call
              6. Exit Phone app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Favorites and all contacts').wait.exists(), 'Phone launch failed'
        #step2
        d(description = 'Favorites and all contacts').click.wait()
        #step3,4
        for i in range (random.randint(1,5)):
            d.swipe(196,700,196,180,steps = 10)
      
        for i in range (random.randint(1,5)):
            d.swipe(196,180,196,700,steps = 10)

        d.click(random.randint(130,370),random.randint(217,871))
        assert d(text = 'Dialing').wait.exists(timeout = 15000), 'Not start to call'
        assert d(textContains = '0:').wait.exists(timeout = 15000), 'Call is not connected'
        #step5
        d(description = 'End').click.wait()
        assert d(description = 'Favorites and all contacts').wait.exists(), 'Call end failed'
Exemple #4
0
    def testDeleteVideo(self):
        """
        Summary:testRecordVideoAndDelete: Record a video, then play and delete the video.
        Steps:1. Open Camera app
              2. Record a video
              3. Touch thumbnail to view the video
              4. Touch Delete button to delete the video
              5. Exit Camera app
        """
        BEFORE_DELETE=commands.getoutput(QUERY_VIDEO_COUNT_COMMANDS)

        #step1,2
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Shutter button').wait.exists(), 'Camera launch failed'
        d(description = 'Camera, video, or panorama selector').click.wait()
        d(description = 'Switch to video').click.wait()
        assert d(description = 'Shutter button').wait.exists(), 'Video Camera launch failed'

        #step3
        d.swipe(startX, startY, endX, endY, steps = 10)
        time.sleep(2)
        d.click(274,482)

        #step4
        d.press('menu')
        assert d(text = 'Delete').wait.exists()
        d(text = 'Delete').click.wait()
        d(text = 'OK').click.wait(timeout = 2000)

        AFTER_DELETE = commands.getoutput(QUERY_VIDEO_COUNT_COMMANDS)

        assert int(AFTER_DELETE) == int(BEFORE_DELETE) - 1, 'Video record failed'
Exemple #5
0
    def testAlarmDelete(self):
        """
        Summary:testAlarmDelete: Delete an alarm.
        Steps:
                1.Launch alarm and check launch successfully
                2.Verify alarm is exist or not
                3.If no alarm, then add one
                4.Delete an alarm
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Alarms').wait.exists(), 'Clock launch failed'

        d(description = 'Alarms').click.wait()
        assert d(text = 'Alarms').wait.exists(), 'Alarm launch failed'

        #step2,3
        ALARM_COUNT = commands.getoutput(QUERY_ALARM_COUNT_COMMANDS)
        if int(ALARM_COUNT) == 0:
            d(description = 'Add alarm').click.wait()
            d(text = 'Cancel').click.wait()

        #step4
        d.swipe(startX, startY, endX, endY, steps = 10)
        assert d(text = 'Alarm deleted.'), 'Alarm delete failed'
Exemple #6
0
    def testPlayVideo(self):
        """
        Summary:testRecordVideoAndDelete: Record a video, then play and delete the video.
        Steps:1. Open Camera app
              2. Record a video
              3. Touch thumbnail to view the video
              4. Tocuh screen center to play the video
              5. Exit Camera app
        """
        #step1,2
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Shutter button').wait.exists(), 'Camera launch failed'
        d(description = 'Camera, video, or panorama selector').click.wait()
        d(description = 'Switch to video').click.wait()
        assert d(description = 'Shutter button').wait.exists(), 'Video Camera launch failed'

        #step3
        d.swipe(startX, startY, endX, endY, steps = 10)
        time.sleep(2)
        d.click(274,482)
        d.press('menu')
        assert d(text = 'Delete').wait.exists()

        #step4
        d.press('back')
        d.click(274,482)
        time.sleep(10)
        d.click(274,482)
        # assert playing progress bar exist
        assert d(index = 2, className = 'android.view.View').wait.exists(), 'Video play failed'
Exemple #7
0
    def test_launcher_widgets(self):
        print("Test Widgets")
        d.press.back()
        time.sleep(2)
        d.press.home()
        time.sleep(2)
        d.press.menu()
        if d(text="Widgets",className="android.widget.TextView", resourceId="com.android.launcher3:id/widget_button").exists:
            print("Found Widgets")
            d(text="Widgets",className="android.widget.TextView", resourceId="com.android.launcher3:id/widget_button").click()
            time.sleep(2)
            while not d(text="Email",className="android.widget.TextView", resourceId="com.android.launcher3:id/widget_name").exists:
                d.swipe(400, 500, 50, 500, steps=50);
            if d(className="android.widget.LinearLayout").child(text="Email",className="android.widget.TextView", resourceId="com.android.launcher3:id/widget_name").exists:
                print("swipe email widget to launcher")
                d.drag(360, 200, 480, 200, steps=100)
                time.sleep(2)
                if d(text="Choose folder",className="android.widget.TextView", resourceId="android:id/action_bar_title").exists:
                    print("choose inbox folder for email")
                    d(text="Inbox",className="android.widget.TextView", resourceId="com.android.email:id/name").click()
                    time.sleep(2)
                else:
                    print("drap email widget to launcher fail")
            else:
                print("No found email widget")
            d.press.back()
            time.sleep(2)

        else:
            print("No found widgets button")
        d.press.back()
        time.sleep(2)
Exemple #8
0
    def testDeletePicture(self):
        """
        Summary:testCapturePictureAndDelete: Take a picture, then view and delete the picture.
        Steps:1. Open Camera app
              2. Touch thumbnail to view the picture
              3. Touch setting menu
              4. Touch Delete button to delete the picture
              5. Exit Camera app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Shutter button').wait.exists(), 'Camera launch failed'

        BEFORE_DELETE = commands.getoutput(QUERY_PICTURE_COUNT_COMMANDS)

        #step2
        d.swipe(startX, startY, endX, endY, steps = 10)
        time.sleep(2)
        d.click(274,482)

        #step3
        d.press('menu')
        assert d(text = 'Delete').wait.exists()

        #step4
        d(text = 'Delete').click.wait()
        d(text = 'OK').click.wait(timeout = 2000)

        AFTER_DELETE = commands.getoutput(QUERY_PICTURE_COUNT_COMMANDS)
        assert int(AFTER_DELETE) == int(BEFORE_DELETE) - 1, 'Picture delete failed'
 def wifi(self):
   device.screen.on()
   device.press.menu()
   device(text ="Settings").click()
   device(text ="Wireless & networks").down(className="android.widget.TextView").click()
   device.screenshot("home.png")
   device.swipe(591,191,688,245)
   device.press.home()
Exemple #10
0
def electron():
    launch_tb_activity()
    print("electron")
    x = 108
    y = 270
    d.swipe(900, 270, 10, 270)
    time.sleep(2)
    apply_one(x, y)
    exit_tb()
Exemple #11
0
def others():
    d.swipe(900, 270, 10, 270)
    time.sleep(2)
    launch_tb_activity()
    print("others")
    x = 820
    y = 270
    apply_one(x, y)
    exit_tb()
Exemple #12
0
def house():
    d.swipe(900, 270, 10, 270)
    time.sleep(2)
    launch_tb_activity()
    print("house")
    x = 270
    y = 270
    apply_one(x, y)
    exit_tb()
def main():
    #base_info()



    #base_info()

    #op_test()

    print("Go")
    #t=Device('0331416080186')
    print("Start")

    #print(t.info)



    #d.press.home()
    #d.swipe(200,500,700,500)

    #d.press.home()
    #click_test()

    #scroll_test()

    '''
    d.press.home()
    d.swipe(200,500,700,500)

    #d.press.home()
    click_test()
    '''
    #liuliang()
    #d(text=u'数码科技').click()
    #if d(text=u'腾讯体育').exists:
    #print("Existed")
    #d.dump("hierarchy.xml")
    #d.swipe(500,1570,500,400)
    delta_each = 400
    time.sleep(3)

    for dragtime in range(20):
        print('dragtime')
        for i in range(3):
            d.click(919, 420 + i * delta_each)
            print('click')
            time.sleep(8)
            #each_dianpu()
            each_dianpu()
            time.sleep(8)
        d.swipe(919, 420 + delta_each * 3, 919, 400)
        time.sleep(5)
Exemple #14
0
    def testOpenPicture(self):
        """
        Summary:testCapturePictureAndDelete: Take a picture, then view and delete the picture.
        Steps:1. Open Camera app
              2. Touch thumbnail to view the picture
              3. Exit Camera app
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Shutter button').wait.exists(), 'Camera launch failed'

        #Step2
        d.swipe(startX, startY, endX, endY, steps = 10)
        time.sleep(2)
        d.click(274,482)
        d.press('menu')
        assert d(text = 'Delete').wait.exists()
Exemple #15
0
    def testOpenMusicPlayer(self):
        """
        Summary:testOpenMusicPlayer: Open music player.
        Steps: 1. Open music app
               2. Touch All tab
               3. Play a music file
               4. Back to home screen, run music on background
        """
        #step1
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(text = 'Listen Now').wait.exists(), 'Music player launch failed'

        #step2
        d.swipe(0,400,400,400,steps=10)
        assert d(text = 'Playlists').wait.exists(), 'Option bar launch failed'

        d(text = 'Playlists').click.wait()
        assert d(text = 'Last added').wait.exists(), 'Playlists launch failed'

        #step3
        d(text = 'Last added').click.wait()
        d.click(120,400)
        assert d(description = 'Pause').wait.exists(), 'Music play failed'
Exemple #16
0
def launch_tb():  # cling position method
    d.screen.on()
    time.sleep(1)
    os.system("adb shell am force-stop com.taobao.taobao")
    time.sleep(1)
    d.press("home")
    d.swipe(120, 1110, 900, 1110)

    d(text="shopping").click()
    time.sleep(1)
    # launch TB
    d.click(225, 1300)
    time.sleep(8)

    #click Trial
    d.click(950, 900)
    time.sleep(8)
    #click Te She Dao Gou
    d.click(300, 300)
    time.sleep(8)
    #click Free to try
    d.click(930, 1105)
    time.sleep(10)
Exemple #17
0
    def testAlarmAdd(self):
        '''
        Summary:testAlarmAdd: Add an alarm.
        Steps:
                1.Launch alarm and check launch successfully
                2.Get alarm number
                3.Verify alarm is exist or not
                4.If exist, delete it
                5.Add alarm
        '''
        #step1
        #os.system('adb shell am start ' + self.runComponent)
        commands.getoutput('adb shell am start ' + self.runComponent)
        assert d(description = 'Alarms').wait.exists(), 'Clock launch failed'

        d(description = 'Alarms').click.wait()
        assert d(text = 'Alarms').wait.exists(), 'Alarm launch failed'

        #step2
        #BEFORE_DELETE = os.popen(QUERY_ALARM_COUNT_COMMANDS)
        BEFORE_DELETE = commands.getoutput(QUERY_ALARM_COUNT_COMMANDS)

        #step3,4
        for i in range(0, int(BEFORE_DELETE)):
            d.swipe(startX, startY, endX, endY, steps = 10)
            assert d(text = 'Alarm deleted.'), 'Alarm delete failed'
            
        #AFTER_DELETE = os.popen(QUERY_ALARM_COUNT_COMMANDS)
        AFTER_DELETE = commands.getoutput(QUERY_ALARM_COUNT_COMMANDS)
        assert int(AFTER_DELETE) == 0, 'Still exist alarm'


        #step5
        d(description = 'Add alarm').click.wait()
        d(text = 'Cancel').click.wait()

        assert d(text = ':00').wait.exists(), 'Alarm create failed'
Exemple #18
0
def runtest(serialno, loop):
    print "liu: in runtest"
    if serialno:
        print "liu: in serialno"
        from uiautomator import Device
        d = Device(serialno)
    else:
        print "liu: in else"
        from uiautomator import device as d

    print "总共 %d 次循环" %loop
    d.watcher("Vellamo out of memory").when(text="Vellamo Out of Memory").click(text="ok")
    for i in range(1, loop+1):
        print "第 %d 次循环" %i
        d.screen.on()
        d.press.home()
        removeRecentList(d, "Benchmarking Application")
        d(description="Apps").click()
        d(text="Vellamo").click()
        time.sleep(2)

        if d(text="Accept").exists:
            d(text="Accept").click()
        if d(text="Welcome").exists:
            d.swipe(500,240,100,240)
            d.swipe(500,240,100,240)
            d.swipe(500,240,100,240)
        d(className="android.support.v4.view.ViewPager", \
            resourceId="com.quicinc.vellamo:id/act_main_pager_portrait")\
            .child(className="android.view.View")[0].click()

        #d(className="android.view.View")[2].click()
        if d(text="Yes").exists:
            d(text="Yes").click()
        while not d(text="Your device's score!").exists:
            time.sleep(2)
        else:
            d.screenshot("%s/screenshot/%d_vellamo_%s.png"\
                    %(sys.path[0], i, now.strftime(ISOFORMAT)))

        d.press.home()
        i += 1

    print "***** test end ********"
Exemple #19
0
 def test_idlescreen_swipe(self):
     print("Swipe on idlescreen")
     d.swipe(300, 480, 480, 20, steps=10)
     time.sleep(2)
     d.swipe(300, 480, 480, 20, steps=10)
     time.sleep(2)