Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: chrome/test/media_router/telemetry/benchmarks/pagesets/media_router_perf_pages.py

Issue 1931553004: Stop the existing session if it exists before start a new session and add mirroring scenario for cp… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update media_router_perf_pages.py Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 from telemetry.page import shared_page_state 11 from telemetry.page import shared_page_state
12 12
13 SESSION_TIME = 300 # 5 minutes
13 14
14 class SharedState(shared_page_state.SharedPageState): 15 class SharedState(shared_page_state.SharedPageState):
15 """Shared state that restarts the browser for every single story.""" 16 """Shared state that restarts the browser for every single story."""
16 17
17 def __init__(self, test, finder_options, story_set): 18 def __init__(self, test, finder_options, story_set):
18 super(SharedState, self).__init__( 19 super(SharedState, self).__init__(
19 test, finder_options, story_set) 20 test, finder_options, story_set)
20 21
21 def DidRunStory(self, results): 22 def DidRunStory(self, results):
22 super(SharedState, self).DidRunStory(results) 23 super(SharedState, self).DidRunStory(results)
(...skipping 29 matching lines...) Expand all
52 super(CastIdlePage, self).__init__( 53 super(CastIdlePage, self).__init__(
53 page_set=page_set, 54 page_set=page_set,
54 url='file://basic_test.html', 55 url='file://basic_test.html',
55 shared_page_state_class=SharedState) 56 shared_page_state_class=SharedState)
56 57
57 def RunPageInteractions(self, action_runner): 58 def RunPageInteractions(self, action_runner):
58 # Wait for 5s after Chrome is opened in order to get consistent results. 59 # Wait for 5s after Chrome is opened in order to get consistent results.
59 action_runner.Wait(5) 60 action_runner.Wait(5)
60 with action_runner.CreateInteraction('Idle'): 61 with action_runner.CreateInteraction('Idle'):
61 action_runner.ExecuteJavaScript('collectPerfData();') 62 action_runner.ExecuteJavaScript('collectPerfData();')
62 action_runner.Wait(300) 63 action_runner.Wait(SESSION_TIME)
63 64
64 65
65 class CastFlingingPage(media_router_page.CastPage): 66 class CastFlingingPage(media_router_page.CastPage):
66 """Cast page to fling a video to Chromecast device.""" 67 """Cast page to fling a video to Chromecast device."""
67 68
68 def __init__(self, page_set): 69 def __init__(self, page_set):
69 super(CastFlingingPage, self).__init__( 70 super(CastFlingingPage, self).__init__(
70 page_set=page_set, 71 page_set=page_set,
71 url='file://basic_test.html#flinging', 72 url='file://basic_test.html#flinging',
72 shared_page_state_class=SharedState) 73 shared_page_state_class=SharedState)
73 74
74 def RunPageInteractions(self, action_runner): 75 def RunPageInteractions(self, action_runner):
75 # Wait for 5s after Chrome is opened in order to get consistent results. 76 sink_name = self._GetDeviceName()
77 # Wait for 5s after Chrome is opened in order to get consistent results.
76 action_runner.Wait(5) 78 action_runner.Wait(5)
77 with action_runner.CreateInteraction('flinging'): 79 with action_runner.CreateInteraction('flinging'):
80
78 self._WaitForResult( 81 self._WaitForResult(
79 action_runner, 82 action_runner,
80 lambda: action_runner.EvaluateJavaScript('initialized'), 83 lambda: action_runner.EvaluateJavaScript('initialized'),
81 'Failed to initialize') 84 'Failed to initialize',
85 timeout=30)
86 self.CloseExistingRoute(action_runner, sink_name)
82 87
83 # Start session 88 # Start session
84 action_runner.TapElement(selector='#start_session_button') 89 action_runner.TapElement(selector='#start_session_button')
85 self._WaitForResult( 90 self._WaitForResult(
86 action_runner, 91 action_runner,
87 lambda: len(action_runner.tab.browser.tabs) >= 2, 92 lambda: len(action_runner.tab.browser.tabs) >= 2,
88 'MR dialog never showed up.') 93 'MR dialog never showed up.')
89 94
90 # Wait for 2s to make sure the dialog is fully loaded. 95 # Wait for 2s to make sure the dialog is fully loaded.
91 action_runner.Wait(2) 96 action_runner.Wait(2)
92 for tab in action_runner.tab.browser.tabs: 97 for tab in action_runner.tab.browser.tabs:
93 # Choose sink 98 # Choose sink
94 if tab.url == 'chrome://media-router/': 99 if tab.url == 'chrome://media-router/':
95 self.ChooseSink(tab, self._GetDeviceName()) 100 self.ChooseSink(tab, sink_name)
96 101
97 self._WaitForResult( 102 self._WaitForResult(
98 action_runner, 103 action_runner,
99 lambda: action_runner.EvaluateJavaScript('currentSession'), 104 lambda: action_runner.EvaluateJavaScript('currentSession'),
100 'Failed to start session', 105 'Failed to start session',
101 timeout=10) 106 timeout=10)
102 107
103 # Load Media 108 # Load Media
104 self.ExecuteAsyncJavaScript( 109 self.ExecuteAsyncJavaScript(
105 action_runner, 110 action_runner,
106 'loadMedia("%s");' % utils.GetInternalVideoURL(), 111 'loadMedia("%s");' % utils.GetInternalVideoURL(),
107 lambda: action_runner.EvaluateJavaScript('currentMedia'), 112 lambda: action_runner.EvaluateJavaScript('currentMedia'),
108 'Failed to load media', 113 'Failed to load media',
109 timeout=120) 114 timeout=120)
110 115
111 action_runner.Wait(5) 116 action_runner.Wait(5)
112 action_runner.ExecuteJavaScript('collectPerfData();') 117 action_runner.ExecuteJavaScript('collectPerfData();')
113 action_runner.Wait(300) 118 action_runner.Wait(SESSION_TIME)
114 # Stop session 119 # Stop session
115 self.ExecuteAsyncJavaScript( 120 self.ExecuteAsyncJavaScript(
116 action_runner, 121 action_runner,
117 'stopSession();', 122 'stopSession();',
118 lambda: not action_runner.EvaluateJavaScript('currentSession'), 123 lambda: not action_runner.EvaluateJavaScript('currentSession'),
119 'Failed to stop session') 124 'Failed to stop session')
120 125
121 126
127 class CastMirroringPage(media_router_page.CastPage):
128 """Cast page to mirror a tab to Chromecast device."""
129
130 def __init__(self, page_set):
131 super(CastMirroringPage, self).__init__(
132 page_set=page_set,
133 url='file://mirroring.html',
134 shared_page_state_class=SharedState)
135
136 def RunPageInteractions(self, action_runner):
137 sink_name = self._GetDeviceName()
138 # Wait for 5s after Chrome is opened in order to get consistent results.
139 action_runner.Wait(5)
140 with action_runner.CreateInteraction('mirroring'):
141 self.CloseExistingRoute(action_runner, sink_name)
142
143 # Start session
144 action_runner.TapElement(selector='#start_session_button')
145 self._WaitForResult(
146 action_runner,
147 lambda: len(action_runner.tab.browser.tabs) >= 2,
148 'MR dialog never showed up.')
149
150 # Wait for 2s to make sure the dialog is fully loaded.
151 action_runner.Wait(2)
152 for tab in action_runner.tab.browser.tabs:
153 # Choose sink
154 if tab.url == 'chrome://media-router/':
155 self.ChooseSink(tab, sink_name)
156
157 # Wait for 5s to make sure the route is created.
158 action_runner.Wait(5)
159 action_runner.TapElement(selector='#start_session_button')
160 action_runner.Wait(2)
161 for tab in action_runner.tab.browser.tabs:
162 if tab.url == 'chrome://media-router/':
163 if not self.CheckIfExistingRoute(tab, sink_name):
164 raise page.page_test.Failure('Failed to start mirroring session.')
165 action_runner.ExecuteJavaScript('collectPerfData();')
166 action_runner.Wait(SESSION_TIME)
167 self.CloseExistingRoute(action_runner, sink_name)
168
169
122 class MediaRouterDialogPageSet(story.StorySet): 170 class MediaRouterDialogPageSet(story.StorySet):
123 """Pageset for media router dialog latency tests.""" 171 """Pageset for media router dialog latency tests."""
124 172
125 def __init__(self): 173 def __init__(self):
126 super(MediaRouterDialogPageSet, self).__init__( 174 super(MediaRouterDialogPageSet, self).__init__(
127 cloud_storage_bucket=story.PARTNER_BUCKET) 175 cloud_storage_bucket=story.PARTNER_BUCKET)
128 self.AddStory(CastDialogPage(self)) 176 self.AddStory(CastDialogPage(self))
129 177
130 178
131 class MediaRouterCPUMemoryPageSet(story.StorySet): 179 class MediaRouterCPUMemoryPageSet(story.StorySet):
132 """Pageset for media router CPU/memory usage tests.""" 180 """Pageset for media router CPU/memory usage tests."""
133 181
134 def __init__(self): 182 def __init__(self):
135 super(MediaRouterCPUMemoryPageSet, self).__init__( 183 super(MediaRouterCPUMemoryPageSet, self).__init__(
136 cloud_storage_bucket=story.PARTNER_BUCKET) 184 cloud_storage_bucket=story.PARTNER_BUCKET)
137 self.AddStory(CastIdlePage(self)) 185 self.AddStory(CastIdlePage(self))
138 self.AddStory(CastFlingingPage(self)) 186 self.AddStory(CastFlingingPage(self))
187 self.AddStory(CastMirroringPage(self))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698