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

Side by Side Diff: chrome/browser/media/webrtc_browsertest_common.cc

Issue 1061473002: Make WebRtcWebcamBrowserTest fail faster. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issue in js code and improve logging of constraints Created 5 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/media/webrtc_browsertest_common.h" 5 #include "chrome/browser/media/webrtc_browsertest_common.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
10 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser_tabstrip.h" 14 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
15 #include "content/public/test/browser_test_utils.h" 16 #include "content/public/test/browser_test_utils.h"
16 17
17 namespace test { 18 namespace test {
18 19
(...skipping 12 matching lines...) Expand all
31 static const char kAdviseOnGclientSolution[] = 32 static const char kAdviseOnGclientSolution[] =
32 "You need to add this solution to your .gclient to run this test:\n" 33 "You need to add this solution to your .gclient to run this test:\n"
33 "{\n" 34 "{\n"
34 " \"name\" : \"webrtc.DEPS\",\n" 35 " \"name\" : \"webrtc.DEPS\",\n"
35 " \"url\" : \"https://chromium.googlesource.com/chromium/deps/" 36 " \"url\" : \"https://chromium.googlesource.com/chromium/deps/"
36 "webrtc/webrtc.DEPS\",\n" 37 "webrtc/webrtc.DEPS\",\n"
37 "}"; 38 "}";
38 39
39 const int kDefaultPollIntervalMsec = 250; 40 const int kDefaultPollIntervalMsec = 250;
40 41
42 bool IsErrorResult(const std::string& result) {
43 return StartsWithASCII(result, "failed-", false);
44 }
45
41 base::FilePath GetReferenceFilesDir() { 46 base::FilePath GetReferenceFilesDir() {
42 base::FilePath test_data_dir; 47 base::FilePath test_data_dir;
43 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); 48 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
44 49
45 return test_data_dir.Append(kReferenceFilesDirName); 50 return test_data_dir.Append(kReferenceFilesDirName);
46 } 51 }
47 52
48 base::FilePath GetToolForPlatform(const std::string& tool_name) { 53 base::FilePath GetToolForPlatform(const std::string& tool_name) {
49 base::FilePath tools_dir = 54 base::FilePath tools_dir =
50 GetReferenceFilesDir().Append(FILE_PATH_LITERAL("tools")); 55 GetReferenceFilesDir().Append(FILE_PATH_LITERAL("tools"));
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 std::string result; 131 std::string result;
127 132
128 while (base::Time::Now() - start_time < timeout) { 133 while (base::Time::Now() - start_time < timeout) {
129 std::string result; 134 std::string result;
130 if (!content::ExecuteScriptAndExtractString(tab_contents, javascript, 135 if (!content::ExecuteScriptAndExtractString(tab_contents, javascript,
131 &result)) { 136 &result)) {
132 LOG(ERROR) << "Failed to execute javascript " << javascript; 137 LOG(ERROR) << "Failed to execute javascript " << javascript;
133 return false; 138 return false;
134 } 139 }
135 140
136 if (evaluates_to == result) 141 if (evaluates_to == result) {
137 return true; 142 return true;
143 } else if (IsErrorResult(result)) {
144 LOG(ERROR) << "|" << javascript << "| returned an error: " << result;
145 return false;
146 }
138 147
139 // Sleep a bit here to keep this loop from spinlocking too badly. 148 // Sleep a bit here to keep this loop from spinlocking too badly.
140 if (!SleepInJavascript(tab_contents, poll_interval_msec)) { 149 if (!SleepInJavascript(tab_contents, poll_interval_msec)) {
141 // TODO(phoglund): Figure out why this fails every now and then. 150 // TODO(phoglund): Figure out why this fails every now and then.
142 // It's not a huge deal if it does though. 151 // It's not a huge deal if it does though.
143 LOG(ERROR) << "Failed to sleep."; 152 LOG(ERROR) << "Failed to sleep.";
144 } 153 }
145 } 154 }
146 LOG(ERROR) 155 LOG(ERROR)
147 << "Timed out while waiting for " << javascript 156 << "Timed out while waiting for " << javascript
148 << " to evaluate to " << evaluates_to << "; last result was '" << result 157 << " to evaluate to " << evaluates_to << "; last result was '" << result
149 << "'"; 158 << "'";
150 return false; 159 return false;
151 } 160 }
152 161
153 } // namespace test 162 } // namespace test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698