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

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

Issue 2163583002: 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, 5 months 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 self.formatted_exception, 136 self.formatted_exception,
137 re.DOTALL | re.MULTILINE) 137 re.DOTALL | re.MULTILINE)
138 self.assertEquals([expected_exception_name], actual_exception_names, 138 self.assertEquals([expected_exception_name], actual_exception_names,
139 msg='Full formatted exception: %s' % '\n > '.join( 139 msg='Full formatted exception: %s' % '\n > '.join(
140 self.formatted_exception.split('\n'))) 140 self.formatted_exception.split('\n')))
141 141
142 def testRaiseBrowserGoneExceptionFromRestartBrowserBeforeEachPage(self): 142 def testRaiseBrowserGoneExceptionFromRestartBrowserBeforeEachPage(self):
143 self.CaptureFormattedException() 143 self.CaptureFormattedException()
144 story_set = story.StorySet() 144 story_set = story.StorySet()
145 story_set.AddStory(page_module.Page( 145 story_set.AddStory(page_module.Page(
146 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 146 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
147 name='foo'))
148 story_set.AddStory(page_module.Page( 147 story_set.AddStory(page_module.Page(
149 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 148 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
150 name='bar'))
151 story_set.AddStory(page_module.Page( 149 story_set.AddStory(page_module.Page(
152 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 150 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
153 name='baz'))
154 151
155 class Test(legacy_page_test.LegacyPageTest): 152 class Test(legacy_page_test.LegacyPageTest):
156 153
157 def __init__(self, *args): 154 def __init__(self, *args):
158 super(Test, self).__init__( 155 super(Test, self).__init__(
159 *args, needs_browser_restart_after_each_page=True) 156 *args, needs_browser_restart_after_each_page=True)
160 self.run_count = 0 157 self.run_count = 0
161 158
162 def RestartBrowserBeforeEachPage(self): 159 def RestartBrowserBeforeEachPage(self):
163 # This will only be called twice with 3 pages. 160 # This will only be called twice with 3 pages.
(...skipping 15 matching lines...) Expand all
179 story_runner.Run(test, story_set, options, results) 176 story_runner.Run(test, story_set, options, results)
180 self.assertEquals(2, test.run_count) 177 self.assertEquals(2, test.run_count)
181 self.assertEquals(2, len(GetSuccessfulPageRuns(results))) 178 self.assertEquals(2, len(GetSuccessfulPageRuns(results)))
182 self.assertEquals(1, len(results.failures)) 179 self.assertEquals(1, len(results.failures))
183 self.assertFormattedExceptionIsEmpty() 180 self.assertFormattedExceptionIsEmpty()
184 181
185 def testNeedsBrowserRestartAfterEachPage(self): 182 def testNeedsBrowserRestartAfterEachPage(self):
186 self.CaptureFormattedException() 183 self.CaptureFormattedException()
187 story_set = story.StorySet() 184 story_set = story.StorySet()
188 story_set.AddStory(page_module.Page( 185 story_set.AddStory(page_module.Page(
189 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 186 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
190 name='foo'))
191 story_set.AddStory(page_module.Page( 187 story_set.AddStory(page_module.Page(
192 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir(), 188 'file://blank.html', story_set, base_dir=util.GetUnittestDataDir()))
193 name='bar'))
194 189
195 class Test(legacy_page_test.LegacyPageTest): 190 class Test(legacy_page_test.LegacyPageTest):
196 191
197 def __init__(self, *args, **kwargs): 192 def __init__(self, *args, **kwargs):
198 super(Test, self).__init__(*args, **kwargs) 193 super(Test, self).__init__(*args, **kwargs)
199 self.browser_starts = 0 194 self.browser_starts = 0
200 195
201 def DidStartBrowser(self, *args): 196 def DidStartBrowser(self, *args):
202 super(Test, self).DidStartBrowser(*args) 197 super(Test, self).DidStartBrowser(*args)
203 self.browser_starts += 1 198 self.browser_starts += 1
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 finally: 520 finally:
526 shutil.rmtree(options.output_dir) 521 shutil.rmtree(options.output_dir)
527 522
528 def _RunPageTestThatRaisesAppCrashException(self, test, max_failures): 523 def _RunPageTestThatRaisesAppCrashException(self, test, max_failures):
529 class TestPage(page_module.Page): 524 class TestPage(page_module.Page):
530 525
531 def RunNavigateSteps(self, _): 526 def RunNavigateSteps(self, _):
532 raise exceptions.AppCrashException 527 raise exceptions.AppCrashException
533 528
534 story_set = story.StorySet() 529 story_set = story.StorySet()
535 for i in range(5): 530 for _ in range(5):
536 story_set.AddStory( 531 story_set.AddStory(
537 TestPage('file://blank.html', story_set, 532 TestPage('file://blank.html', story_set,
538 base_dir=util.GetUnittestDataDir(), name='foo%d' % i)) 533 base_dir=util.GetUnittestDataDir()))
539 options = options_for_unittests.GetCopy() 534 options = options_for_unittests.GetCopy()
540 options.output_formats = ['none'] 535 options.output_formats = ['none']
541 options.suppress_gtest_report = True 536 options.suppress_gtest_report = True
542 SetUpStoryRunnerArguments(options) 537 SetUpStoryRunnerArguments(options)
543 results = results_options.CreateResults(EmptyMetadataForTest(), options) 538 results = results_options.CreateResults(EmptyMetadataForTest(), options)
544 story_runner.Run(test, story_set, options, results, 539 story_runner.Run(test, story_set, options, results,
545 max_failures=max_failures) 540 max_failures=max_failures)
546 return results 541 return results
547 542
548 def testSingleTabMeansCrashWillCauseFailureValue(self): 543 def testSingleTabMeansCrashWillCauseFailureValue(self):
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 results.pages_to_profiling_files) 729 results.pages_to_profiling_files)
735 screenshot_file_path = ( 730 screenshot_file_path = (
736 results.pages_to_profiling_files[failing_page][0].GetAbsPath()) 731 results.pages_to_profiling_files[failing_page][0].GetAbsPath())
737 try: 732 try:
738 actual_screenshot_img = image_util.FromPngFile(screenshot_file_path) 733 actual_screenshot_img = image_util.FromPngFile(screenshot_file_path)
739 self.assertTrue(image_util.AreEqual( 734 self.assertTrue(image_util.AreEqual(
740 image_util.FromBase64Png(expected_png_base64), 735 image_util.FromBase64Png(expected_png_base64),
741 actual_screenshot_img)) 736 actual_screenshot_img))
742 finally: # Must clean up screenshot file if exists. 737 finally: # Must clean up screenshot file if exists.
743 os.remove(screenshot_file_path) 738 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