| OLD | NEW |
| 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 StringIO | 6 import StringIO |
| 7 import sys | 7 import sys |
| 8 import unittest | 8 import unittest |
| 9 | 9 |
| 10 from catapult_base import cloud_storage # pylint: disable=import-error | 10 from catapult_base import cloud_storage # pylint: disable=import-error |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 355 |
| 356 test = TestStoryTest() | 356 test = TestStoryTest() |
| 357 story_set = story_module.StorySet() | 357 story_set = story_module.StorySet() |
| 358 story_set.AddStory(DummyLocalStory(TestSharedStateForStoryTest)) | 358 story_set.AddStory(DummyLocalStory(TestSharedStateForStoryTest)) |
| 359 story_runner.Run(test, story_set, self.options, self.results) | 359 story_runner.Run(test, story_set, self.options, self.results) |
| 360 return [call[0] for call in manager.mock_calls] | 360 return [call[0] for call in manager.mock_calls] |
| 361 | 361 |
| 362 calls_in_order = GetCallsInOrder() # pylint: disable=no-value-for-parameter | 362 calls_in_order = GetCallsInOrder() # pylint: disable=no-value-for-parameter |
| 363 self.assertEquals(EXPECTED_CALLS_IN_ORDER, calls_in_order) | 363 self.assertEquals(EXPECTED_CALLS_IN_ORDER, calls_in_order) |
| 364 | 364 |
| 365 def testTearDownStateAfterEachStoryRun(self): | 365 def testTearDownStateAfterEachStoryOrStorySetRun(self): |
| 366 class TestSharedStateForTearDown(TestSharedState): | 366 class TestSharedStateForTearDown(TestSharedState): |
| 367 num_of_tear_downs = 0 | 367 num_of_tear_downs = 0 |
| 368 | 368 |
| 369 def RunStory(self, results): | 369 def RunStory(self, results): |
| 370 pass | 370 pass |
| 371 | 371 |
| 372 def TearDownState(self): | 372 def TearDownState(self): |
| 373 TestSharedStateForTearDown.num_of_tear_downs += 1 | 373 TestSharedStateForTearDown.num_of_tear_downs += 1 |
| 374 | 374 |
| 375 story_set = story_module.StorySet() | 375 story_set = story_module.StorySet() |
| 376 story_set.AddStory(DummyLocalStory(TestSharedStateForTearDown)) | 376 story_set.AddStory(DummyLocalStory(TestSharedStateForTearDown)) |
| 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 | 379 |
| 380 TestSharedStateForTearDown.num_of_tear_downs = 0 | 380 TestSharedStateForTearDown.num_of_tear_downs = 0 |
| 381 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results) | 381 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results) |
| 382 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 1) | 382 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 1) |
| 383 | 383 |
| 384 TestSharedStateForTearDown.num_of_tear_downs = 0 | 384 TestSharedStateForTearDown.num_of_tear_downs = 0 |
| 385 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results, | 385 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results, |
| 386 should_tear_down_state_after_each_story_run=True) | 386 tear_down_after_story=True) |
| 387 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 3) | 387 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 3) |
| 388 | 388 |
| 389 self.options.pageset_repeat = 5 |
| 390 TestSharedStateForTearDown.num_of_tear_downs = 0 |
| 391 story_runner.Run(mock.MagicMock(), story_set, self.options, self.results, |
| 392 tear_down_after_story_set=True) |
| 393 self.assertEquals(TestSharedStateForTearDown.num_of_tear_downs, 5) |
| 394 |
| 389 def testTearDownIsCalledOnceForEachStoryGroupWithPageSetRepeat(self): | 395 def testTearDownIsCalledOnceForEachStoryGroupWithPageSetRepeat(self): |
| 390 self.options.pageset_repeat = 3 | 396 self.options.pageset_repeat = 3 |
| 391 fooz_init_call_counter = [0] | 397 fooz_init_call_counter = [0] |
| 392 fooz_tear_down_call_counter = [0] | 398 fooz_tear_down_call_counter = [0] |
| 393 barz_init_call_counter = [0] | 399 barz_init_call_counter = [0] |
| 394 barz_tear_down_call_counter = [0] | 400 barz_tear_down_call_counter = [0] |
| 395 class FoozStoryState(FooStoryState): | 401 class FoozStoryState(FooStoryState): |
| 396 def __init__(self, test, options, storyz): | 402 def __init__(self, test, options, storyz): |
| 397 super(FoozStoryState, self).__init__( | 403 super(FoozStoryState, self).__init__( |
| 398 test, options, storyz) | 404 test, options, storyz) |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 mock.call.test.WillRunStory(root_mock.state.platform), | 986 mock.call.test.WillRunStory(root_mock.state.platform), |
| 981 mock.call.state.WillRunStory(root_mock.story), | 987 mock.call.state.WillRunStory(root_mock.story), |
| 982 mock.call.state.CanRunStory(root_mock.story), | 988 mock.call.state.CanRunStory(root_mock.story), |
| 983 mock.call.state.RunStory(root_mock.results), | 989 mock.call.state.RunStory(root_mock.results), |
| 984 mock.call.test.Measure(root_mock.state.platform, root_mock.results), | 990 mock.call.test.Measure(root_mock.state.platform, root_mock.results), |
| 985 mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results), | 991 mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results), |
| 986 mock.call.results.AddValue(FailureValueMatcher('foo')), | 992 mock.call.results.AddValue(FailureValueMatcher('foo')), |
| 987 mock.call.state.DidRunStory(root_mock.results), | 993 mock.call.state.DidRunStory(root_mock.results), |
| 988 mock.call.test.DidRunStory(root_mock.state.platform) | 994 mock.call.test.DidRunStory(root_mock.state.platform) |
| 989 ]) | 995 ]) |
| OLD | NEW |