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

Unified Diff: content/public/test/browser_test_utils.cc

Issue 2334223012: Fix failures on content_browser tests on Windows 7. (Closed)
Patch Set: don't use the webrtc sendToTest method, and compare to 'video-input' (and not 'video') Created 4 years, 3 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
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/test/data/media/webrtc_test_utilities.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/browser_test_utils.cc
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
index 802d4eba324aefe2afe3628832346c879ff54346..5211cafb5b23381c965be8cde80b84cff3550b8c 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -408,6 +408,30 @@ void AppendGzippedResource(const base::RefCountedMemory& encoded,
} while (status != net::Filter::FILTER_DONE);
}
+// Queries for video input devices on the current system using the getSources
+// API.
+//
+// This does not guarantee that a getUserMedia with video will succeed, as the
+// camera could be busy for instance.
+//
+// Returns has-video-input-device to the test if there is a webcam available,
+// no-video-input-devices otherwise.
+const char kHasVideoInputDeviceOnSystem[] =
+ "(function() {"
+ "navigator.mediaDevices.enumerateDevices()"
+ ".then(function(devices) {"
+ "devices.forEach(function(device) {"
+ "if (device.kind == 'video-input') {"
+ "window.domAutomationController.send('has-video-input-device');"
+ "return;"
+ "}"
+ "});"
+ "window.domAutomationController.send('no-video-input-devices');"
+ "});"
+ "})()";
+
+const char kHasVideoInputDevice[] = "has-video-input-device";
+
} // namespace
bool NavigateIframeToURL(WebContents* web_contents,
@@ -742,6 +766,13 @@ void SimulateKeyPress(WebContents* web_contents,
ASSERT_EQ(modifiers, 0);
}
+bool IsWebcamAvailableOnSystem(WebContents* web_contents) {
+ std::string result;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractString(
+ web_contents, kHasVideoInputDeviceOnSystem, &result));
+ return result == kHasVideoInputDevice;
+}
+
RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) {
return web_contents->GetMainFrame();
}
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/test/data/media/webrtc_test_utilities.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698