| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 | 4 |
| 5 import utils | 5 import utils |
| 6 | 6 |
| 7 from telemetry import page | 7 from telemetry import page |
| 8 from telemetry import story | 8 from telemetry import story |
| 9 from benchmarks.pagesets import media_router_page | 9 from benchmarks.pagesets import media_router_page |
| 10 from telemetry.core import exceptions | 10 from telemetry.core import exceptions |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 def __init__(self, page_set): | 55 def __init__(self, page_set): |
| 56 super(CastIdlePage, self).__init__( | 56 super(CastIdlePage, self).__init__( |
| 57 page_set=page_set, | 57 page_set=page_set, |
| 58 url='file://basic_test.html', | 58 url='file://basic_test.html', |
| 59 shared_page_state_class=SharedState) | 59 shared_page_state_class=SharedState) |
| 60 | 60 |
| 61 def RunPageInteractions(self, action_runner): | 61 def RunPageInteractions(self, action_runner): |
| 62 # Wait for 5s after Chrome is opened in order to get consistent results. | 62 # Wait for 5s after Chrome is opened in order to get consistent results. |
| 63 action_runner.Wait(5) | 63 action_runner.Wait(5) |
| 64 with action_runner.CreateInteraction('Idle'): | 64 with action_runner.CreateInteraction('Idle'): |
| 65 action_runner.ExecuteJavaScript2('collectPerfData();') | 65 action_runner.ExecuteJavaScript('collectPerfData();') |
| 66 action_runner.Wait(SESSION_TIME) | 66 action_runner.Wait(SESSION_TIME) |
| 67 | 67 |
| 68 | 68 |
| 69 class CastFlingingPage(media_router_page.CastPage): | 69 class CastFlingingPage(media_router_page.CastPage): |
| 70 """Cast page to fling a video to Chromecast device.""" | 70 """Cast page to fling a video to Chromecast device.""" |
| 71 | 71 |
| 72 def __init__(self, page_set): | 72 def __init__(self, page_set): |
| 73 super(CastFlingingPage, self).__init__( | 73 super(CastFlingingPage, self).__init__( |
| 74 page_set=page_set, | 74 page_set=page_set, |
| 75 url='file://basic_test.html#flinging', | 75 url='file://basic_test.html#flinging', |
| 76 shared_page_state_class=SharedState) | 76 shared_page_state_class=SharedState) |
| 77 | 77 |
| 78 def RunPageInteractions(self, action_runner): | 78 def RunPageInteractions(self, action_runner): |
| 79 sink_name = self._GetDeviceName() | 79 sink_name = self._GetDeviceName() |
| 80 # Wait for 5s after Chrome is opened in order to get consistent results. | 80 # Wait for 5s after Chrome is opened in order to get consistent results. |
| 81 action_runner.Wait(5) | 81 action_runner.Wait(5) |
| 82 with action_runner.CreateInteraction('flinging'): | 82 with action_runner.CreateInteraction('flinging'): |
| 83 | 83 |
| 84 self._WaitForResult( | 84 self._WaitForResult( |
| 85 action_runner, | 85 action_runner, |
| 86 lambda: action_runner.EvaluateJavaScript2('initialized'), | 86 lambda: action_runner.EvaluateJavaScript('initialized'), |
| 87 'Failed to initialize', | 87 'Failed to initialize', |
| 88 timeout=30) | 88 timeout=30) |
| 89 self.CloseExistingRoute(action_runner, sink_name) | 89 self.CloseExistingRoute(action_runner, sink_name) |
| 90 | 90 |
| 91 # Start session | 91 # Start session |
| 92 action_runner.TapElement(selector='#start_session_button') | 92 action_runner.TapElement(selector='#start_session_button') |
| 93 self._WaitForResult( | 93 self._WaitForResult( |
| 94 action_runner, | 94 action_runner, |
| 95 lambda: len(action_runner.tab.browser.tabs) >= 2, | 95 lambda: len(action_runner.tab.browser.tabs) >= 2, |
| 96 'MR dialog never showed up.') | 96 'MR dialog never showed up.') |
| 97 | 97 |
| 98 for tab in action_runner.tab.browser.tabs: | 98 for tab in action_runner.tab.browser.tabs: |
| 99 # Choose sink | 99 # Choose sink |
| 100 if tab.url == 'chrome://media-router/': | 100 if tab.url == 'chrome://media-router/': |
| 101 self.WaitUntilDialogLoaded(action_runner, tab) | 101 self.WaitUntilDialogLoaded(action_runner, tab) |
| 102 self.ChooseSink(tab, sink_name) | 102 self.ChooseSink(tab, sink_name) |
| 103 | 103 |
| 104 self._WaitForResult( | 104 self._WaitForResult( |
| 105 action_runner, | 105 action_runner, |
| 106 lambda: action_runner.EvaluateJavaScript2('currentSession'), | 106 lambda: action_runner.EvaluateJavaScript('currentSession'), |
| 107 'Failed to start session', | 107 'Failed to start session', |
| 108 timeout=10) | 108 timeout=10) |
| 109 | 109 |
| 110 # Load Media | 110 # Load Media |
| 111 self.ExecuteAsyncJavaScript( | 111 self.ExecuteAsyncJavaScript( |
| 112 action_runner, | 112 action_runner, |
| 113 js_template.Render( | 113 js_template.Render( |
| 114 'loadMedia({{ url }});', url=utils.GetInternalVideoURL()), | 114 'loadMedia({{ url }});', url=utils.GetInternalVideoURL()), |
| 115 lambda: action_runner.EvaluateJavaScript2('currentMedia'), | 115 lambda: action_runner.EvaluateJavaScript('currentMedia'), |
| 116 'Failed to load media', | 116 'Failed to load media', |
| 117 timeout=120) | 117 timeout=120) |
| 118 | 118 |
| 119 action_runner.Wait(5) | 119 action_runner.Wait(5) |
| 120 action_runner.ExecuteJavaScript2('collectPerfData();') | 120 action_runner.ExecuteJavaScript('collectPerfData();') |
| 121 action_runner.Wait(SESSION_TIME) | 121 action_runner.Wait(SESSION_TIME) |
| 122 # Stop session | 122 # Stop session |
| 123 self.ExecuteAsyncJavaScript( | 123 self.ExecuteAsyncJavaScript( |
| 124 action_runner, | 124 action_runner, |
| 125 'stopSession();', | 125 'stopSession();', |
| 126 lambda: not action_runner.EvaluateJavaScript2('currentSession'), | 126 lambda: not action_runner.EvaluateJavaScript('currentSession'), |
| 127 'Failed to stop session', | 127 'Failed to stop session', |
| 128 timeout=30) | 128 timeout=30) |
| 129 | 129 |
| 130 | 130 |
| 131 class CastMirroringPage(media_router_page.CastPage): | 131 class CastMirroringPage(media_router_page.CastPage): |
| 132 """Cast page to mirror a tab to Chromecast device.""" | 132 """Cast page to mirror a tab to Chromecast device.""" |
| 133 | 133 |
| 134 def __init__(self, page_set): | 134 def __init__(self, page_set): |
| 135 super(CastMirroringPage, self).__init__( | 135 super(CastMirroringPage, self).__init__( |
| 136 page_set=page_set, | 136 page_set=page_set, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 163 self._WaitForResult( | 163 self._WaitForResult( |
| 164 action_runner, | 164 action_runner, |
| 165 lambda: len(action_runner.tab.browser.tabs) >= 2, | 165 lambda: len(action_runner.tab.browser.tabs) >= 2, |
| 166 'MR dialog never showed up.') | 166 'MR dialog never showed up.') |
| 167 | 167 |
| 168 for tab in action_runner.tab.browser.tabs: | 168 for tab in action_runner.tab.browser.tabs: |
| 169 if tab.url == 'chrome://media-router/': | 169 if tab.url == 'chrome://media-router/': |
| 170 self.WaitUntilDialogLoaded(action_runner, tab) | 170 self.WaitUntilDialogLoaded(action_runner, tab) |
| 171 if not self.CheckIfExistingRoute(tab, sink_name): | 171 if not self.CheckIfExistingRoute(tab, sink_name): |
| 172 raise page.page_test.Failure('Failed to start mirroring session.') | 172 raise page.page_test.Failure('Failed to start mirroring session.') |
| 173 action_runner.ExecuteJavaScript2('collectPerfData();') | 173 action_runner.ExecuteJavaScript('collectPerfData();') |
| 174 action_runner.Wait(SESSION_TIME) | 174 action_runner.Wait(SESSION_TIME) |
| 175 self.CloseExistingRoute(action_runner, sink_name) | 175 self.CloseExistingRoute(action_runner, sink_name) |
| 176 | 176 |
| 177 | 177 |
| 178 class MediaRouterDialogPageSet(story.StorySet): | 178 class MediaRouterDialogPageSet(story.StorySet): |
| 179 """Pageset for media router dialog latency tests.""" | 179 """Pageset for media router dialog latency tests.""" |
| 180 | 180 |
| 181 def __init__(self): | 181 def __init__(self): |
| 182 super(MediaRouterDialogPageSet, self).__init__( | 182 super(MediaRouterDialogPageSet, self).__init__( |
| 183 cloud_storage_bucket=story.PARTNER_BUCKET) | 183 cloud_storage_bucket=story.PARTNER_BUCKET) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 195 self.AddStory(CastMirroringPage(self)) | 195 self.AddStory(CastMirroringPage(self)) |
| 196 | 196 |
| 197 | 197 |
| 198 class CPUMemoryPageSet(story.StorySet): | 198 class CPUMemoryPageSet(story.StorySet): |
| 199 """Pageset to get baseline CPU and memory usage.""" | 199 """Pageset to get baseline CPU and memory usage.""" |
| 200 | 200 |
| 201 def __init__(self): | 201 def __init__(self): |
| 202 super(CPUMemoryPageSet, self).__init__( | 202 super(CPUMemoryPageSet, self).__init__( |
| 203 cloud_storage_bucket=story.PARTNER_BUCKET) | 203 cloud_storage_bucket=story.PARTNER_BUCKET) |
| 204 self.AddStory(CastIdlePage(self)) | 204 self.AddStory(CastIdlePage(self)) |
| OLD | NEW |