| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 10 #include "chrome/browser/media/media_stream_devices_controller.h" | 10 #include "chrome/browser/media/media_stream_devices_controller.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "components/content_settings/core/browser/host_content_settings_map.h" | 22 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 23 #include "components/content_settings/core/common/content_settings_types.h" | 23 #include "components/content_settings/core/common/content_settings_types.h" |
| 24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
| 26 #include "content/public/common/media_stream_request.h" | 26 #include "content/public/common/media_stream_request.h" |
| 27 #include "content/public/common/origin_util.h" | 27 #include "content/public/common/origin_util.h" |
| 28 #include "content/public/test/browser_test_utils.h" | 28 #include "content/public/test/browser_test_utils.h" |
| 29 #include "media/base/media_switches.h" | 29 #include "media/base/media_switches.h" |
| 30 #include "net/dns/mock_host_resolver.h" | 30 #include "net/dns/mock_host_resolver.h" |
| 31 #include "net/test/spawned_test_server/spawned_test_server.h" | |
| 32 | 31 |
| 33 // MediaStreamPermissionTest --------------------------------------------------- | 32 // MediaStreamPermissionTest --------------------------------------------------- |
| 34 | 33 |
| 35 class MediaStreamPermissionTest : public WebRtcTestBase { | 34 class MediaStreamPermissionTest : public WebRtcTestBase { |
| 36 public: | 35 public: |
| 37 MediaStreamPermissionTest() {} | 36 MediaStreamPermissionTest() {} |
| 38 ~MediaStreamPermissionTest() override {} | 37 ~MediaStreamPermissionTest() override {} |
| 39 | 38 |
| 40 // InProcessBrowserTest: | 39 // InProcessBrowserTest: |
| 41 void SetUpCommandLine(base::CommandLine* command_line) override { | 40 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 42 // This test expects to run with fake devices but real UI. | 41 // This test expects to run with fake devices but real UI. |
| 43 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 42 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
| 44 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) | 43 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) |
| 45 << "Since this test tests the UI we want the real UI!"; | 44 << "Since this test tests the UI we want the real UI!"; |
| 46 } | 45 } |
| 47 | 46 |
| 48 protected: | 47 protected: |
| 49 content::WebContents* LoadTestPageInTab() { | 48 content::WebContents* LoadTestPageInTab() { |
| 50 return LoadTestPageInBrowser(browser()); | 49 return LoadTestPageInBrowser(browser()); |
| 51 } | 50 } |
| 52 | 51 |
| 53 content::WebContents* LoadTestPageInIncognitoTab() { | 52 content::WebContents* LoadTestPageInIncognitoTab() { |
| 54 return LoadTestPageInBrowser(CreateIncognitoBrowser()); | 53 return LoadTestPageInBrowser(CreateIncognitoBrowser()); |
| 55 } | 54 } |
| 56 | 55 |
| 57 // Returns the URL of the main test page. | 56 // Returns the URL of the main test page. |
| 58 GURL test_page_url() const { | 57 GURL test_page_url() const { |
| 59 const char kMainWebrtcTestHtmlPage[] = | 58 const char kMainWebrtcTestHtmlPage[] = "/webrtc/webrtc_jsep01_test.html"; |
| 60 "files/webrtc/webrtc_jsep01_test.html"; | 59 return embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage); |
| 61 return test_server()->GetURL(kMainWebrtcTestHtmlPage); | |
| 62 } | 60 } |
| 63 | 61 |
| 64 private: | 62 private: |
| 65 content::WebContents* LoadTestPageInBrowser(Browser* browser) { | 63 content::WebContents* LoadTestPageInBrowser(Browser* browser) { |
| 66 EXPECT_TRUE(test_server()->Start()); | 64 EXPECT_TRUE(embedded_test_server()->Start()); |
| 67 | 65 |
| 68 // Uses the default server. | 66 // Uses the default server. |
| 69 GURL url = test_page_url(); | 67 GURL url = test_page_url(); |
| 70 | 68 |
| 71 EXPECT_TRUE(content::IsOriginSecure(url)); | 69 EXPECT_TRUE(content::IsOriginSecure(url)); |
| 72 | 70 |
| 73 ui_test_utils::NavigateToURL(browser, url); | 71 ui_test_utils::NavigateToURL(browser, url); |
| 74 return browser->tab_strip_model()->GetActiveWebContents(); | 72 return browser->tab_strip_model()->GetActiveWebContents(); |
| 75 } | 73 } |
| 76 | 74 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 157 |
| 160 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, | 158 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, |
| 161 DenyingCameraDoesNotCauseStickyDenyForMics) { | 159 DenyingCameraDoesNotCauseStickyDenyForMics) { |
| 162 content::WebContents* tab_contents = LoadTestPageInTab(); | 160 content::WebContents* tab_contents = LoadTestPageInTab(); |
| 163 | 161 |
| 164 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, | 162 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, |
| 165 kVideoOnlyCallConstraints); | 163 kVideoOnlyCallConstraints); |
| 166 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( | 164 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( |
| 167 tab_contents, kAudioOnlyCallConstraints)); | 165 tab_contents, kAudioOnlyCallConstraints)); |
| 168 } | 166 } |
| OLD | NEW |