コード例 #1
0
 def AddEffects_Screenshot_HomeScreen(self):
     """ Add Effects and take Screenshot then HomeScreen
     """
     self.photos.open_a_picture()
     time.sleep(1)
     print "catch screenshot before_effect.png"
     self._device.screenshot("before.png")
     time.sleep(1)
     cmd = 'mv before.png ' + self.tmpdir + '/before.png'
     os.system(cmd)
     self.photos.apply_filter_to_photos("filter Mars")
     time.sleep(1)
     print "catch screenshot after_effect.png"
     self._device.screenshot("after.png")
     time.sleep(1)
     cmd = 'mv after.png ' + self.tmpdir + '/after.png'
     os.system(cmd)
     time.sleep(1)
     rms = compare_pic.compare_pic(self.tmpdir + "/before.png",
                                   self.tmpdir + "/after.png")
     time.sleep(1)
     print "The Similarity value of 2 screenshot is %s" % rms
     assert rms >= 5, "The screenshot is same with before add effect"
     time.sleep(2)
     self._device.press.home()
コード例 #2
0
 def addeffects_check_screenshot(self):
     """ Add Effects and take Screenshot to compare
     """
     self.photos.open_a_picture()
     time.sleep(2)
     print "catch screenshot before_effect.png"
     self.d.screenshot("before.png")
     time.sleep(1)
     cmd = 'mv before.png ' + self.tmpdir + '/before.png'
     os.system(cmd)
     self.photos.apply_filter_to_photos("filter Deimos")
     print "catch screenshot after_effect.png"
     self.d.screenshot("after.png")
     time.sleep(1)
     cmd = 'mv after.png ' + self.tmpdir + '/after.png'
     os.system(cmd)
     time.sleep(1)
     rms = compare_pic.compare_pic(self.tmpdir + "/before.png",
                                   self.tmpdir + "/after.png")
     time.sleep(1)
     print "The Similarity value of 2 screenshot is %s" % rms
     assert rms > 5, "The screenshot is same with before add effect"
     time.sleep(5)
     self.d.press.back()
     time.sleep(1)
コード例 #3
0
ファイル: multi_display.py プロジェクト: zenghui0-0/tempfile
 def test_2SimultaneousDisplays_HDMI1_HDMI2(self):
     multi_display.is_multi_displayed()
     croped_pri_image = multi_display.get_screenshot_multidisplay_croped(
         multi_display.PRIMARY_DISPLAY_ID)
     croped_ext_image = multi_display.get_screenshot_multidisplay_croped(
         multi_display.EXTERNAL_DISPLAY_ID)
     rms = compare_pic.compare_pic(croped_pri_image, croped_ext_image)
     assert rms < 2, "Not same screen between two displays."
コード例 #4
0
 def check_pic(self):
     """ check edit picture effect via compare 2 screenshot
     """
     path = os.getcwd()
     print "current path is " + path
     time.sleep(1)
     rms = compare_pic.compare_pic(path + "/before.png", path + "/after.png")
     time.sleep(1)
     print "The Similarity value of 2 screenshot is %s" % rms
     assert rms >= 20, "The screenshot is same with before add effect"
コード例 #5
0
 def is_clone_mode(self):
     # Capture 1 / 4 area for both display and compare with each other to find if
     # they're the same picture.
     LOG.debug('Check device if is in clone mode.')
     sx, sy, ex, ey = 0, 0, self.d.info['displayWidth'] / 2, self.d.info[
         'displayHeight'] / 2
     img1 = self.get_screenshot_multidisplay_croped(self.PRIMARY_DISPLAY_ID,
                                                    sx, sy, ex, ey)
     img2 = self.get_screenshot_multidisplay_croped(
         self.EXTERNAL_DISPLAY_ID, sx, sy, ex, ey)
     assert compare_pic.compare_pic(img1, img2) < 2, "Not in clone mode."
     return True
