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

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

Issue 2310683003: Removed duplicated JS hasVideoInputDeviceOnSystem() test helper (Closed)
Patch Set: Update logging syntax 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
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..64b6aa924a934308f6ecc49cde5580ba61ae115d 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -408,6 +408,25 @@ 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.
+static const std::string hasVideoInputDeviceOnSystem =
+ "(function() {"
+ "MediaStreamTrack.getSources(function(devices) {"
+ "devices.forEach(function(device) {"
+ "if (device.kind == 'video')"
+ "returnToTest('has-video-input-device');"
mcasas 2016/09/06 23:13:12 returnToTest(), confusingly enough, doesn't seem t
lunalu1 2016/09/07 14:30:34 Done.
+ "});"
+ "returnToTest('no-video-input-devices');"
+ "});"
+ "})()";
+
} // namespace
bool NavigateIframeToURL(WebContents* web_contents,
@@ -742,6 +761,13 @@ void SimulateKeyPress(WebContents* web_contents,
ASSERT_EQ(modifiers, 0);
}
+bool HasWebcamAvailableOnSystem(WebContents* tab_contents) {
+ std::string result;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractString(
+ tab_contents, hasVideoInputDeviceOnSystem, &result));
+ return result == "has-video-input-device";
+}
+
RenderFrameHost* ConvertToRenderFrameHost(WebContents* web_contents) {
return web_contents->GetMainFrame();
}

Powered by Google App Engine
This is Rietveld 408576698