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 import os | 5 from telemetry.page import profile_creator |
6 | 6 |
7 from telemetry.core import util | 7 import page_sets |
8 from telemetry.page import page_set | |
9 from telemetry.page import profile_creator | |
10 | 8 |
11 | 9 |
12 class SmallProfileCreator(profile_creator.ProfileCreator): | 10 class SmallProfileCreator(profile_creator.ProfileCreator): |
13 """ | 11 """ |
14 Runs a browser through a series of operations to fill in a small test profile. | 12 Runs a browser through a series of operations to fill in a small test profile. |
15 """ | 13 """ |
16 | 14 |
17 def __init__(self): | 15 def __init__(self): |
18 super(SmallProfileCreator, self).__init__() | 16 super(SmallProfileCreator, self).__init__() |
19 typical_25 = os.path.join(util.GetBaseDir(), 'page_sets', 'typical_25.py') | 17 self._page_set = page_sets.Typical25() |
20 self._page_set = page_set.PageSet.FromFile(typical_25) | |
21 | 18 |
22 # Open all links in the same tab save for the last _NUM_TABS links which | 19 # Open all links in the same tab save for the last _NUM_TABS links which |
23 # are each opened in a new tab. | 20 # are each opened in a new tab. |
24 self._NUM_TABS = 5 | 21 self._NUM_TABS = 5 |
25 | 22 |
26 def TabForPage(self, page, browser): | 23 def TabForPage(self, page, browser): |
27 idx = page.page_set.pages.index(page) | 24 idx = page.page_set.pages.index(page) |
28 # The last _NUM_TABS pages open a new tab. | 25 # The last _NUM_TABS pages open a new tab. |
29 if idx <= (len(page.page_set.pages) - self._NUM_TABS): | 26 if idx <= (len(page.page_set.pages) - self._NUM_TABS): |
30 return browser.tabs[0] | 27 return browser.tabs[0] |
31 else: | 28 else: |
32 return browser.tabs.New() | 29 return browser.tabs.New() |
33 | 30 |
34 def MeasurePage(self, _, tab, results): | 31 def MeasurePage(self, _, tab, results): |
35 tab.WaitForDocumentReadyStateToBeComplete() | 32 tab.WaitForDocumentReadyStateToBeComplete() |
OLD | NEW |