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

Side by Side Diff: telemetry/telemetry/internal/story_runner_unittest.py

Issue 2162963002: [polymer] Merge of master into polymer10-migration (Closed) Base URL: git@github.com:catapult-project/catapult.git@polymer10-migration
Patch Set: Merge polymer10-migration int polymer10-merge 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 math 5 import math
6 import os 6 import os
7 import StringIO 7 import StringIO
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 test = TestStoryTest() 357 test = TestStoryTest()
358 story_set = story_module.StorySet() 358 story_set = story_module.StorySet()
359 story_set.AddStory(DummyLocalStory(TestSharedStateForStoryTest)) 359 story_set.AddStory(DummyLocalStory(TestSharedStateForStoryTest))
360 story_runner.Run(test, story_set, self.options, self.results) 360 story_runner.Run(test, story_set, self.options, self.results)
361 return [call[0] for call in manager.mock_calls] 361 return [call[0] for call in manager.mock_calls]
362 362
363 calls_in_order = GetCallsInOrder() # pylint: disable=no-value-for-parameter 363 calls_in_order = GetCallsInOrder() # pylint: disable=no-value-for-parameter
364 self.assertEquals(EXPECTED_CALLS_IN_ORDER, calls_in_order) 364 self.assertEquals(EXPECTED_CALLS_IN_ORDER, calls_in_order)
365 365
366 def testTearDownStateAfterEachStoryRun(self): 366 def testTearDownStateAfterEachStoryOrStorySetRun(self):
367 class TestSharedStateForTearDown(TestSharedState): 367 class TestSharedStateForTearDown(TestSharedState):
368 num_of_tear_downs = 0 368 num_of_tear_downs = 0
369 369
370 def RunStory(self, results): 370 def RunStory(self, results):
371 pass 371 pass
372 372
373 def TearDownState(self): 373 def TearDownState(self):
374 TestSharedStateForTearDown.num_of_tear_downs += 1 374 TestSharedStateForTearDown.num_of_tear_downs += 1
375 375
376 story_set = story_module.StorySet() 376 story_set = story_module.StorySet()
377 story_set.AddStory(DummyLocalStory(TestSharedStateForTearDown)) 377 story_set.AddStory(DummyLocalStory(TestSharedStateForTearDown))
378 story_set.AddStory(DummyLocalStory(TestSharedStateForTearDown)) 378 story_set.AddStory(DummyLocalStory(TestSharedStateForTearDown))
379 story_set.AddStory(DummyLocalStory(TestSharedStateForTearDown)) 379 story_set.AddStory(DummyLocalStory(TestSharedStateForTearDown))
380 380
381 TestSharedStateForTearDown.num_of_tear_downs = 0 381 TestSharedStateForTearDown.num_of_tear_downs = 0
382 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results) 382 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results)
383 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 1) 383 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 1)
384 384
385 TestSharedStateForTearDown.num_of_tear_downs = 0 385 TestSharedStateForTearDown.num_of_tear_downs = 0
386 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results, 386 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results,
387 should_tear_down_state_after_each_story_run=True) 387 tear_down_after_story=True)
388 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 3) 388 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 3)
389 389
390 self.options.pageset_repeat = 5
391 TestSharedStateForTearDown.num_of_tear_downs = 0
392 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results,
393 tear_down_after_story_set=True)
394 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 5)
395
390 def testTearDownIsCalledOnceForEachStoryGroupWithPageSetRepeat(self): 396 def testTearDownIsCalledOnceForEachStoryGroupWithPageSetRepeat(self):
391 self.options.pageset_repeat = 3 397 self.options.pageset_repeat = 3
392 fooz_init_call_counter = [0] 398 fooz_init_call_counter = [0]
393 fooz_tear_down_call_counter = [0] 399 fooz_tear_down_call_counter = [0]
394 barz_init_call_counter = [0] 400 barz_init_call_counter = [0]
395 barz_tear_down_call_counter = [0] 401 barz_tear_down_call_counter = [0]
396 class FoozStoryState(FooStoryState): 402 class FoozStoryState(FooStoryState):
397 def __init__(self, test, options, storyz): 403 def __init__(self, test, options, storyz):
398 super(FoozStoryState, self).__init__( 404 super(FoozStoryState, self).__init__(
399 test, options, storyz) 405 test, options, storyz)
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 mock.call.test.WillRunStory(root_mock.state.platform), 988 mock.call.test.WillRunStory(root_mock.state.platform),
983 mock.call.state.WillRunStory(root_mock.story), 989 mock.call.state.WillRunStory(root_mock.story),
984 mock.call.state.CanRunStory(root_mock.story), 990 mock.call.state.CanRunStory(root_mock.story),
985 mock.call.state.RunStory(root_mock.results), 991 mock.call.state.RunStory(root_mock.results),
986 mock.call.test.Measure(root_mock.state.platform, root_mock.results), 992 mock.call.test.Measure(root_mock.state.platform, root_mock.results),
987 mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results), 993 mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results),
988 mock.call.results.AddValue(FailureValueMatcher('foo')), 994 mock.call.results.AddValue(FailureValueMatcher('foo')),
989 mock.call.state.DidRunStory(root_mock.results), 995 mock.call.state.DidRunStory(root_mock.results),
990 mock.call.test.DidRunStory(root_mock.state.platform) 996 mock.call.test.DidRunStory(root_mock.state.platform)
991 ]) 997 ])
OLDNEW
« no previous file with comments | « telemetry/telemetry/internal/story_runner.py ('k') | telemetry/telemetry/internal/util/webpagereplay.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698