Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(973)

Side by Side Diff: chrome/browser/chrome_content_browser_client_unittest.cc

Issue 897673002: First step in enabling creating tabs without an Activity on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a-base-mounir
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.
67 // See https://crbug.com/457667.
68 content::WebContents* web_contents = nullptr;
69 client.OpenURL(browser()->profile(),
70 params,
71 base::Bind(&DidOpenURLForWindowTest, &web_contents));
72
73 EXPECT_TRUE(web_contents);
60 74
61 content::WebContents* active_contents = browser()->tab_strip_model()-> 75 content::WebContents* active_contents = browser()->tab_strip_model()->
62 GetActiveWebContents(); 76 GetActiveWebContents();
63 EXPECT_EQ(contents, active_contents); 77 EXPECT_EQ(web_contents, active_contents);
64 EXPECT_EQ(url, active_contents->GetVisibleURL()); 78 EXPECT_EQ(url, active_contents->GetVisibleURL());
65 } 79 }
66 80
67 EXPECT_EQ(previous_count + 2, browser()->tab_strip_model()->count()); 81 EXPECT_EQ(previous_count + 2, browser()->tab_strip_model()->count());
68 } 82 }
69 83
70 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 84 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
71 85
72 #if defined(ENABLE_WEBRTC) 86 #if defined(ENABLE_WEBRTC)
73 87
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 250
237 #if defined(OS_ANDROID) 251 #if defined(OS_ANDROID)
238 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, 252 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER,
239 CONTENT_SETTING_ALLOW); 253 CONTENT_SETTING_ALLOW);
240 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA_IDENTIFIER, 254 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA_IDENTIFIER,
241 PERMISSION_STATUS_GRANTED); 255 PERMISSION_STATUS_GRANTED);
242 #endif 256 #endif
243 } 257 }
244 258
245 } // namespace chrome 259 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698