Beispiel #1
0
    def test_strip_metrics(self):
        patterns = [
            ('RenderView at (0,0) size 800x600', 'RenderView '),
            ('text run at (0,0) width 100: "some text"', '"some text"'),
            ('RenderBlock {HTML} at (0,0) size 800x600',
             'RenderBlock {HTML} '),
            ('RenderBlock {INPUT} at (29,3) size 12x12 [color=#000000]',
             'RenderBlock {INPUT}'),
            ('RenderBlock (floating) {DT} at (5,5) size 79x310 [border: (5px solid #000000)]',
             'RenderBlock (floating) {DT} [border: px solid #000000)]'),
            ('\n    "truncate text    "\n', '\n    "truncate text"\n'),
            ('RenderText {#text} at (0,3) size 41x12\n    text run at (0,3) width 41: "whimper "\n',
             'RenderText {#text} \n    "whimper"\n'),
            ("""text run at (0,0) width 109: ".one {color: green;}"
          text run at (109,0) width 0: " "
          text run at (0,17) width 81: ".1 {color: red;}"
          text run at (81,17) width 0: " "
          text run at (0,34) width 102: ".a1 {color: green;}"
          text run at (102,34) width 0: " "
          text run at (0,51) width 120: "P.two {color: purple;}"
          text run at (120,51) width 0: " "\n""",
             '".one {color: green;}  .1 {color: red;}  .a1 {color: green;}  P.two {color: purple;}"\n'
             ),
            ('text-- other text', 'text--other text'),
            (' some output   "truncate trailing spaces at end of line after text"   \n',
             ' some output   "truncate trailing spaces at end of line after text"\n'
             ),
            (r'scrollWidth 120', r'scrollWidth'),
            (r'scrollHeight 120', r'scrollHeight'),
        ]

        for pattern in patterns:
            driver_output = DriverOutput(pattern[0], None, None, None)
            driver_output.strip_metrics()
            self.assertEqual(driver_output.text, pattern[1])
Beispiel #2
0
    def run_test(self, test_input, stop_when_done):
        if not self.started:
            self.started = True
            self.pid = TestDriver.next_pid
            TestDriver.next_pid += 1

        start_time = time.time()
        test_name = test_input.test_name
        test_args = test_input.args or []
        test = self._port._tests[test_name]
        if test.keyboard:
            raise KeyboardInterrupt
        if test.exception:
            raise ValueError('exception from ' + test_name)
        if test.hang:
            time.sleep((float(test_input.timeout) * 4) / 1000.0 + 1.0)  # The 1.0 comes from thread_padding_sec in layout_test_runnery.

        audio = None
        actual_text = test.actual_text

        if 'flaky' in test_name and not test_name in self._port._flakes:
            self._port._flakes.add(test_name)
            actual_text = 'flaky text failure'

        if actual_text and test_args and test_name == 'passes/args.html':
            actual_text = actual_text + ' ' + ' '.join(test_args)

        if test.actual_audio:
            audio = test.actual_audio
        crashed_process_name = None
        crashed_pid = None
        if test.crash:
            crashed_process_name = self._port.driver_name()
            crashed_pid = 1
        elif test.web_process_crash:
            crashed_process_name = 'WebProcess'
            crashed_pid = 2

        crash_log = ''
        if crashed_process_name:
            crash_logs = CrashLogs(self._port.host)
            crash_log = crash_logs.find_newest_log(crashed_process_name, None) or ''

        if stop_when_done:
            self.stop()

        if test.actual_checksum == test_input.image_hash:
            image = None
        else:
            image = test.actual_image
        return DriverOutput(actual_text, image, test.actual_checksum, audio,
            crash=test.crash or test.web_process_crash, crashed_process_name=crashed_process_name,
            crashed_pid=crashed_pid, crash_log=crash_log,
            test_time=time.time() - start_time, timeout=test.timeout, error=test.error, pid=self.pid)
    def test_strip_metrics(self):
        patterns = [
            ("RenderView at (0,0) size 800x600", "RenderView "),
            ('text run at (0,0) width 100: "some text"', '"some text"'),
            ("RenderBlock {HTML} at (0,0) size 800x600", "RenderBlock {HTML} "),
            ("RenderBlock {INPUT} at (29,3) size 12x12 [color=#000000]", "RenderBlock {INPUT}"),
            (
                "RenderBlock (floating) {DT} at (5,5) size 79x310 [border: (5px solid #000000)]",
                "RenderBlock (floating) {DT} [border: px solid #000000)]",
            ),
            ('\n    "truncate text    "\n', '\n    "truncate text"\n'),
            (
                'RenderText {#text} at (0,3) size 41x12\n    text run at (0,3) width 41: "whimper "\n',
                'RenderText {#text} \n    "whimper"\n',
            ),
            (
                """text run at (0,0) width 109: ".one {color: green;}"
          text run at (109,0) width 0: " "
          text run at (0,17) width 81: ".1 {color: red;}"
          text run at (81,17) width 0: " "
          text run at (0,34) width 102: ".a1 {color: green;}"
          text run at (102,34) width 0: " "
          text run at (0,51) width 120: "P.two {color: purple;}"
          text run at (120,51) width 0: " "\n""",
                '".one {color: green;}  .1 {color: red;}  .a1 {color: green;}  P.two {color: purple;}"\n',
            ),
            ("text-- other text", "text--other text"),
            (
                ' some output   "truncate trailing spaces at end of line after text"   \n',
                ' some output   "truncate trailing spaces at end of line after text"\n',
            ),
            (r"scrollWidth 120", r"scrollWidth"),
            (r"scrollHeight 120", r"scrollHeight"),
        ]

        for pattern in patterns:
            driver_output = DriverOutput(pattern[0], None, None, None)
            driver_output.strip_metrics()
            self.assertEqual(driver_output.text, pattern[1])