| 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" | 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 32 | 32 |
| 33 // MediaStreamPermissionTest --------------------------------------------------- | 33 // MediaStreamPermissionTest --------------------------------------------------- |
| 34 | 34 |
| 35 class MediaStreamPermissionTest : public WebRtcTestBase { | 35 class MediaStreamPermissionTest : public WebRtcTestBase { |
| 36 public: | 36 public: |
| 37 MediaStreamPermissionTest() {} | 37 MediaStreamPermissionTest() {} |
| 38 ~MediaStreamPermissionTest() override {} | 38 ~MediaStreamPermissionTest() override {} |
| 39 | 39 |
| 40 // InProcessBrowserTest: | 40 // InProcessBrowserTest: |
| 41 void SetUpCommandLine(base::CommandLine* command_line) override { | 41 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 42 // This test expects to run with fake devices but real UI. | 42 // This test expects to run with fake devices but real UI. |
| 43 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 43 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
| 44 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) | 44 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) |
| 45 << "Since this test tests the UI we want the real UI!"; | 45 << "Since this test tests the UI we want the real UI!"; |
| 46 } | 46 } |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 content::WebContents* LoadTestPageInTab() { | 49 content::WebContents* LoadTestPageInTab() { |
| 50 return LoadTestPageInBrowser(browser()); | 50 return LoadTestPageInBrowser(browser()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 content::WebContents* LoadTestPageInIncognitoTab() { | 53 content::WebContents* LoadTestPageInIncognitoTab() { |
| 54 return LoadTestPageInBrowser(CreateIncognitoBrowser()); | 54 return LoadTestPageInBrowser(CreateIncognitoBrowser()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Returns the URL of the main test page. | 57 // Returns the URL of the main test page. |
| 58 GURL test_page_url() const { | 58 GURL test_page_url() const { |
| 59 const char kMainWebrtcTestHtmlPage[] = | 59 const char kMainWebrtcTestHtmlPage[] = "/webrtc/webrtc_jsep01_test.html"; |
| 60 "files/webrtc/webrtc_jsep01_test.html"; | 60 return embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage); |
| 61 return test_server()->GetURL(kMainWebrtcTestHtmlPage); | |
| 62 } | 61 } |
| 63 | 62 |
| 64 private: | 63 private: |
| 65 content::WebContents* LoadTestPageInBrowser(Browser* browser) { | 64 content::WebContents* LoadTestPageInBrowser(Browser* browser) { |
| 66 EXPECT_TRUE(test_server()->Start()); | 65 EXPECT_TRUE(embedded_test_server()->Start()); |
| 67 | 66 |
| 68 // Uses the default server. | 67 // Uses the default server. |
| 69 GURL url = test_page_url(); | 68 GURL url = test_page_url(); |
| 70 | 69 |
| 71 EXPECT_TRUE(content::IsOriginSecure(url)); | 70 EXPECT_TRUE(content::IsOriginSecure(url)); |
| 72 | 71 |
| 73 ui_test_utils::NavigateToURL(browser, url); | 72 ui_test_utils::NavigateToURL(browser, url); |
| 74 return browser->tab_strip_model()->GetActiveWebContents(); | 73 return browser->tab_strip_model()->GetActiveWebContents(); |
| 75 } | 74 } |
| 76 | 75 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 158 |
| 160 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, | 159 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, |
| 161 DenyingCameraDoesNotCauseStickyDenyForMics) { | 160 DenyingCameraDoesNotCauseStickyDenyForMics) { |
| 162 content::WebContents* tab_contents = LoadTestPageInTab(); | 161 content::WebContents* tab_contents = LoadTestPageInTab(); |
| 163 | 162 |
| 164 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, | 163 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, |
| 165 kVideoOnlyCallConstraints); | 164 kVideoOnlyCallConstraints); |
| 166 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( | 165 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( |
| 167 tab_contents, kAudioOnlyCallConstraints)); | 166 tab_contents, kAudioOnlyCallConstraints)); |
| 168 } | 167 } |
| OLD | NEW |