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

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: Minor update for the function docs 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.ExecuteAsyncJavaScript(
39 action_runner,
40 'initialize();',
41 lambda: action_runner.EvaluateJavaScript('initialized'),
42 'Failed to initialize')
43
44 action_runner.TapElement(selector='#start_session_button')
45 action_runner.Wait(5)
46 for tab in action_runner.tab.browser.tabs:
47 # Close media router dialog
48 if tab.url == 'chrome://media-router/':
49 self.CloseDialog(tab)
50
51
52 class CastIdlePage(CastDialogPage):
53 """Cast page to open a cast-enabled page and do nothing."""
54
55 def __init__(self, page_set):
56 super(CastIdlePage, self).__init__(
57 page_set=page_set,
58 url='file://basic_test.html',
59 shared_page_state_class=SharedState)
60
61 def RunPageInteractions(self, action_runner):
62 super(CastIdlePage, self).RunPageInteractions(action_runner)
63 action_runner.Wait(15)
64
65
66 class CastFlingingPage(media_router_page.CastPage):
67 """Cast page to fling a video to Chromecast device."""
68
69 def __init__(self, page_set):
70 super(CastFlingingPage, self).__init__(
71 page_set=page_set,
72 url='file://basic_test.html#flinging',
73 shared_page_state_class=SharedState)
74
75 def RunPageInteractions(self, action_runner):
76 # Wait for 5s after Chrome is opened in order to get consistent results.
77 action_runner.Wait(5)
78 with action_runner.CreateInteraction('flinging'):
79 action_runner.ExecuteJavaScript('collectPerfData();')
80
81 self.ExecuteAsyncJavaScript(
82 action_runner,
83 'initialize();',
84 lambda: action_runner.EvaluateJavaScript('initialized'),
85 'Failed to initialize')
86
87 # Start session
88 action_runner.TapElement(selector='#start_session_button')
89 self._WaitForResult(
90 action_runner,
91 lambda: len(action_runner.tab.browser.tabs) >= 2,
92 'MR dialog never showed up.')
93
94 # Wait for 2s to make sure the dialog is fully loaded.
95 action_runner.Wait(2)
96 for tab in action_runner.tab.browser.tabs:
97 # Choose sink
98 if tab.url == 'chrome://media-router/':
99 self.ChooseSink(tab, self._GetDeviceName())
100
101 self._WaitForResult(
102 action_runner,
103 lambda: action_runner.EvaluateJavaScript('currentSession'),
104 'Failed to start session',
105 timeout=10)
106
107 # Load Media
108 # TODO: use local video instead of the public one.
109 self.ExecuteAsyncJavaScript(
110 action_runner,
111 'loadMedia("http://easyhtml5video.com/images/happyfit2.mp4");',
112 lambda: action_runner.EvaluateJavaScript('currentMedia'),
113 'Failed to load media')
114
115 action_runner.Wait(20)
116 # Stop session
117 self.ExecuteAsyncJavaScript(
118 action_runner,
119 'stopSession();',
120 lambda: not action_runner.EvaluateJavaScript('currentSession'),
121 'Failed to stop session')
122
123
124 class MediaRouterDailogPageSet(story.StorySet):
125 """Pageset for media router dialog latency tests."""
126
127 def __init__(self):
128 super(MediaRouterDailogPageSet, self).__init__(
129 cloud_storage_bucket=story.PARTNER_BUCKET)
130 self.AddStory(CastDialogPage(self))
131
132
133 class MediaRouterCPUMemoryPageSet(story.StorySet):
134 """Pageset for media router CPU/memory usage tests."""
135
136 def __init__(self):
137 super(MediaRouterCPUMemoryPageSet, self).__init__(
138 cloud_storage_bucket=story.PARTNER_BUCKET)
139 self.AddStory(CastIdlePage(self))
140 self.AddStory(CastFlingingPage(self))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698