Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: telemetry/telemetry/page/page_run_end_to_end_unittest.py

Issue 2457303003: Revert of [Telemetry] Ensure that story display names are unique (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import re 6 import re
7 import shutil 7 import shutil
8 import sys 8 import sys
9 import StringIO 9 import StringIO
10 import tempfile 10 import tempfile
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 self.formatted_exception, 138 self.formatted_exception,
139 re.DOTALL | re.MULTILINE) 139 re.DOTALL | re.MULTILINE)
140 self.assertEquals([expected_exception_name], actual_exception_names, 140 self.assertEquals([expected_exception_name], actual_exception_names,
141 msg='Full formatted exception: %s' % '\n > '.join( 141 msg='Full formatted exception: %s' % '\n > '.join(
142 self.formatted_exception.split('\n'))) 142 self.formatted_exception.split('\n')))
143 143
144 def testRaiseBrowserGoneExceptionFromRestartBrowserBeforeEachPage(self): 144 def testRaiseBrowserGoneExceptionFromRestartBrowserBeforeEachPage(self):
145 self.CaptureFormattedException() 145 self.CaptureFormattedException()
146 story_set = story.StorySet() 146 story_set = story.StorySet()
147 story_set.AddStory(page_module.Page( 147 story_set.AddStory(page_module.Page(
148 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 148 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
149 name='foo'))
150 story_set.AddStory(page_module.Page( 149 story_set.AddStory(page_module.Page(
151 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 150 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
152 name='bar'))
153 story_set.AddStory(page_module.Page( 151 story_set.AddStory(page_module.Page(
154 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 152 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
155 name='baz'))
156 153
157 class Test(legacy_page_test.LegacyPageTest): 154 class Test(legacy_page_test.LegacyPageTest):
158 155
159 def __init__(self, *args): 156 def __init__(self, *args):
160 super(Test, self).__init__( 157 super(Test, self).__init__(
161 *args, needs_browser_restart_after_each_page=True) 158 *args, needs_browser_restart_after_each_page=True)
162 self.run_count = 0 159 self.run_count = 0
163 160
164 def RestartBrowserBeforeEachPage(self): 161 def RestartBrowserBeforeEachPage(self):
165 # This will only be called twice with 3 pages. 162 # This will only be called twice with 3 pages.
(...skipping 15 matching lines...) Expand all
181 story_runner.Run(test, story_set, options, results) 178 story_runner.Run(test, story_set, options, results)
182 self.assertEquals(2, test.run_count) 179 self.assertEquals(2, test.run_count)
183 self.assertEquals(2, len(GetSuccessfulPageRuns(results))) 180 self.assertEquals(2, len(GetSuccessfulPageRuns(results)))
184 self.assertEquals(1, len(results.failures)) 181 self.assertEquals(1, len(results.failures))
185 self.assertFormattedExceptionIsEmpty() 182 self.assertFormattedExceptionIsEmpty()
186 183
187 def testNeedsBrowserRestartAfterEachPage(self): 184 def testNeedsBrowserRestartAfterEachPage(self):
188 self.CaptureFormattedException() 185 self.CaptureFormattedException()
189 story_set = story.StorySet() 186 story_set = story.StorySet()
190 story_set.AddStory(page_module.Page( 187 story_set.AddStory(page_module.Page(
191 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 188 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
192 name='foo'))
193 story_set.AddStory(page_module.Page( 189 story_set.AddStory(page_module.Page(
194 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 190 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
195 name='bar'))
196 191
197 class Test(legacy_page_test.LegacyPageTest): 192 class Test(legacy_page_test.LegacyPageTest):
198 193
199 def __init__(self, *args, **kwargs): 194 def __init__(self, *args, **kwargs):
200 super(Test, self).__init__(*args, **kwargs) 195 super(Test, self).__init__(*args, **kwargs)
201 self.browser_starts = 0 196 self.browser_starts = 0
202 197
203 def DidStartBrowser(self, *args): 198 def DidStartBrowser(self, *args):
204 super(Test, self).DidStartBrowser(*args) 199 super(Test, self).DidStartBrowser(*args)
205 self.browser_starts += 1 200 self.browser_starts += 1
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 finally: 564 finally:
570 shutil.rmtree(options.output_dir) 565 shutil.rmtree(options.output_dir)
571 566
572 def _RunPageTestThatRaisesAppCrashException(self, test, max_failures): 567 def _RunPageTestThatRaisesAppCrashException(self, test, max_failures):
573 class TestPage(page_module.Page): 568 class TestPage(page_module.Page):
574 569
575 def RunNavigateSteps(self, _): 570 def RunNavigateSteps(self, _):
576 raise exceptions.AppCrashException 571 raise exceptions.AppCrashException
577 572
578 story_set = story.StorySet() 573 story_set = story.StorySet()
579 for i in range(5): 574 for _ in range(5):
580 story_set.AddStory( 575 story_set.AddStory(
581 TestPage('file://blank.html', story_set, 576 TestPage('file://blank.html', story_set,
582 base_dir=util.GetUnittestDataDir(), name='foo%d' % i)) 577 base_dir=util.GetUnittestDataDir()))
583 options = options_for_unittests.GetCopy() 578 options = options_for_unittests.GetCopy()
584 options.output_formats = ['none'] 579 options.output_formats = ['none']
585 options.suppress_gtest_report = True 580 options.suppress_gtest_report = True
586 SetUpStoryRunnerArguments(options) 581 SetUpStoryRunnerArguments(options)
587 results = results_options.CreateResults(EmptyMetadataForTest(), options) 582 results = results_options.CreateResults(EmptyMetadataForTest(), options)
588 story_runner.Run(test, story_set, options, results, 583 story_runner.Run(test, story_set, options, results,
589 max_failures=max_failures) 584 max_failures=max_failures)
590 return results 585 return results
591 586
592 def testSingleTabMeansCrashWillCauseFailureValue(self): 587 def testSingleTabMeansCrashWillCauseFailureValue(self):
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 results.pages_to_profiling_files) 773 results.pages_to_profiling_files)
779 screenshot_file_path = ( 774 screenshot_file_path = (
780 results.pages_to_profiling_files[failing_page][0].GetAbsPath()) 775 results.pages_to_profiling_files[failing_page][0].GetAbsPath())
781 try: 776 try:
782 actual_screenshot_img = image_util.FromPngFile(screenshot_file_path) 777 actual_screenshot_img = image_util.FromPngFile(screenshot_file_path)
783 self.assertTrue(image_util.AreEqual( 778 self.assertTrue(image_util.AreEqual(
784 image_util.FromBase64Png(expected_png_base64), 779 image_util.FromBase64Png(expected_png_base64),
785 actual_screenshot_img)) 780 actual_screenshot_img))
786 finally: # Must clean up screenshot file if exists. 781 finally: # Must clean up screenshot file if exists.
787 os.remove(screenshot_file_path) 782 os.remove(screenshot_file_path)
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/story_runner_unittest.py ('k') | telemetry/telemetry/story/story_set.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698