Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / tools / perf / profile_creators / small_profile_creator.py
blob46109a7a4f341a536c73cb5e47498f07a2c37085
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.
5 from telemetry.page import profile_creator
7 import logging
8 import page_sets
10 from telemetry import benchmark
11 from telemetry.page import page_test
12 from telemetry.page import test_expectations
13 from telemetry.results import results_options
14 from telemetry.user_story import user_story_runner
17 class SmallProfileCreator(profile_creator.ProfileCreator):
18 """
19 Runs a browser through a series of operations to fill in a small test profile.
21 This consists of performing a single navigation to each of the top 25 pages.
22 """
23 class PageTest(page_test.PageTest):
24 def __init__(self):
25 super(SmallProfileCreator.PageTest, self).__init__()
26 self._page_set = page_sets.Typical25PageSet()
28 # Open all links in the same tab save for the last _NUM_TABS links which
29 # are each opened in a new tab.
30 self._NUM_TABS = 5
32 def TabForPage(self, page, browser):
33 """Superclass override."""
34 idx = page.page_set.pages.index(page)
35 # The last _NUM_TABS pages open a new tab.
36 if idx <= (len(page.page_set.pages) - self._NUM_TABS):
37 return browser.tabs[0]
38 else:
39 return browser.tabs.New()
41 def ValidateAndMeasurePage(self, page, tab, results):
42 """Superclass override."""
43 tab.WaitForDocumentReadyStateToBeComplete()
45 def __init__(self):
46 super(SmallProfileCreator, self).__init__()
47 self._page_test = SmallProfileCreator.PageTest()
49 def Run(self, options):
50 expectations = test_expectations.TestExpectations()
51 results = results_options.CreateResults(
52 benchmark.BenchmarkMetadata(profile_creator.__class__.__name__),
53 options)
54 user_story_runner.Run(self._page_test, self._page_test._page_set,
55 expectations, options, results)
57 if results.failures:
58 logging.warning('Some pages failed to load.')
59 logging.warning('Failed pages:\n%s',
60 '\n'.join(map(str, results.pages_that_failed)))
61 raise Exception('SmallProfileCreator failed.')