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

Unified Diff: content/browser/webrtc/webrtc_image_capture_browsertest.cc

Issue 2418923003: ImageCapture: avoid several grabFrame()s in flight, beef up content_browsertests (Closed)
Patch Set: xianglu@ comments Created 4 years, 2 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 | « no previous file | content/renderer/media/image_capture_frame_grabber.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/webrtc/webrtc_image_capture_browsertest.cc
diff --git a/content/browser/webrtc/webrtc_image_capture_browsertest.cc b/content/browser/webrtc/webrtc_image_capture_browsertest.cc
index 13603b7976c0b5afc425999a4e595cf09a1b4d19..2213c5fd6a598cec2ecb3126b0d3667791c9f60a 100644
--- a/content/browser/webrtc/webrtc_image_capture_browsertest.cc
+++ b/content/browser/webrtc/webrtc_image_capture_browsertest.cc
@@ -18,6 +18,19 @@
#include "base/android/build_info.h"
#endif
+namespace content {
+
+#if defined(OS_WIN)
+// These tests are flaky on WebRTC Windows bots: https://crbug.com/633242.
+#define MAYBE_CreateAndGetCapabilities DISABLED_CreateAndGetCapabilities
+#define MAYBE_CreateAndTakePhoto DISABLED_CreateAndTakePhoto
+#define MAYBE_CreateAndGrabFrame DISABLED_CreateAndGrabFrame
+#else
+#define MAYBE_CreateAndGetCapabilities CreateAndGetCapabilities
+#define MAYBE_CreateAndTakePhoto CreateAndTakePhoto
+#define MAYBE_CreateAndGrabFrame CreateAndGrabFrame
+#endif
+
namespace {
static const char kImageCaptureHtmlFile[] = "/media/image_capture_test.html";
@@ -32,8 +45,6 @@ static struct TargetCamera {
} // namespace
-namespace content {
-
// This class is the content_browsertests for Image Capture API, which allows
// for capturing still images out of a MediaStreamTrack. Is a
// WebRtcWebcamBrowserTest to be able to use a physical camera.
@@ -67,74 +78,56 @@ class WebRtcImageCaptureBrowserTest
switches::kEnableBlinkFeatures, "ImageCapture");
}
- private:
- DISALLOW_COPY_AND_ASSIGN(WebRtcImageCaptureBrowserTest);
-};
+ void SetUp() override {
+ ASSERT_TRUE(embedded_test_server()->InitializeAndListen());
+ WebRtcWebcamBrowserTest::SetUp();
+ }
-#if defined(OS_WIN)
-// This test is flaky on WebRTC Windows bots: https://crbug.com/633242.
-#define MAYBE_CreateAndGetCapabilities DISABLED_CreateAndGetCapabilities
-#else
-#define MAYBE_CreateAndGetCapabilities CreateAndGetCapabilities
-#endif
-IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
- MAYBE_CreateAndGetCapabilities) {
+ // Tries to run a |command| JS test, returning true if the test can be safely
+ // skipped or it works as intended, or false otherwise.
+ bool RunImageCaptureTestCase(const std::string& command) {
#if defined(OS_ANDROID)
- // TODO(mcasas): fails on Lollipop devices: https://crbug.com/634811
- if (base::android::BuildInfo::GetInstance()->sdk_int() <
- base::android::SDK_VERSION_MARSHMALLOW) {
- return;
- }
+ // TODO(mcasas): fails on Lollipop devices: https://crbug.com/634811
+ if (base::android::BuildInfo::GetInstance()->sdk_int() <
+ base::android::SDK_VERSION_MARSHMALLOW) {
+ return true;
+ }
#endif
- ASSERT_TRUE(embedded_test_server()->Start());
- GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile));
- NavigateToURL(shell(), url);
+ GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile));
+ NavigateToURL(shell(), url);
+
+ if (!IsWebcamAvailableOnSystem(shell()->web_contents())) {
+ DVLOG(1) << "No video device; skipping test...";
+ return true;
+ }
- if (!IsWebcamAvailableOnSystem(shell()->web_contents())) {
- DVLOG(1) << "No video device; skipping test...";
- return;
+ std::string result;
+ if (!ExecuteScriptAndExtractString(shell(), command, &result))
+ return false;
+ return result == "OK";
}
- std::string result;
- ASSERT_TRUE(ExecuteScriptAndExtractString(
- shell(), "testCreateAndGetCapabilities()", &result));
- if (result == "OK")
- return;
- FAIL();
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebRtcImageCaptureBrowserTest);
+};
+
+IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
+ MAYBE_CreateAndGetCapabilities) {
+ embedded_test_server()->StartAcceptingConnections();
+ ASSERT_TRUE(RunImageCaptureTestCase("testCreateAndGetCapabilities()"));
}
-#if defined(OS_WIN)
-// This test is flaky on WebRTC Windows bots: https://crbug.com/633242.
-#define MAYBE_CreateAndTakePhoto DISABLED_CreateAndTakePhoto
-#else
-#define MAYBE_CreateAndTakePhoto CreateAndTakePhoto
-#endif
IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
MAYBE_CreateAndTakePhoto) {
-#if defined(OS_ANDROID)
- // TODO(mcasas): fails on Lollipop devices: https://crbug.com/634811
- if (base::android::BuildInfo::GetInstance()->sdk_int() <
- base::android::SDK_VERSION_MARSHMALLOW) {
- return;
- }
-#endif
-
- ASSERT_TRUE(embedded_test_server()->Start());
- GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile));
- NavigateToURL(shell(), url);
-
- if (!IsWebcamAvailableOnSystem(shell()->web_contents())) {
- DVLOG(1) << "No video device; skipping test...";
- return;
- }
+ embedded_test_server()->StartAcceptingConnections();
+ ASSERT_TRUE(RunImageCaptureTestCase("testCreateAndTakePhoto()"));
+}
- std::string result;
- ASSERT_TRUE(ExecuteScriptAndExtractString(shell(), "testCreateAndTakePhoto()",
- &result));
- if (result == "OK")
- return;
- FAIL();
+IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
+ MAYBE_CreateAndGrabFrame) {
+ embedded_test_server()->StartAcceptingConnections();
+ ASSERT_TRUE(RunImageCaptureTestCase("testCreateAndGrabFrame()"));
}
INSTANTIATE_TEST_CASE_P(,
« no previous file with comments | « no previous file | content/renderer/media/image_capture_frame_grabber.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698