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

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_media_access_apitest.cc

Issue 2941563002: Enable new getUserMedia audio constraints algorithm behind a flag. (Closed)
Patch Set: remove vertical space from DEPS Created 3 years, 6 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
« no previous file with comments | « extensions/browser/guest_view/web_view/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/macros.h" 6 #include "base/macros.h"
6 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
7 #include "content/public/browser/web_contents_delegate.h" 8 #include "content/public/browser/web_contents_delegate.h"
8 #include "content/public/test/browser_test_utils.h" 9 #include "content/public/test/browser_test_utils.h"
9 #include "extensions/browser/guest_view/web_view/web_view_apitest.h" 10 #include "extensions/browser/guest_view/web_view/web_view_apitest.h"
10 #include "extensions/test/extension_test_message_listener.h" 11 #include "extensions/test/extension_test_message_listener.h"
12 #include "media/base/media_switches.h"
11 13
12 namespace { 14 namespace {
13 15
14 // This class intercepts media access request from the embedder. The request 16 // This class intercepts media access request from the embedder. The request
15 // should be triggered only if the embedder API (from tests) allows the request 17 // should be triggered only if the embedder API (from tests) allows the request
16 // in Javascript. 18 // in Javascript.
17 // We do not issue the actual media request; the fact that the request reached 19 // We do not issue the actual media request; the fact that the request reached
18 // embedder's WebContents is good enough for our tests. This is also to make 20 // embedder's WebContents is good enough for our tests. This is also to make
19 // the test run successfully on trybots. 21 // the test run successfully on trybots.
20 class MockWebContentsDelegate : public content::WebContentsDelegate { 22 class MockWebContentsDelegate : public content::WebContentsDelegate {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 75
74 // Runs media_access tests. 76 // Runs media_access tests.
75 void RunTest(const std::string& test_name) { 77 void RunTest(const std::string& test_name) {
76 ExtensionTestMessageListener test_run_listener("TEST_PASSED", false); 78 ExtensionTestMessageListener test_run_listener("TEST_PASSED", false);
77 test_run_listener.set_failure_message("TEST_FAILED"); 79 test_run_listener.set_failure_message("TEST_FAILED");
78 EXPECT_TRUE(content::ExecuteScript( 80 EXPECT_TRUE(content::ExecuteScript(
79 embedder_web_contents_, 81 embedder_web_contents_,
80 base::StringPrintf("runTest('%s');", test_name.c_str()))); 82 base::StringPrintf("runTest('%s');", test_name.c_str())));
81 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied()); 83 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied());
82 } 84 }
85
86 void SetUpCommandLine(base::CommandLine* command_line) override {
87 // Enable fake devices to make sure there is at least one device in the
88 // system. Otherwise, this test would fail on machines without physical
89 // media devices since getUserMedia fails early in those cases.
90 WebViewAPITest::SetUpCommandLine(command_line);
91 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
92 }
83 }; 93 };
84 94
85 IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllow) { 95 IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllow) {
86 std::string app_location = "web_view/media_access/allow"; 96 std::string app_location = "web_view/media_access/allow";
87 StartTestServer(app_location); 97 StartTestServer(app_location);
88 LaunchApp(app_location); 98 LaunchApp(app_location);
89 99
90 std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate()); 100 std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate());
91 embedder_web_contents_->SetDelegate(mock.get()); 101 embedder_web_contents_->SetDelegate(mock.get());
92 102
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 TestNoPreventDefaultImpliesDeny) { 202 TestNoPreventDefaultImpliesDeny) {
193 std::string app_location = "web_view/media_access/deny"; 203 std::string app_location = "web_view/media_access/deny";
194 StartTestServer(app_location); 204 StartTestServer(app_location);
195 LaunchApp(app_location); 205 LaunchApp(app_location);
196 206
197 RunTest("testNoPreventDefaultImpliesDeny"); 207 RunTest("testNoPreventDefaultImpliesDeny");
198 StopTestServer(); 208 StopTestServer();
199 } 209 }
200 210
201 } // namespace extensions 211 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/web_view/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698