コード例 #6
0
 def is_show_different_picture(self):
     # Capture 1 / 4 area for both display and compare with each other to find if
     # they're the same picture.
     LOG.debug('Check device if shows different pictures.')
     sx, sy, ex, ey = 0, 0, self.d.info['displayWidth'] / 2, self.d.info[
         'displayHeight'] / 2
     img1 = self.get_screenshot_multidisplay_croped(self.PRIMARY_DISPLAY_ID,
                                                    sx, sy, ex, ey)
     img2 = self.get_screenshot_multidisplay_croped(
         self.EXTERNAL_DISPLAY_ID, sx, sy, ex, ey)
     assert compare_pic.compare_pic(
         img1, img2) > 20, "Got same picture on those displays."
     return True
 def test_ImageEdit_ContinouslyRotate_SaveImage(self):
     ''' refer TC test_ImageEdit_ContinouslyRotate_SaveImage
     '''
     print "[RunTest]: %s" % self.__str__()
     self.photos.launch_photos_am()
     self.photos.open_a_picture()
     self.photos.click_crop_tools()
     im1 = multi_display.get_screenshot_forMultiDisplay(0)
     # --------Rotate left or right--------
     for _ in range(4):
         self.photos.rotate_90_degrees()
     sleep(3)
     im2 = multi_display.get_screenshot_forMultiDisplay(0)
     assert compare_pic.compare_pic(im1,
                                    im2) < 5, "Got diff between two pics."
     self.photos.stop_photos_am()
コード例 #8
0
 def check_docx(self):
     """ get screenshot and check cocx which template docx by screenshot in DocsToGo.
     """
     assert self._device(
         text="Untitled.docx"
     ).exists, "Can not find the edited file Untitled.docx"
     self._device(text="Untitled.docx").click.wait()
     time.sleep(2)
     print "Excute:Select all"
     self._locator.more_btn.click.wait()
     time.sleep(1)
     self._locator.edit_btn.click.wait()
     time.sleep(1)
     self._locator.select_all_btn.click.wait()
     time.sleep(2)
     self.get_docx_screenshot("before.png")
     self._locator.return_btn.click.wait()
     time.sleep(2)
     self.check_ad()
     self._locator.back_btn.click.wait()
     time.sleep(1)
     if self._locator.back_btn.exists:
         self._locator.back_btn.click.wait()
         time.sleep(1)
     if not self._device(text="template.docx").exists:
         self._device(scrollable=True).scroll.to(text="template.docx")
     time.sleep(1)
     assert self._device(
         text="template.docx").exists, "can not found template.docx"
     self._device(text="template.docx").click.wait()
     time.sleep(2)
     print "Excute:Select all"
     self._locator.more_btn.click.wait()
     time.sleep(1)
     self._locator.edit_btn.click.wait()
     time.sleep(1)
     self._locator.select_all_btn.click.wait()
     time.sleep(2)
     self.get_docx_screenshot("after.png")
     time.sleep(2)
     rms = compare_pic.compare_pic(self.tmpdir + "/before.png",
                                   self.tmpdir + "/after.png")
     time.sleep(1)
     print "The Similarity value of 2 screenshot is %s" % rms
     assert rms <= 5, "Add front fail,rms=%s" % rms
コード例 #9
0
 def change_display_size_and_check(self, value='Default'):
     current_value = self._d(
         resourceId='com.android.settings:id/current_label').info['text']
     # not capture wifi area
     before_change = multi_display.get_screenshot_multidisplay_croped(
         0, 100, 100, 200, 200)
     self._d(className='android.widget.RadioButton',
             description=value).click()
     sleep(3)
     # not capture wifi area
     after_change = multi_display.get_screenshot_multidisplay_croped(
         0, 100, 100, 200, 200)
     rms = compare_pic.compare_pic(before_change, after_change)
     if value == current_value:
         assert rms == 0, "Display size not same."
     else:
         assert rms > 0, "Display size not take effect."
     return True
コード例 #10
0
 def diff_pic_after_rotate(self):
     """ diff the pic in widget after rotate
     """
     self.photos.open_a_picture()
     self.photos.click_crop_tools()
     print "catch template.png"
     bounds_template = self._device(
         resourceId="com.google.android.apps.photos:id/cpe_crop_overlay"
     ).bounds
     path_template = get_screenshot_region(bounds_template)
     cmd = "mv %s /tmp/template.png" % path_template
     os.system(cmd)
     time.sleep(2)
     for _ in range(0, 4):
         self.photos.rotate_90_degrees()
         time.sleep(1)
     print "catch rotate.png"
     bounds = self._device(
         resourceId="com.google.android.apps.photos:id/cpe_crop_overlay"
     ).bounds
     path = get_screenshot_region(bounds)
     cmd = "mv %s /tmp/rotate.png" % path
     os.system(cmd)
     rms = compare_pic.compare_pic("/tmp/template.png", "/tmp/rotate.png")
     time.sleep(1)
     print "The Similarity value of 2 screenshot is %s" % rms
     assert rms < 5, "The picture is not same with template"
     if self._device(
             resourceId=
             "com.google.android.apps.photos:id/cpe_strength_accept"):
         self._device(
             resourceId=
             "com.google.android.apps.photos:id/cpe_strength_accept"
         ).click.wait()
     if self._device(
             resourceId="com.google.android.apps.photos:id/cpe_save_button"
     ):
         self._device(
             resourceId="com.google.android.apps.photos:id/cpe_save_button"
         ).click.wait()
