OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
5 from telemetry.page import shared_page_state | |
5 from telemetry import story | 6 from telemetry import story |
6 | 7 |
7 | 8 |
9 class BrowserStartupSharedState(shared_page_state.SharedPageState): | |
10 """Shared state that restarts the browser for every single story. | |
11 """ | |
eakuefner
2015/11/18 18:39:53
nit: looks like this can fit on the previous line
gabadie
2015/11/18 19:16:31
Done.
| |
12 | |
13 def __init__(self, test, finder_options, story_set): | |
14 super(BrowserStartupSharedState, self).__init__( | |
15 test, finder_options, story_set) | |
16 | |
17 def DidRunStory(self, results): | |
18 super(BrowserStartupSharedState, self).DidRunStory(results) | |
19 self._StopBrowser() | |
20 | |
eakuefner
2015/11/18 18:39:53
nit: two lines between top-level definitions
gabadie
2015/11/18 19:16:31
Done.
| |
8 class StartedPage(page_module.Page): | 21 class StartedPage(page_module.Page): |
9 | 22 |
10 def __init__(self, url, startup_url, page_set): | 23 def __init__(self, url, startup_url, page_set): |
11 super(StartedPage, self).__init__( | 24 super(StartedPage, self).__init__( |
12 url=url, page_set=page_set, startup_url=startup_url) | 25 url=url, page_set=page_set, startup_url=startup_url) |
13 self.archive_data_file = 'data/startup_pages.json' | 26 self.archive_data_file = 'data/startup_pages.json' |
14 | 27 |
15 def RunNavigateSteps(self, action_runner): | 28 def RunNavigateSteps(self, action_runner): |
16 action_runner.Wait(10) | 29 action_runner.Wait(10) |
17 | 30 |
(...skipping 14 matching lines...) Expand all Loading... | |
32 archive_data_file='data/startup_pages.json', | 45 archive_data_file='data/startup_pages.json', |
33 cloud_storage_bucket=story.PARTNER_BUCKET) | 46 cloud_storage_bucket=story.PARTNER_BUCKET) |
34 | 47 |
35 # Typical page. | 48 # Typical page. |
36 self.AddStory(StartedPage('about:blank', 'about:blank', self)) | 49 self.AddStory(StartedPage('about:blank', 'about:blank', self)) |
37 # Typical page. | 50 # Typical page. |
38 self.AddStory(StartedPage('http://bbc.co.uk', 'http://bbc.co.uk', self)) | 51 self.AddStory(StartedPage('http://bbc.co.uk', 'http://bbc.co.uk', self)) |
39 # Horribly complex page - stress test! | 52 # Horribly complex page - stress test! |
40 self.AddStory(StartedPage( | 53 self.AddStory(StartedPage( |
41 'http://kapook.com', 'http://kapook.com', self)) | 54 'http://kapook.com', 'http://kapook.com', self)) |
55 | |
56 | |
57 class StartedPageTBM(page_module.Page): | |
58 | |
59 def __init__(self, url, page_set): | |
60 super(StartedPageTBM, self).__init__( | |
61 url=url, page_set=page_set, startup_url=url, | |
62 shared_page_state_class=BrowserStartupSharedState) | |
63 self.archive_data_file = 'data/startup_pages.json' | |
64 | |
65 def RunNavigateSteps(self, action_runner): | |
66 # Do not call super.RunNavigateSteps() to not reload the page that has | |
67 # already been opened with startup_url. | |
68 | |
69 # TODO(gabadie): Get rid of this (crbug.com/555504) | |
70 action_runner.Wait(10) | |
71 | |
72 def RunPageInteractions(self, action_runner): | |
73 self.RunNavigateSteps(action_runner) | |
74 | |
75 | |
76 class StartupPagesPageSetTBM(story.StorySet): | |
77 | |
78 """ Pages for testing starting Chrome with a URL. | |
eakuefner
2015/11/18 18:39:53
nit: no space between """ and Pages. Newline after
gabadie
2015/11/18 19:16:31
Done.
| |
79 Note that this file can't be used with record_wpr, since record_wpr requires | |
80 a true navigate step, which we do not want for startup testing. Instead use | |
81 record_wpr startup_pages_record to record data for this test. | |
82 """ | |
83 | |
84 def __init__(self): | |
85 super(StartupPagesPageSetTBM, self).__init__( | |
86 archive_data_file='data/startup_pages.json', | |
87 cloud_storage_bucket=story.PARTNER_BUCKET) | |
88 | |
89 # Typical page. | |
90 self.AddStory(StartedPageTBM('about:blank', self)) | |
91 # Typical page. | |
92 self.AddStory(StartedPageTBM('http://bbc.co.uk', self)) | |
93 # Horribly complex page - stress test! | |
94 self.AddStory(StartedPageTBM('http://kapook.com', self)) | |
OLD | NEW |