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" | |
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" |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 // This class intercepts media access request from the embedder. The request | 15 // This class intercepts media access request from the embedder. The request |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 | 63 |
63 DISALLOW_COPY_AND_ASSIGN(MockWebContentsDelegate); | 64 DISALLOW_COPY_AND_ASSIGN(MockWebContentsDelegate); |
64 }; | 65 }; |
65 | 66 |
66 } // namespace | 67 } // namespace |
67 | 68 |
68 namespace extensions { | 69 namespace extensions { |
69 | 70 |
70 class WebViewMediaAccessAPITest : public WebViewAPITest { | 71 class WebViewMediaAccessAPITest : public WebViewAPITest { |
71 protected: | 72 protected: |
72 WebViewMediaAccessAPITest() {} | 73 WebViewMediaAccessAPITest() { |
74 // This switch ensures that there will always be at least one media device, | |
75 // even on machines without physical devices. This is required for tests | |
76 // that request permission to use media devices. | |
77 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
Marijn Kruisselbrink
2017/04/11 18:02:17
nit: To add command line flags you should probably
| |
78 "use-fake-device-for-media-stream"); | |
79 } | |
73 | 80 |
74 // Runs media_access tests. | 81 // Runs media_access tests. |
75 void RunTest(const std::string& test_name) { | 82 void RunTest(const std::string& test_name) { |
76 ExtensionTestMessageListener test_run_listener("TEST_PASSED", false); | 83 ExtensionTestMessageListener test_run_listener("TEST_PASSED", false); |
77 test_run_listener.set_failure_message("TEST_FAILED"); | 84 test_run_listener.set_failure_message("TEST_FAILED"); |
78 EXPECT_TRUE(content::ExecuteScript( | 85 EXPECT_TRUE(content::ExecuteScript( |
79 embedder_web_contents_, | 86 embedder_web_contents_, |
80 base::StringPrintf("runTest('%s');", test_name.c_str()))); | 87 base::StringPrintf("runTest('%s');", test_name.c_str()))); |
81 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied()); | 88 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied()); |
82 } | 89 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 TestNoPreventDefaultImpliesDeny) { | 199 TestNoPreventDefaultImpliesDeny) { |
193 std::string app_location = "web_view/media_access/deny"; | 200 std::string app_location = "web_view/media_access/deny"; |
194 StartTestServer(app_location); | 201 StartTestServer(app_location); |
195 LaunchApp(app_location); | 202 LaunchApp(app_location); |
196 | 203 |
197 RunTest("testNoPreventDefaultImpliesDeny"); | 204 RunTest("testNoPreventDefaultImpliesDeny"); |
198 StopTestServer(); | 205 StopTestServer(); |
199 } | 206 } |
200 | 207 |
201 } // namespace extensions | 208 } // namespace extensions |
OLD | NEW |