コード例 #11
0
 def check_picture(self, mode):
     """ Check picture effect
     """
     g_common_obj.assert_exp_happens()
     for _ in range(0, 3):
         if self._device(
                 resourceId="com.android.rs.image:id/display").exists:
             break
         else:
             self.launch_app_am()
             time.sleep(3)
     print "catch before screenshot:"
     assert self._device(resourceId="com.android.rs.image:id/display"
                         ).exists, "can not find the picture widget"
     bounds_template = self._device(
         resourceId="com.android.rs.image:id/display").bounds
     self.path_before = get_screenshot_region(bounds_template)
     print self.path_before
     self.choose_mode(mode)
     g_common_obj.assert_exp_happens()
     self._device(scrollable=True).scroll.vert.toEnd()
     time.sleep(2)
     self.add_effect()
     g_common_obj.assert_exp_happens()
     self._device(scrollable=True).scroll.vert.backward(steps=5)
     time.sleep(1)
     print "catch after screenshot:"
     assert self._device(resourceId="com.android.rs.image:id/display"
                         ).exists, "can not find the picture widget"
     bounds_template = self._device(
         resourceId="com.android.rs.image:id/display").bounds
     self.path_after = get_screenshot_region(bounds_template)
     print self.path_after
     rms = compare_pic.compare_pic(self.path_before, self.path_after)
     time.sleep(1)
     print "The Similarity value of 2 screenshot is %s" % rms
     if mode == "Copy":
         assert rms == 0, "The screenshot is not same with before change in Imageprocessing"
     else:
         assert rms > 0, "The screenshot is same with before change in Imageprocessing"
コード例 #12
0
ファイル: ComposeUI_gits.py プロジェクト: zenghui0-0/tempfile
    def test_shadow_sampleapkelevationbasic(self):
        """
        refer TC test_Shadow_SampleAPKElevationBasic
        """
        print "[RunTest]: %s" % self.__str__()
        # install apk if not exists in package list
        if self.basic_pkg_name not in pkgmgr.get_packages():
            apk_path = get_resource_from_atifactory(self.case_cfg,
                                                    'ElevationBasic', 'apk')
            pkgmgr.apk_install(apk_path)
        # launch app
        run_cmd = "am start -S -n %s/%s" % (self.basic_pkg_name,
                                            self.activity_name)
        g_common_obj.adb_cmd_capture_msg(run_cmd)
        sleep(2)
        # screen capture before operation
        sx, sy, ex, ey = self.d.info["displayWidth"] / 2, \
                         0, \
                         self.d.info["displayWidth"], \
                         self.d.info["displayHeight"]
        img_before = multi_display.get_screenshot_multidisplay_croped(
            0, sx, sy, ex, ey)

        # define operation type
        def long_tap_content():
            d = g_common_obj.get_device()
            d(resourceId="com.example.android.elevationbasic:id/floating_shape_2"
              ).long_click()

        # start test
        thread = threading.Timer(1.5, long_tap_content)
        thread.start()
        # screen capture after operation
        sleep(2)
        img_after = multi_display.get_screenshot_multidisplay_croped(
            0, sx, sy, ex, ey)
        assert compare_pic.compare_pic(
            img_before, img_after) > 4, "No diff after operation"
コード例 #13
0
ファイル: GPUoverdraw.py プロジェクト: zenghui0-0/tempfile
 def test_DebugMode_GPUOverdraw(self):
     img1 = self.dgo.enable_show_overdraw_areas_get_screenshot()
     img2 = self.dgo.enable_show_areas_for_deuteranomaly_get_screenshot()
     rms1 = compare_pic.compare_pic(self.img_default, img1)
     rms2 = compare_pic.compare_pic(self.img_default, img2)
     assert rms1 > 0 and rms2 > 0, "Fail to set GPU overdraw."