當前位置: 首頁>>代碼示例>>Python>>正文


Python VisualTest.mobile_resize方法代碼示例

本文整理匯總了Python中toolium.visual_test.VisualTest.mobile_resize方法的典型用法代碼示例。如果您正苦於以下問題:Python VisualTest.mobile_resize方法的具體用法?Python VisualTest.mobile_resize怎麽用?Python VisualTest.mobile_resize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在toolium.visual_test.VisualTest的用法示例。


在下文中一共展示了VisualTest.mobile_resize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_mobile_resize

# 需要導入模塊: from toolium.visual_test import VisualTest [as 別名]
# 或者: from toolium.visual_test.VisualTest import mobile_resize [as 別名]
def test_mobile_resize(driver_wrapper):
    # Update conf and create a new VisualTest instance
    driver_wrapper.driver.get_window_size.return_value = {'width': 375, 'height': 667}
    driver_wrapper.config.set('Driver', 'type', 'ios')
    visual = VisualTest(driver_wrapper)

    # Resize image
    img = Image.open(file_ios)
    img = visual.mobile_resize(img)

    # Assert output image
    assert_image(visual, img, 'report_name', 'ios_resized')
開發者ID:jframos,項目名稱:toolium,代碼行數:14,代碼來源:test_visual_test.py

示例2: test_mobile_no_resize

# 需要導入模塊: from toolium.visual_test import VisualTest [as 別名]
# 或者: from toolium.visual_test.VisualTest import mobile_resize [as 別名]
def test_mobile_no_resize(driver_wrapper):
    # Update conf and create a new VisualTest instance
    driver_wrapper.driver.get_window_size.return_value = {'width': 750, 'height': 1334}
    driver_wrapper.config.set('Driver', 'type', 'ios')
    visual = VisualTest(driver_wrapper)

    # Resize image
    orig_img = Image.open(file_ios)
    img = visual.mobile_resize(orig_img)

    # Assert that image object has not been modified
    assert orig_img == img
開發者ID:jframos,項目名稱:toolium,代碼行數:14,代碼來源:test_visual_test.py

示例3: VisualTests

# 需要導入模塊: from toolium.visual_test import VisualTest [as 別名]
# 或者: from toolium.visual_test.VisualTest import mobile_resize [as 別名]

#.........這裏部分代碼省略.........
    def test_get_html_row(self):
        expected_row = '<tr class=diff><td>test_get_html_row</td><td><img style="width: 100%" onclick=' \
                       '"launchModal\(this.src\)" src=".*register_v2.png"/></td></td><td><img style="width: 100%" ' \
                       'onclick="launchModal\(this.src\)" src=".*register.png"/></td></td><td></td></tr>'
        row = self.visual._get_html_row('diff', self._testMethodName, self.file_v1, self.file_v2)
        assertRegex(self, row, expected_row)

    def assert_image(self, img, img_name, expected_image_filename):
        """Save img in an image file and compare with the expected image

        :param img: image object
        :param img_name: temporary filename
        :param expected_image_filename: filename of the expected image
        """
        # Save result image in output folder
        result_file = os.path.join(self.visual.output_directory, img_name + '.png')
        img.save(result_file)

        # Output image and expected image must be equals
        expected_image = os.path.join(self.root_path, 'resources', expected_image_filename + '.png')
        PilEngine().assertSameFiles(result_file, expected_image, 0.1)

    def test_crop_element(self):
        # Create element mock
        web_element = get_mock_element(x=250, y=40, height=40, width=300)

        # Resize image
        img = Image.open(self.file_v1)
        img = self.visual.crop_element(img, web_element)

        # Assert output image
        self.assert_image(img, self._testMethodName, 'register_cropped_element')

    def test_mobile_resize(self):
        # Update conf and create a new VisualTest instance
        self.driver_wrapper.driver.get_window_size.return_value = {'width': 375, 'height': 667}
        self.driver_wrapper.config.set('Driver', 'type', 'ios')
        self.visual = VisualTest(self.driver_wrapper)

        # Resize image
        img = Image.open(self.file_ios)
        img = self.visual.mobile_resize(img)

        # Assert output image
        self.assert_image(img, self._testMethodName, 'ios_resized')

    def test_mobile_no_resize(self):
        # Update conf and create a new VisualTest instance
        self.driver_wrapper.driver.get_window_size.return_value = {'width': 750, 'height': 1334}
        self.driver_wrapper.config.set('Driver', 'type', 'ios')
        self.visual = VisualTest(self.driver_wrapper)

        # Resize image
        orig_img = Image.open(self.file_ios)
        img = self.visual.mobile_resize(orig_img)

        # Assert that image object has not been modified
        assert_equal(orig_img, img)

    def test_exclude_elements(self):
        # Create elements mock
        web_elements = [get_mock_element(x=250, y=40, height=40, width=300),
                        get_mock_element(x=250, y=90, height=20, width=100)]
        img = Image.open(self.file_v1)

        # Exclude elements
開發者ID:cesarca,項目名稱:toolium,代碼行數:70,代碼來源:test_visual_test.py


注:本文中的toolium.visual_test.VisualTest.mobile_resize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。