diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/test/gpu/gpu_tests/gpu_test_base.py | 3 | ||||
-rw-r--r-- | content/test/gpu/gpu_tests/gpu_test_base_unittest.py | 28 |
2 files changed, 30 insertions, 1 deletions
diff --git a/content/test/gpu/gpu_tests/gpu_test_base.py b/content/test/gpu/gpu_tests/gpu_test_base.py index e956707..1fa74dc 100644 --- a/content/test/gpu/gpu_tests/gpu_test_base.py +++ b/content/test/gpu/gpu_tests/gpu_test_base.py @@ -200,6 +200,9 @@ class PageBase(page_module.Page): url=url, page_set=page_set, base_dir=base_dir, name=name, shared_page_state_class=shared_page_state_class, make_javascript_deterministic=make_javascript_deterministic) + # Disable automatic garbage collection to reduce the test's cycle time. + self._collect_garbage_before_run = False + # TODO(kbr): this is fragile -- if someone changes the # shared_page_state_class to something that doesn't handle skip # expectations, then they'll hit the exception in diff --git a/content/test/gpu/gpu_tests/gpu_test_base_unittest.py b/content/test/gpu/gpu_tests/gpu_test_base_unittest.py index 5fb39e2..ae81623 100644 --- a/content/test/gpu/gpu_tests/gpu_test_base_unittest.py +++ b/content/test/gpu/gpu_tests/gpu_test_base_unittest.py @@ -11,7 +11,6 @@ from telemetry.core import util from telemetry.story import story_set as story_set_module from telemetry.testing import fakes -util.AddDirToPythonPath(util.GetTelemetryDir(), 'third_party', 'mock') import mock # pylint: disable=import-error import gpu_test_base @@ -161,6 +160,18 @@ class PageWhichFailsNTimes(FakePage): self._times_to_fail = self._times_to_fail - 1 raise Exception('Deliberate exception') +class PageRunExecutionTest(unittest.TestCase): + def testNoGarbageCollectionCalls(self): + mock_shared_state = mock.Mock() + p = gpu_test_base.PageBase('file://foo.html') + p.Run(mock_shared_state) + expected = [mock.call.page_test.WillNavigateToPage( + p, mock_shared_state.current_tab), + mock.call.page_test.RunNavigateSteps( + p, mock_shared_state.current_tab), + mock.call.page_test.DidNavigateToPage( + p, mock_shared_state.current_tab)] + self.assertEquals(mock_shared_state.mock_calls, expected) class PageExecutionTest(unittest.TestCase): def setupTest(self, manager_mock=None): @@ -181,6 +192,21 @@ class PageExecutionTest(unittest.TestCase): test = testclass(manager_mock=manager_mock) return test, finder_options + # Test page.Run() method is called by telemetry framework before + # ValidateAndMeasurePageInner. + def testPageRunMethodIsCalledBeforeValidateAndMeasurePage(self): + manager = mock.Mock() + test, finder_options = self.setupTest(manager) + page = FakePage(test, 'page1') + page.Run = manager.Run + test.AddFakePage(page) + self.assertEqual(test.Run(finder_options), 0, + 'Test should run with no errors') + expected = [mock.call.Run(mock.ANY), + mock.call.validator.ValidateAndMeasurePageInner( + page, mock.ANY, mock.ANY)] + self.assertEquals(manager.mock_calls, expected) + def testPassingPage(self): manager = mock.Mock() test, finder_options = self.setupTest(manager_mock=manager) |