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 "chrome/browser/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "chrome/browser/search_engines/template_url_service_factory.h" | 9 #include "chrome/browser/search_engines/template_url_service_factory.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/test/base/browser_with_test_window_test.h" | 12 #include "chrome/test/base/browser_with_test_window_test.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
14 #include "components/content_settings/core/browser/host_content_settings_map.h" | 14 #include "components/content_settings/core/browser/host_content_settings_map.h" |
15 #include "components/search_engines/template_url_service.h" | 15 #include "components/search_engines/template_url_service.h" |
16 #include "components/variations/entropy_provider.h" | 16 #include "components/variations/entropy_provider.h" |
17 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
18 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
23 | 23 |
24 namespace chrome { | 24 namespace chrome { |
25 | 25 |
26 typedef testing::Test ChromeContentBrowserClientTest; | 26 using ChromeContentBrowserClientTest = testing::Test; |
27 | 27 |
28 TEST_F(ChromeContentBrowserClientTest, ShouldAssignSiteForURL) { | 28 TEST_F(ChromeContentBrowserClientTest, ShouldAssignSiteForURL) { |
29 ChromeContentBrowserClient client; | 29 ChromeContentBrowserClient client; |
30 EXPECT_FALSE(client.ShouldAssignSiteForURL(GURL("chrome-native://test"))); | 30 EXPECT_FALSE(client.ShouldAssignSiteForURL(GURL("chrome-native://test"))); |
31 EXPECT_TRUE(client.ShouldAssignSiteForURL(GURL("http://www.google.com"))); | 31 EXPECT_TRUE(client.ShouldAssignSiteForURL(GURL("http://www.google.com"))); |
32 EXPECT_TRUE(client.ShouldAssignSiteForURL(GURL("https://www.google.com"))); | 32 EXPECT_TRUE(client.ShouldAssignSiteForURL(GURL("https://www.google.com"))); |
33 } | 33 } |
34 | 34 |
| 35 using ChromeContentBrowserClientWindowTest = BrowserWithTestWindowTest; |
| 36 |
| 37 // BrowserWithTestWindowTest doesn't work on iOS and Android. |
| 38 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 39 |
| 40 // This test opens two URLs using ContentBrowserClient::OpenURL. It expects the |
| 41 // URLs to be opened in new tabs and activated, changing the active tabs after |
| 42 // each call and increasing the tab count by 2. |
| 43 TEST_F(ChromeContentBrowserClientWindowTest, OpenURL) { |
| 44 ChromeContentBrowserClient client; |
| 45 |
| 46 int previous_count = browser()->tab_strip_model()->count(); |
| 47 |
| 48 GURL urls[] = { GURL("https://www.google.com"), |
| 49 GURL("https://www.chromium.org") }; |
| 50 |
| 51 for (const GURL& url : urls) { |
| 52 content::OpenURLParams params(url, |
| 53 content::Referrer(), |
| 54 NEW_FOREGROUND_TAB, |
| 55 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 56 false); |
| 57 content::WebContents* contents = |
| 58 client.OpenURL(browser()->profile(), params); |
| 59 EXPECT_TRUE(contents); |
| 60 |
| 61 content::WebContents* active_contents = browser()->tab_strip_model()-> |
| 62 GetActiveWebContents(); |
| 63 EXPECT_EQ(contents, active_contents); |
| 64 EXPECT_EQ(url, active_contents->GetVisibleURL()); |
| 65 } |
| 66 |
| 67 EXPECT_EQ(previous_count + 2, browser()->tab_strip_model()->count()); |
| 68 } |
| 69 |
| 70 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| 71 |
35 // NOTE: Any updates to the expectations in these tests should also be done in | 72 // NOTE: Any updates to the expectations in these tests should also be done in |
36 // the browser test WebRtcDisableEncryptionFlagBrowserTest. | 73 // the browser test WebRtcDisableEncryptionFlagBrowserTest. |
37 class DisableWebRtcEncryptionFlagTest : public testing::Test { | 74 class DisableWebRtcEncryptionFlagTest : public testing::Test { |
38 public: | 75 public: |
39 DisableWebRtcEncryptionFlagTest() | 76 DisableWebRtcEncryptionFlagTest() |
40 : from_command_line_(base::CommandLine::NO_PROGRAM), | 77 : from_command_line_(base::CommandLine::NO_PROGRAM), |
41 to_command_line_(base::CommandLine::NO_PROGRAM) {} | 78 to_command_line_(base::CommandLine::NO_PROGRAM) {} |
42 | 79 |
43 protected: | 80 protected: |
44 void SetUp() override { | 81 void SetUp() override { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 CheckPermissionStatus(PERMISSION_PUSH_MESSAGING, PERMISSION_STATUS_GRANTED); | 230 CheckPermissionStatus(PERMISSION_PUSH_MESSAGING, PERMISSION_STATUS_GRANTED); |
194 | 231 |
195 #if defined(OS_ANDROID) | 232 #if defined(OS_ANDROID) |
196 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, | 233 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, |
197 CONTENT_SETTING_ALLOW); | 234 CONTENT_SETTING_ALLOW); |
198 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA, PERMISSION_STATUS_GRANTED); | 235 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA, PERMISSION_STATUS_GRANTED); |
199 #endif | 236 #endif |
200 } | 237 } |
201 | 238 |
202 } // namespace chrome | 239 } // namespace chrome |
OLD | NEW |