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

Unified Diff: chrome/browser/media/webrtc/webrtc_browsertest_common.cc

Issue 2753543010: WebRTC: Use the MediaStream Recording API for the audio_quality_browsertest. (Closed)
Patch Set: Addressed comments. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/webrtc/webrtc_browsertest_common.cc
diff --git a/chrome/browser/media/webrtc/webrtc_browsertest_common.cc b/chrome/browser/media/webrtc/webrtc_browsertest_common.cc
index 00105e363ba0f961391277f04219199772625b02..568d12160374add109f602c1921b145194942c71 100644
--- a/chrome/browser/media/webrtc/webrtc_browsertest_common.cc
+++ b/chrome/browser/media/webrtc/webrtc_browsertest_common.cc
@@ -119,7 +119,6 @@ bool SleepInJavascript(content::WebContents* tab_contents, int timeout_msec) {
tab_contents, javascript, &result);
return ok && result == "sleep-ok";
}
-
bool PollingWaitUntil(const std::string& javascript,
const std::string& evaluates_to,
content::WebContents* tab_contents) {
@@ -136,7 +135,6 @@ bool PollingWaitUntil(const std::string& javascript,
std::string result;
while (base::Time::Now() - start_time < timeout) {
- std::string result;
if (!content::ExecuteScriptAndExtractString(tab_contents, javascript,
&result)) {
LOG(ERROR) << "Failed to execute javascript " << javascript;
@@ -164,4 +162,33 @@ bool PollingWaitUntil(const std::string& javascript,
return false;
}
+bool PollingWaitUntil(const std::string& javascript,
+ content::WebContents* tab_contents,
+ int poll_interval_msec) {
+ base::Time start_time = base::Time::Now();
+ base::TimeDelta timeout = TestTimeouts::action_max_timeout();
+ bool result;
+
+ while (base::Time::Now() - start_time < timeout) {
+ if (!content::ExecuteScriptAndExtractBool(tab_contents, javascript,
+ &result)) {
+ LOG(ERROR) << "Failed to execute javascript " << javascript;
+ return false;
+ }
+
+ if (result) {
+ return true;
+ }
+
+ // Sleep a bit here to keep this loop from spinlocking too badly.
+ if (!SleepInJavascript(tab_contents, poll_interval_msec)) {
+ // TODO(phoglund): Figure out why this fails every now and then.
+ // It's not a huge deal if it does though.
+ LOG(ERROR) << "Failed to sleep.";
+ }
+ }
+ LOG(ERROR) << "Timed out while waiting for " << javascript;
+ return false;
+}
mcasas 2017/03/22 17:54:14 This code is very similar to l.129-163. Either ref
+
} // namespace test
« no previous file with comments | « chrome/browser/media/webrtc/webrtc_browsertest_common.h ('k') | chrome/test/data/webrtc/audio_extraction.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698