Index: tools/perf/measurements/tab_switching_unittest.py |
diff --git a/tools/perf/measurements/tab_switching_unittest.py b/tools/perf/measurements/tab_switching_unittest.py |
index d16fcc4e36d00fe37ee4cbb7ea1cb6881df0b04c..79efbb116d3ace14849a694b87153d47a8cfc774 100644 |
--- a/tools/perf/measurements/tab_switching_unittest.py |
+++ b/tools/perf/measurements/tab_switching_unittest.py |
@@ -3,15 +3,12 @@ |
# found in the LICENSE file. |
import contextlib |
-from measurements import tab_switching |
-import mock |
-from page_sets.system_health import multi_tab_stories |
-from telemetry import benchmark |
-from telemetry import story as story_module |
from telemetry.internal.results import page_test_results |
from telemetry.testing import page_test_test_case |
-from telemetry.testing import options_for_unittests |
-from telemetry.value import histogram |
+ |
+from measurements import tab_switching |
+ |
+import mock |
class BrowserForTest(object): |
@@ -33,12 +30,6 @@ |
story.story_set = self |
self.stories.append(story) |
-INTEGRATION_TEST_TAB_COUNT = 3 |
- |
-class EmptyMultiTabStory(multi_tab_stories.MultiTabStory): |
- NAME = 'multitab:test:empty' |
- URL_LIST = ['about:blank'] * INTEGRATION_TEST_TAB_COUNT |
- URL = URL_LIST[0] |
class TabSwitchingUnittest(page_test_test_case.PageTestTestCase): |
@staticmethod |
@@ -72,9 +63,22 @@ |
# Mock histogram result to test _IsDone really works. |
expected_histogram = [ |
- # DidNavigateToPage() calls GetHistogram() once |
+ # To get first_histogram for last tab (tab_1). |
'{"count": 0, "buckets": []}', |
- # ValidateAndMeasurePage() calls GetHistogram() once |
+ # First _IsDone check for tab_0. Retry. |
+ '{"count": 0, "buckets": []}', |
+ # Second _IsDone check for tab_0. Retry. |
+ '{"count": 0, "buckets": []}', |
+ # Third _IsDone check for tab_0. Pass. |
+ '{"count": 1, "buckets": [{"low": 1, "high": 2, "count": 1}]}', |
+ # To get prev_histogram. End of tab_0 loop. |
+ '{"count": 1, "buckets": [{"low": 1, "high": 2, "count": 1}]}', |
+ # First _IsDone check for tab_1. Retry. |
+ '{"count": 1, "buckets": [{"low": 1, "high": 2, "count": 1}]}', |
+ # Second _IsDone check for tab_1. Pass. |
+ '{"count": 2, "buckets": [{"low": 1, "high": 2, "count": 1},' |
+ '{"low": 2, "high": 3, "count": 1}]}', |
+ # To get prev_histogram. End of tab_1 loop. |
'{"count": 2, "buckets": [{"low": 1, "high": 2, "count": 1},' |
'{"low": 2, "high": 3, "count": 1}]}', |
] |
@@ -84,34 +88,10 @@ |
mock.patch('telemetry.value.histogram_util.GetHistogram', |
mock_get_histogram), |
mock.patch('metrics.keychain_metric.KeychainMetric')): |
- measure.DidNavigateToPage(story_set.stories[0], browser.tabs[-1]) |
measure.ValidateAndMeasurePage(story_set.stories[0], browser.tabs[-1], |
page_test_results.PageTestResults()) |
self.assertEqual(len(expected_histogram), |
len(mock_get_histogram.mock_calls)) |
- # The last tab is passed to DidNavigateToPage() and |
- # ValidateAndMeasurePage() |
expected_calls = [mock.call(mock.ANY, mock.ANY, t) for t in |
- [browser.tabs[-1]] * 2] |
+ [tab_1] + [tab_0] * 4 + [tab_1] * 3] |
self.assertEqual(expected_calls, mock_get_histogram.mock_calls) |
- |
- @benchmark.Enabled('has tabs') |
- @benchmark.Disabled('mac-reference') |
- @benchmark.Disabled('android') |
- def testTabSwitching(self): |
- """IT of TabSwitching measurement and multi-tab story""" |
- ps = story_module.StorySet() |
- ps.AddStory(EmptyMultiTabStory(ps, False)) |
- measurement = tab_switching.TabSwitching() |
- options = options_for_unittests.GetCopy() |
- results = self.RunMeasurement(measurement, ps, options=options) |
- self.assertEquals(len(results.failures), 0) |
- |
- self.assertEquals(len(results.all_summary_values), 1) |
- summary = results.all_summary_values[0] |
- self.assertIsInstance(summary, histogram.HistogramValue) |
- self.assertEquals(summary.name, 'MPArch_RWH_TabSwitchPaintDuration') |
- histogram_count = sum([b.count for b in summary.buckets]) |
- self.assertEquals(histogram_count, INTEGRATION_TEST_TAB_COUNT) |
- histogram_mean = summary.GetRepresentativeNumber() |
- self.assertGreater(histogram_mean, 0) |