OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """The tab switching measurement. | 5 """The tab switching measurement. |
6 | 6 |
7 This measurement opens pages in different tabs. After all the tabs have opened, | 7 This measurement opens pages in different tabs. After all the tabs have opened, |
8 it cycles through each tab in sequence, and records a histogram of the time | 8 it cycles through each tab in sequence, and records a histogram of the time |
9 between when a tab was first requested to be shown, and when it was painted. | 9 between when a tab was first requested to be shown, and when it was painted. |
10 """ | 10 """ |
11 | 11 |
12 from metrics import histogram_util | 12 from metrics import histogram_util |
13 from telemetry.core import util | 13 from telemetry.core import util |
14 from telemetry.page import page_measurement | 14 from telemetry.page import page_measurement |
15 from telemetry.page import page_runner | 15 from telemetry.page import page_runner |
16 | 16 |
17 # TODO: Revisit this test once multitab support is finalized. | 17 # TODO: Revisit this test once multitab support is finalized. |
18 | 18 |
19 class TabSwitching(page_measurement.PageMeasurement): | 19 class TabSwitching(page_measurement.PageMeasurement): |
20 def CustomizeBrowserOptions(self, options): | 20 def CustomizeBrowserOptions(self, options): |
21 options.AppendExtraBrowserArg('--enable-stats-collection-bindings') | 21 options.AppendExtraBrowserArgs([ |
22 options.AppendExtraBrowserArg('--dom-automation') | 22 '--enable-stats-collection-bindings', |
23 options.AppendExtraBrowserArg('--reduce-security-for-dom-automation-tests') | 23 '--dom-automation', |
| 24 '--reduce-security-for-dom-automation-tests' |
| 25 ]) |
24 | 26 |
25 def CanRunForPage(self, page): | 27 def CanRunForPage(self, page): |
26 return not page.page_set.pages.index(page) | 28 return not page.page_set.pages.index(page) |
27 | 29 |
28 def DidNavigateToPage(self, page, tab): | 30 def DidNavigateToPage(self, page, tab): |
29 for i in xrange(1, len(page.page_set.pages)): | 31 for i in xrange(1, len(page.page_set.pages)): |
30 t = tab.browser.tabs.New() | 32 t = tab.browser.tabs.New() |
31 | 33 |
32 page_state = page_runner.PageState() | 34 page_state = page_runner.PageState() |
33 page_state.PreparePage(page.page_set.pages[i], t) | 35 page_state.PreparePage(page.page_set.pages[i], t) |
(...skipping 23 matching lines...) Expand all Loading... |
57 prev_histogram = histogram_util.GetHistogramFromDomAutomation( | 59 prev_histogram = histogram_util.GetHistogramFromDomAutomation( |
58 histogram_type, histogram_name, tab) | 60 histogram_type, histogram_name, tab) |
59 | 61 |
60 last_histogram = histogram_util.GetHistogramFromDomAutomation( | 62 last_histogram = histogram_util.GetHistogramFromDomAutomation( |
61 histogram_type, histogram_name, tab) | 63 histogram_type, histogram_name, tab) |
62 diff_histogram = histogram_util.SubtractHistogram(last_histogram, | 64 diff_histogram = histogram_util.SubtractHistogram(last_histogram, |
63 first_histogram) | 65 first_histogram) |
64 | 66 |
65 results.AddSummary(histogram_name, '', diff_histogram, | 67 results.AddSummary(histogram_name, '', diff_histogram, |
66 data_type='unimportant-histogram') | 68 data_type='unimportant-histogram') |
OLD | NEW |