d8bb4532be2c418d257c365283e6d786d340b4b0
[platform/framework/web/crosswalk.git] / src / tools / perf / profile_creators / small_profile_creator.py
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
3 # found in the LICENSE file.
4
5 from telemetry.page import profile_creator
6
7 import page_sets
8
9
10 class SmallProfileCreator(profile_creator.ProfileCreator):
11   """
12   Runs a browser through a series of operations to fill in a small test profile.
13   """
14
15   def __init__(self):
16     super(SmallProfileCreator, self).__init__()
17     self._page_set = page_sets.Typical25PageSet()
18
19     # Open all links in the same tab save for the last _NUM_TABS links which
20     # are each opened in a new tab.
21     self._NUM_TABS = 5
22
23   def TabForPage(self, page, browser):
24     idx = page.page_set.pages.index(page)
25     # The last _NUM_TABS pages open a new tab.
26     if idx <= (len(page.page_set.pages) - self._NUM_TABS):
27       return browser.tabs[0]
28     else:
29       return browser.tabs.New()
30
31   def ValidateAndMeasurePage(self, _, tab, results):
32     tab.WaitForDocumentReadyStateToBeComplete()