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

Side by Side Diff: content/browser/media/webrtc/webrtc_capture_from_element_browsertest.cc

Issue 2104643002: MediaCaptureFromElement: add content_browsertests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow <video>/<audio>.play() for tests when not initiated by user gesture. Created 4 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/strings/stringprintf.h"
7 #include "build/build_config.h" 7 #include "content/public/common/content_switches.h"
8 #include "content/public/test/browser_test_utils.h"
9 #include "content/public/test/content_browser_test_utils.h"
10 #include "content/test/webrtc_content_browsertest_base.h" 8 #include "content/test/webrtc_content_browsertest_base.h"
9 #include "media/base/test_data_util.h"
11 10
12 namespace { 11 namespace {
13 12
14 static const char kCanvasTestHtmlPage[] = "/media/canvas_capture_color.html"; 13 static const char kCanvasTestHtmlPage[] = "/media/canvas_capture_color.html";
15 14
15 static const char kVideoAudioHtmlFile[] =
16 "/media/video_audio_element_capture_test.html";
17
18 static struct FileAndTypeParameters {
19 bool has_video;
20 bool has_audio;
21 bool use_audio_tag;
22 std::string filename;
23 } const kFileAndTypeParameters[] = {
24 {true, false, false, "bear-320x240-video-only.webm"},
25 {false, true, false, "bear-320x240-audio-only.webm"},
26 {true, true, false, "bear-320x240.webm"},
27 {false, true, true, "bear-320x240-audio-only.webm"},
28 };
29
16 } // namespace 30 } // namespace
17 31
18 namespace content { 32 namespace content {
19 33
20 // This class tests the rgba color values produced by canvas capture. 34 // This class is the browser tests for Media Capture from DOM Elements API,
21 class WebRtcCanvasCaptureTest : public WebRtcContentBrowserTest { 35 // which allows for creation of a MediaStream out of a <canvas>, <video> or
36 // <audio> element.
37 class WebRtcCaptureFromElementBrowserTest
38 : public WebRtcContentBrowserTest,
39 public testing::WithParamInterface<struct FileAndTypeParameters> {
22 public: 40 public:
23 WebRtcCanvasCaptureTest() {} 41 WebRtcCaptureFromElementBrowserTest() {}
24 ~WebRtcCanvasCaptureTest() override {} 42 ~WebRtcCaptureFromElementBrowserTest() override {}
43
44 void SetUpCommandLine(base::CommandLine* command_line) override {
45 WebRtcContentBrowserTest::SetUpCommandLine(command_line);
46 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
47 switches::kEnableBlinkFeatures, "MediaCaptureFromVideo");
48
49 // Allow <video>/<audio>.play() when not initiated by user gesture.
50 base::CommandLine::ForCurrentProcess()->AppendSwitch(
51 switches::kDisableGestureRequirementForMediaPlayback);
52 }
25 53
26 private: 54 private:
27 DISALLOW_COPY_AND_ASSIGN(WebRtcCanvasCaptureTest); 55 DISALLOW_COPY_AND_ASSIGN(WebRtcCaptureFromElementBrowserTest);
28 }; 56 };
29 57
30 IN_PROC_BROWSER_TEST_F(WebRtcCanvasCaptureTest, 58 IN_PROC_BROWSER_TEST_F(WebRtcCaptureFromElementBrowserTest,
31 VerifyCanvasCaptureColor) { 59 VerifyCanvasCaptureColor) {
32 MakeTypicalCall("testCanvasCaptureColors();", kCanvasTestHtmlPage); 60 MakeTypicalCall("testCanvasCaptureColors();", kCanvasTestHtmlPage);
33 } 61 }
34 62
63 IN_PROC_BROWSER_TEST_P(WebRtcCaptureFromElementBrowserTest,
64 CaptureFromMediaElement) {
65 MakeTypicalCall(
66 base::StringPrintf("testCaptureFromMediaElement(\"%s\", %d, %d, %d);",
67 GetParam().filename.c_str(),
68 GetParam().has_video,
69 GetParam().has_audio,
70 GetParam().use_audio_tag),
71 kVideoAudioHtmlFile);
72 }
73
74 INSTANTIATE_TEST_CASE_P(,
75 WebRtcCaptureFromElementBrowserTest,
76 testing::ValuesIn(kFileAndTypeParameters));
35 } // namespace content 77 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/webrtc/webrtc_canvas_capture_browsertest.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698