Chromium Code Reviews| 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 """ | |
| 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 | |
| 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 # It is still not clear why we would need to wait 10s here. It has been | |
|
eakuefner
2015/11/17 16:51:52
Put this text in the bug and replace this comment
gabadie
2015/11/17 18:14:23
Done.
| |
| 70 # here since the begining (bf5c7d375e881e8d7fa8b7e36f8b87587751ae84). Its | |
| 71 # purpose was to make sure the low priority task in charge of outputing the | |
| 72 # the histogram values we were interested in, was executed before stoping | |
| 73 # the browser. We might be able to get ride of it (crbug.com/555504). | |
| 74 action_runner.Wait(10) | |
| 75 | |
| 76 def RunPageInteractions(self, action_runner): | |
| 77 self.RunNavigateSteps(action_runner) | |
| 78 | |
| 79 | |
| 80 class StartupPagesPageSetTBM(story.StorySet): | |
|
eakuefner
2015/11/17 16:51:52
Seems like you need to record this page set using
eakuefner
2015/11/17 17:54:02
Whoops, since you're pointing to an archive_data_f
| |
| 81 | |
| 82 """ Pages for testing starting Chrome with a URL. | |
| 83 Note that this file can't be used with record_wpr, since record_wpr requires | |
| 84 a true navigate step, which we do not want for startup testing. Instead use | |
| 85 record_wpr startup_pages_record to record data for this test. | |
| 86 """ | |
| 87 | |
| 88 def __init__(self): | |
| 89 super(StartupPagesPageSetTBM, self).__init__( | |
| 90 archive_data_file='data/startup_pages.json', | |
| 91 cloud_storage_bucket=story.PARTNER_BUCKET) | |
| 92 | |
| 93 # Typical page. | |
| 94 self.AddStory(StartedPageTBM('about:blank', self)) | |
| 95 # Typical page. | |
| 96 self.AddStory(StartedPageTBM('http://bbc.co.uk', self)) | |
| 97 # Horribly complex page - stress test! | |
| 98 self.AddStory(StartedPageTBM('http://kapook.com', self)) | |
| OLD | NEW |