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 def __init__(self, test, finder_options, story_set): |
| 13 super(BrowserStartupSharedState, self).__init__( |
| 14 test, finder_options, story_set) |
| 15 |
| 16 def DidRunStory(self, results): |
| 17 super(BrowserStartupSharedState, self).DidRunStory(results) |
| 18 self._StopBrowser() |
| 19 |
| 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 avoid reloading 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 """Pages for testing starting Chrome with a URL. |
| 78 |
| 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 def __init__(self): |
| 84 super(StartupPagesPageSetTBM, self).__init__( |
| 85 archive_data_file='data/startup_pages.json', |
| 86 cloud_storage_bucket=story.PARTNER_BUCKET) |
| 87 |
| 88 # Typical page. |
| 89 self.AddStory(StartedPageTBM('about:blank', self)) |
| 90 # Typical page. |
| 91 self.AddStory(StartedPageTBM('http://bbc.co.uk', self)) |
| 92 # Horribly complex page - stress test! |
| 93 self.AddStory(StartedPageTBM('http://kapook.com', self)) |
OLD | NEW |