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" |
(...skipping 14 matching lines...) Expand all Loading... | |
25 | 25 |
26 using ChromeContentBrowserClientTest = testing::Test; | 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. | 35 // BrowserWithTestWindowTest doesn't work on iOS and Android. |
38 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 36 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
39 | 37 |
38 using ChromeContentBrowserClientWindowTest = BrowserWithTestWindowTest; | |
39 | |
40 static void DidOpenURLForWindowTest(content::WebContents** target_contents, | |
41 content::WebContents* opened_contents) { | |
42 DCHECK(target_contents); | |
43 | |
44 *target_contents = opened_contents; | |
45 } | |
46 | |
40 // This test opens two URLs using ContentBrowserClient::OpenURL. It expects the | 47 // 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 | 48 // URLs to be opened in new tabs and activated, changing the active tabs after |
42 // each call and increasing the tab count by 2. | 49 // each call and increasing the tab count by 2. |
43 TEST_F(ChromeContentBrowserClientWindowTest, OpenURL) { | 50 TEST_F(ChromeContentBrowserClientWindowTest, OpenURL) { |
44 ChromeContentBrowserClient client; | 51 ChromeContentBrowserClient client; |
45 | 52 |
46 int previous_count = browser()->tab_strip_model()->count(); | 53 int previous_count = browser()->tab_strip_model()->count(); |
47 | 54 |
48 GURL urls[] = { GURL("https://www.google.com"), | 55 GURL urls[] = { GURL("https://www.google.com"), |
49 GURL("https://www.chromium.org") }; | 56 GURL("https://www.chromium.org") }; |
50 | 57 |
51 for (const GURL& url : urls) { | 58 for (const GURL& url : urls) { |
52 content::OpenURLParams params(url, | 59 content::OpenURLParams params(url, |
53 content::Referrer(), | 60 content::Referrer(), |
54 NEW_FOREGROUND_TAB, | 61 NEW_FOREGROUND_TAB, |
55 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 62 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
56 false); | 63 false); |
57 content::WebContents* contents = | 64 // TODO(peter): We should have more in-depth browser tests for the window |
58 client.OpenURL(browser()->profile(), params); | 65 // opening functionality, which also covers Android. This test can currently |
59 EXPECT_TRUE(contents); | 66 // only be ran on platforms where OpenURL is implemented synchronously. |
mlamouri (slow - plz ping)
2015/02/11 13:50:23
nit: mind opening a bug?
Peter Beverloo
2015/02/11 16:18:27
Done.
| |
67 content::WebContents* web_contents = nullptr; | |
68 client.OpenURL(browser()->profile(), | |
69 params, | |
70 base::Bind(&DidOpenURLForWindowTest, &web_contents)); | |
71 | |
72 EXPECT_TRUE(web_contents); | |
60 | 73 |
61 content::WebContents* active_contents = browser()->tab_strip_model()-> | 74 content::WebContents* active_contents = browser()->tab_strip_model()-> |
62 GetActiveWebContents(); | 75 GetActiveWebContents(); |
63 EXPECT_EQ(contents, active_contents); | 76 EXPECT_EQ(web_contents, active_contents); |
64 EXPECT_EQ(url, active_contents->GetVisibleURL()); | 77 EXPECT_EQ(url, active_contents->GetVisibleURL()); |
65 } | 78 } |
66 | 79 |
67 EXPECT_EQ(previous_count + 2, browser()->tab_strip_model()->count()); | 80 EXPECT_EQ(previous_count + 2, browser()->tab_strip_model()->count()); |
68 } | 81 } |
69 | 82 |
70 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 83 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
71 | 84 |
72 #if defined(ENABLE_WEBRTC) | 85 #if defined(ENABLE_WEBRTC) |
73 | 86 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 | 249 |
237 #if defined(OS_ANDROID) | 250 #if defined(OS_ANDROID) |
238 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, | 251 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, |
239 CONTENT_SETTING_ALLOW); | 252 CONTENT_SETTING_ALLOW); |
240 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA_IDENTIFIER, | 253 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA_IDENTIFIER, |
241 PERMISSION_STATUS_GRANTED); | 254 PERMISSION_STATUS_GRANTED); |
242 #endif | 255 #endif |
243 } | 256 } |
244 | 257 |
245 } // namespace chrome | 258 } // namespace chrome |
OLD | NEW |