def create_repaint_overlay_result(self, actual_text, expected_text): html = repaint_overlay.generate_repaint_overlay_html( self._test_name, actual_text, expected_text) if html: overlay_filename = self._output_abspath( self.FILENAME_SUFFIX_OVERLAY, '.html') self._write_file(overlay_filename, html)
def create_artifacts(self, typ_artifacts, force_overwrite=False): super(FailureTextMismatch, self).create_artifacts( typ_artifacts, force_overwrite) if six.PY2: html = repaint_overlay.generate_repaint_overlay_html( self.test_name, self.actual_driver_output.text, self.expected_driver_output.text) else: html = repaint_overlay.generate_repaint_overlay_html( self.test_name, self.actual_driver_output.text.decode('utf8', 'replace'), self.expected_driver_output.text.decode('utf8', 'replace')) if html: overlay_filename = self.port.output_filename( self.test_name, FILENAME_SUFFIX_OVERLAY, '.html') self._write_to_artifacts(typ_artifacts, 'overlay', overlay_filename, html.encode('utf8', 'replace'), force_overwrite)
def test_generate_repaint_overlay_html(self): test_name = 'paint/invalidation/repaint-overlay/layers.html' host = Host() port = host.port_factory.get() layer_tree_file = port.expected_filename(test_name, '.txt') if not layer_tree_file or not host.filesystem.exists(layer_tree_file): # This can happen if the scripts are not in the standard blink directory. return layer_tree = str(host.filesystem.read_text_file(layer_tree_file)) self.assertTrue( repaint_overlay.result_contains_repaint_rects(layer_tree)) overlay_html = ( '<!-- Generated by third_party/blink/tools/run_blinkpy_tests.py\n' + ' test case: TestRepaintOverlay.test_generate_repaint_overlay_html. -->\n' + repaint_overlay.generate_repaint_overlay_html( test_name, layer_tree, layer_tree)) results_directory = port.results_directory() host.filesystem.maybe_make_directory(results_directory) actual_overlay_html_file = host.filesystem.join( results_directory, 'layers-overlay.html') host.filesystem.write_text_file(actual_overlay_html_file, overlay_html) overlay_html_file = port.abspath_for_test( 'paint/invalidation/repaint-overlay/layers-overlay.html') expected = host.filesystem.read_text_file(overlay_html_file) self.assertEquals( expected, overlay_html, 'This failure is probably caused by changed repaint_overlay.py. ' 'Please examine the diffs:\n diff %s %s\n' 'If the diffs are valid, update the file:\n cp %s %s\n' 'then update layers-overlay-expected.html in the same directory if needed,' ' and commit the files together with the changed repaint_overlay.py.' % (overlay_html_file, actual_overlay_html_file, actual_overlay_html_file, overlay_html_file))