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

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: 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
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 class ChromeContentBrowserClientWindowTest : public BrowserWithTestWindowTest {
39 public:
40 ChromeContentBrowserClientWindowTest()
41 : web_contents_(nullptr) {}
42
43 void DidOpenURL(content::WebContents* web_contents) {
44 web_contents_ = web_contents;
45 }
46
47 protected:
48 content::WebContents* web_contents() const { return web_contents_; }
49
50 private:
51 content::WebContents* web_contents_;
52 };
53
40 // This test opens two URLs using ContentBrowserClient::OpenURL. It expects the 54 // 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 55 // URLs to be opened in new tabs and activated, changing the active tabs after
42 // each call and increasing the tab count by 2. 56 // each call and increasing the tab count by 2.
43 TEST_F(ChromeContentBrowserClientWindowTest, OpenURL) { 57 TEST_F(ChromeContentBrowserClientWindowTest, OpenURL) {
44 ChromeContentBrowserClient client; 58 ChromeContentBrowserClient client;
45 59
46 int previous_count = browser()->tab_strip_model()->count(); 60 int previous_count = browser()->tab_strip_model()->count();
47 61
48 GURL urls[] = { GURL("https://www.google.com"), 62 GURL urls[] = { GURL("https://www.google.com"),
49 GURL("https://www.chromium.org") }; 63 GURL("https://www.chromium.org") };
50 64
51 for (const GURL& url : urls) { 65 for (const GURL& url : urls) {
52 content::OpenURLParams params(url, 66 content::OpenURLParams params(url,
53 content::Referrer(), 67 content::Referrer(),
54 NEW_FOREGROUND_TAB, 68 NEW_FOREGROUND_TAB,
55 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 69 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
56 false); 70 false);
57 content::WebContents* contents = 71 // TODO(peter): We should have more in-depth browser tests for the window
58 client.OpenURL(browser()->profile(), params); 72 // opening functionality, which also covers Android. For all platforms but
59 EXPECT_TRUE(contents); 73 // Android and iOS this is synchronous, which is the assumption this test
mlamouri (slow - plz ping) 2015/02/09 12:07:37 nit: I wouldn't make any assumption about iOS impl
Peter Beverloo 2015/02/10 17:49:37 Done.
74 // currently follows.
75 client.OpenURL(browser()->profile(),
76 params,
77 base::Bind(&ChromeContentBrowserClientWindowTest::DidOpenURL,
78 base::Unretained(this)));
79 EXPECT_TRUE(web_contents());
mlamouri (slow - plz ping) 2015/02/09 12:07:37 It's a bit odd to have web_contents() being a test
Peter Beverloo 2015/02/10 17:49:37 Done.
60 80
61 content::WebContents* active_contents = browser()->tab_strip_model()-> 81 content::WebContents* active_contents = browser()->tab_strip_model()->
62 GetActiveWebContents(); 82 GetActiveWebContents();
63 EXPECT_EQ(contents, active_contents); 83 EXPECT_EQ(web_contents(), active_contents);
64 EXPECT_EQ(url, active_contents->GetVisibleURL()); 84 EXPECT_EQ(url, active_contents->GetVisibleURL());
65 } 85 }
66 86
67 EXPECT_EQ(previous_count + 2, browser()->tab_strip_model()->count()); 87 EXPECT_EQ(previous_count + 2, browser()->tab_strip_model()->count());
68 } 88 }
69 89
70 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 90 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
71 91
72 #if defined(ENABLE_WEBRTC) 92 #if defined(ENABLE_WEBRTC)
73 93
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 256
237 #if defined(OS_ANDROID) 257 #if defined(OS_ANDROID)
238 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, 258 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER,
239 CONTENT_SETTING_ALLOW); 259 CONTENT_SETTING_ALLOW);
240 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA_IDENTIFIER, 260 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA_IDENTIFIER,
241 PERMISSION_STATUS_GRANTED); 261 PERMISSION_STATUS_GRANTED);
242 #endif 262 #endif
243 } 263 }
244 264
245 } // namespace chrome 265 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698