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

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

Issue 2166433003: Implement a more stable way to check if the dialog is fully loaded before choose the sink, instead … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | chrome/test/media_router/telemetry/benchmarks/pagesets/media_router_perf_pages.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 logging 5 import logging
6 import os 6 import os
7 import time 7 import time
8 import utils 8 import utils
9 9
10 from telemetry import page 10 from telemetry import page
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return route 84 return route
85 85
86 def ExecuteAsyncJavaScript(self, action_runner, script, verify_func, 86 def ExecuteAsyncJavaScript(self, action_runner, script, verify_func,
87 error_message, timeout=5): 87 error_message, timeout=5):
88 """Executes async javascript function and waits until it finishes.""" 88 """Executes async javascript function and waits until it finishes."""
89 89
90 action_runner.ExecuteJavaScript(script) 90 action_runner.ExecuteJavaScript(script)
91 self._WaitForResult(action_runner, verify_func, error_message, 91 self._WaitForResult(action_runner, verify_func, error_message,
92 timeout=timeout) 92 timeout=timeout)
93 93
94 def WaitUntilDialogLoaded(self, action_runner, tab):
95 """Waits until dialog is fully loaded."""
96
97 self._WaitForResult(
98 action_runner,
99 lambda: tab.EvaluateJavaScript(
100 '!!window.document.getElementById('
101 '"media-router-container") &&'
102 'window.document.getElementById('
103 '"media-router-container").sinksToShow_ &&'
104 'window.document.getElementById('
105 '"media-router-container").sinksToShow_.length'),
106 'The dialog is not fully loaded within 15s.',
107 timeout=15)
108
94 def _WaitForResult(self, action_runner, verify_func, error_message, 109 def _WaitForResult(self, action_runner, verify_func, error_message,
95 timeout=5): 110 timeout=5):
96 """Waits until the function finishes or timeout.""" 111 """Waits until the function finishes or timeout."""
97 112
98 start_time = time.time() 113 start_time = time.time()
99 while (not verify_func() and 114 while (not verify_func() and
100 time.time() - start_time < timeout): 115 time.time() - start_time < timeout):
101 action_runner.Wait(1) 116 action_runner.Wait(1)
102 if not verify_func(): 117 if not verify_func():
103 raise page.page_test.Failure(error_message) 118 raise page.page_test.Failure(error_message)
104 119
105 def _GetDeviceName(self): 120 def _GetDeviceName(self):
106 """Gets device name from environment variable RECEIVER_NAME.""" 121 """Gets device name from environment variable RECEIVER_NAME."""
107 122
108 if 'RECEIVER_IP' not in os.environ or not os.environ.get('RECEIVER_IP'): 123 if 'RECEIVER_IP' not in os.environ or not os.environ.get('RECEIVER_IP'):
109 raise page.page_test.Failure( 124 raise page.page_test.Failure(
110 'Your test machine is not set up correctly, ' 125 'Your test machine is not set up correctly, '
111 'RECEIVER_IP enviroment variable is missing.') 126 'RECEIVER_IP enviroment variable is missing.')
112 return utils.GetDeviceName(os.environ.get('RECEIVER_IP')) 127 return utils.GetDeviceName(os.environ.get('RECEIVER_IP'))
OLDNEW
« no previous file with comments | « no previous file | chrome/test/media_router/telemetry/benchmarks/pagesets/media_router_perf_pages.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698