| 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.page import shared_page_state |
| 6 from telemetry import story | 6 from telemetry import story |
| 7 | 7 |
| 8 | 8 |
| 9 class BrowserStartupSharedState(shared_page_state.SharedPageState): | 9 class BrowserStartupSharedState(shared_page_state.SharedPageState): |
| 10 """Shared state that restarts the browser for every single story.""" | 10 """Shared state that restarts the browser for every single story.""" |
| 11 | 11 |
| 12 def __init__(self, test, finder_options, story_set): | 12 def __init__(self, test, finder_options, story_set): |
| 13 super(BrowserStartupSharedState, self).__init__( | 13 super(BrowserStartupSharedState, self).__init__( |
| 14 test, finder_options, story_set) | 14 test, finder_options, story_set) |
| 15 | 15 |
| 16 def DidRunStory(self, results): | 16 def DidRunStory(self, results): |
| 17 super(BrowserStartupSharedState, self).DidRunStory(results) | 17 super(BrowserStartupSharedState, self).DidRunStory(results) |
| 18 self._StopBrowser() | 18 self._StopBrowser() |
| 19 | 19 |
| 20 | 20 |
| 21 class StartedPage(page_module.Page): | 21 class StartedPage(page_module.Page): |
| 22 | 22 |
| 23 def __init__(self, url, page_set): | 23 def __init__(self, url, page_set): |
| 24 super(StartedPage, self).__init__( | 24 super(StartedPage, self).__init__( |
| 25 url=url, page_set=page_set, startup_url=url, | 25 url=url, page_set=page_set, startup_url=url, |
| 26 shared_page_state_class=BrowserStartupSharedState) | 26 shared_page_state_class=BrowserStartupSharedState, |
| 27 name=url) |
| 27 self.archive_data_file = 'data/startup_pages.json' | 28 self.archive_data_file = 'data/startup_pages.json' |
| 28 | 29 |
| 29 def RunNavigateSteps(self, action_runner): | 30 def RunNavigateSteps(self, action_runner): |
| 30 # Do not call super.RunNavigateSteps() to avoid reloading the page that has | 31 # Do not call super.RunNavigateSteps() to avoid reloading the page that has |
| 31 # already been opened with startup_url. | 32 # already been opened with startup_url. |
| 32 | 33 |
| 33 # TODO(gabadie): Get rid of this (crbug.com/555504) | 34 # TODO(gabadie): Get rid of this (crbug.com/555504) |
| 34 action_runner.Wait(10) | 35 action_runner.Wait(10) |
| 35 | 36 |
| 36 def RunPageInteractions(self, action_runner): | 37 def RunPageInteractions(self, action_runner): |
| 37 self.RunNavigateSteps(action_runner) | 38 self.RunNavigateSteps(action_runner) |
| 38 | 39 |
| 39 | 40 |
| 40 class StartupPagesPageSet(story.StorySet): | 41 class StartupPagesPageSet(story.StorySet): |
| 41 """Pages for testing starting Chrome with a URL. | 42 """Pages for testing starting Chrome with a URL. |
| 42 | 43 |
| 43 Note that this file can't be used with record_wpr, since record_wpr requires | 44 Note that this file can't be used with record_wpr, since record_wpr requires |
| 44 a true navigate step, which we do not want for startup testing. Instead use | 45 a true navigate step, which we do not want for startup testing. Instead use |
| 45 record_wpr startup_pages_record to record data for this test.""" | 46 record_wpr startup_pages_record to record data for this test.""" |
| 46 | 47 |
| 47 def __init__(self): | 48 def __init__(self): |
| 48 super(StartupPagesPageSet, self).__init__( | 49 super(StartupPagesPageSet, self).__init__( |
| 49 archive_data_file='data/startup_pages.json', | 50 archive_data_file='data/startup_pages.json', |
| 50 cloud_storage_bucket=story.PARTNER_BUCKET) | 51 cloud_storage_bucket=story.PARTNER_BUCKET, |
| 52 verify_names=True) |
| 51 | 53 |
| 52 # Typical page. | 54 # Typical page. |
| 53 self.AddStory(StartedPage('about:blank', self)) | 55 self.AddStory(StartedPage('about:blank', self)) |
| 54 # Typical page. | 56 # Typical page. |
| 55 self.AddStory(StartedPage('http://bbc.co.uk', self)) | 57 self.AddStory(StartedPage('http://bbc.co.uk', self)) |
| 56 # TODO(charliea): Reenable this when kabook.com is working again. | 58 # TODO(charliea): Reenable this when kabook.com is working again. |
| 57 # crbug.com/667470 | 59 # crbug.com/667470 |
| 58 # Horribly complex page - stress test! | 60 # Horribly complex page - stress test! |
| 59 # self.AddStory(StartedPage('http://kapook.com', self)) | 61 # self.AddStory(StartedPage('http://kapook.com', self)) |
| OLD | NEW |