OLD | NEW |
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" | |
6 #include "base/macros.h" | 5 #include "base/macros.h" |
7 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
8 #include "content/public/browser/web_contents_delegate.h" | 7 #include "content/public/browser/web_contents_delegate.h" |
9 #include "content/public/test/browser_test_utils.h" | 8 #include "content/public/test/browser_test_utils.h" |
10 #include "extensions/browser/guest_view/web_view/web_view_apitest.h" | 9 #include "extensions/browser/guest_view/web_view/web_view_apitest.h" |
11 #include "extensions/test/extension_test_message_listener.h" | 10 #include "extensions/test/extension_test_message_listener.h" |
12 | 11 |
13 namespace { | 12 namespace { |
14 | 13 |
15 // This class intercepts media access request from the embedder. The request | 14 // This class intercepts media access request from the embedder. The request |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 73 |
75 // Runs media_access tests. | 74 // Runs media_access tests. |
76 void RunTest(const std::string& test_name) { | 75 void RunTest(const std::string& test_name) { |
77 ExtensionTestMessageListener test_run_listener("TEST_PASSED", false); | 76 ExtensionTestMessageListener test_run_listener("TEST_PASSED", false); |
78 test_run_listener.set_failure_message("TEST_FAILED"); | 77 test_run_listener.set_failure_message("TEST_FAILED"); |
79 EXPECT_TRUE(content::ExecuteScript( | 78 EXPECT_TRUE(content::ExecuteScript( |
80 embedder_web_contents_, | 79 embedder_web_contents_, |
81 base::StringPrintf("runTest('%s');", test_name.c_str()))); | 80 base::StringPrintf("runTest('%s');", test_name.c_str()))); |
82 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied()); | 81 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied()); |
83 } | 82 } |
84 | |
85 void SetUpCommandLine(base::CommandLine* command_line) override { | |
86 WebViewAPITest::SetUpCommandLine(command_line); | |
87 // This switch ensures that there will always be at least one media device, | |
88 // even on machines without physical devices. This is required by tests that | |
89 // request permission to use media devices. | |
90 command_line->AppendSwitch("use-fake-device-for-media-stream"); | |
91 } | |
92 }; | 83 }; |
93 | 84 |
94 IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllow) { | 85 IN_PROC_BROWSER_TEST_F(WebViewMediaAccessAPITest, TestAllow) { |
95 std::string app_location = "web_view/media_access/allow"; | 86 std::string app_location = "web_view/media_access/allow"; |
96 StartTestServer(app_location); | 87 StartTestServer(app_location); |
97 LaunchApp(app_location); | 88 LaunchApp(app_location); |
98 | 89 |
99 std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate()); | 90 std::unique_ptr<MockWebContentsDelegate> mock(new MockWebContentsDelegate()); |
100 embedder_web_contents_->SetDelegate(mock.get()); | 91 embedder_web_contents_->SetDelegate(mock.get()); |
101 | 92 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 TestNoPreventDefaultImpliesDeny) { | 192 TestNoPreventDefaultImpliesDeny) { |
202 std::string app_location = "web_view/media_access/deny"; | 193 std::string app_location = "web_view/media_access/deny"; |
203 StartTestServer(app_location); | 194 StartTestServer(app_location); |
204 LaunchApp(app_location); | 195 LaunchApp(app_location); |
205 | 196 |
206 RunTest("testNoPreventDefaultImpliesDeny"); | 197 RunTest("testNoPreventDefaultImpliesDeny"); |
207 StopTestServer(); | 198 StopTestServer(); |
208 } | 199 } |
209 | 200 |
210 } // namespace extensions | 201 } // namespace extensions |
OLD | NEW |