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

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

Issue 1843063004: Add new Telemetry tests to get CPU and memory usage for idle and flinging two test scenarios. Mirro… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Jennifer's comments Created 4 years, 8 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
(Empty)
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
3 # found in the LICENSE file.
4
5 from telemetry import page
6 from telemetry import story
7 from benchmarks.pagesets import media_router_page
8 from telemetry.core import exceptions
9 from telemetry.page import shared_page_state
10
11
12 class SharedState(shared_page_state.SharedPageState):
13 """Shared state that restarts the browser for every single story."""
14
15 def __init__(self, test, finder_options, story_set):
16 super(SharedState, self).__init__(
17 test, finder_options, story_set)
18
19 def DidRunStory(self, results):
20 super(SharedState, self).DidRunStory(results)
21 self._StopBrowser()
22
23
24 class CastDialogPage(media_router_page.CastPage):
25 """Cast page to open a cast-enabled page and open media router dialog."""
26
27 def __init__(self, page_set, url='file://basic_test.html',
28 shared_page_state_class=shared_page_state.SharedPageState):
29 super(CastDialogPage, self).__init__(
30 url=url, page_set=page_set,
31 shared_page_state_class=shared_page_state_class)
32
33 def RunPageInteractions(self, action_runner):
34 # Wait for 5s after Chrome is opened in order to get consistent results.
35 action_runner.Wait(5)
36 with action_runner.CreateInteraction('LaunchDialog'):
37 action_runner.ExecuteJavaScript('collectPerfData();')
38 self._WaitForResult(
39 action_runner,
40 lambda: action_runner.EvaluateJavaScript('initialized'),
41 'Failed to initialize')
42
43 action_runner.TapElement(selector='#start_session_button')
44 action_runner.Wait(5)
45 for tab in action_runner.tab.browser.tabs:
46 # Close media router dialog
47 if tab.url == 'chrome://media-router/':
48 self.CloseDialog(tab)
49
50
51 class CastIdlePage(CastDialogPage):
52 """Cast page to open a cast-enabled page and do nothing."""
53
54 def __init__(self, page_set):
55 super(CastIdlePage, self).__init__(
56 page_set=page_set,
57 url='file://basic_test.html',
58 shared_page_state_class=SharedState)
59
60 def RunPageInteractions(self, action_runner):
61 super(CastIdlePage, self).RunPageInteractions(action_runner)
62 action_runner.Wait(15)
63
64
65 class CastFlingingPage(media_router_page.CastPage):
66 """Cast page to fling a video to Chromecast device."""
67
68 def __init__(self, page_set):
69 super(CastFlingingPage, self).__init__(
70 page_set=page_set,
71 url='file://basic_test.html#flinging',
72 shared_page_state_class=SharedState)
73
74 def RunPageInteractions(self, action_runner):
75 # Wait for 5s after Chrome is opened in order to get consistent results.
76 action_runner.Wait(5)
77 with action_runner.CreateInteraction('flinging'):
78 action_runner.ExecuteJavaScript('collectPerfData();')
79
80 self._WaitForResult(
81 action_runner,
82 lambda: action_runner.EvaluateJavaScript('initialized'),
83 'Failed to initialize')
84
85 # Start session
86 action_runner.TapElement(selector='#start_session_button')
87 self._WaitForResult(
88 action_runner,
89 lambda: len(action_runner.tab.browser.tabs) >= 2,
90 'MR dialog never showed up.')
91
92 # Wait for 2s to make sure the dialog is fully loaded.
93 action_runner.Wait(2)
94 for tab in action_runner.tab.browser.tabs:
95 # Choose sink
96 if tab.url == 'chrome://media-router/':
97 self.ChooseSink(tab, self._GetDeviceName())
98
99 self._WaitForResult(
100 action_runner,
101 lambda: action_runner.EvaluateJavaScript('currentSession'),
102 'Failed to start session',
103 timeout=10)
104
105 # Load Media
106 # TODO: use local video instead of the public one.
107 self.ExecuteAsyncJavaScript(
108 action_runner,
109 'loadMedia("http://easyhtml5video.com/images/happyfit2.mp4");',
110 lambda: action_runner.EvaluateJavaScript('currentMedia'),
111 'Failed to load media')
112
113 action_runner.Wait(20)
114 # Stop session
115 self.ExecuteAsyncJavaScript(
116 action_runner,
117 'stopSession();',
118 lambda: not action_runner.EvaluateJavaScript('currentSession'),
119 'Failed to stop session')
120
121
122 class MediaRouterDailogPageSet(story.StorySet):
123 """Pageset for media router dialog latency tests."""
124
125 def __init__(self):
126 super(MediaRouterDailogPageSet, self).__init__(
127 cloud_storage_bucket=story.PARTNER_BUCKET)
128 self.AddStory(CastDialogPage(self))
129
130
131 class MediaRouterCPUMemoryPageSet(story.StorySet):
132 """Pageset for media router CPU/memory usage tests."""
133
134 def __init__(self):
135 super(MediaRouterCPUMemoryPageSet, self).__init__(
136 cloud_storage_bucket=story.PARTNER_BUCKET)
137 self.AddStory(CastIdlePage(self))
138 self.AddStory(CastFlingingPage(self))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698