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

Unified Diff: chrome/browser/chrome_content_browser_client_unittest.cc

Issue 844313002: Add ContentBrowserClient::OpenURL to allow tab opening wo/ WebContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android/ios build Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_content_browser_client_unittest.cc
diff --git a/chrome/browser/chrome_content_browser_client_unittest.cc b/chrome/browser/chrome_content_browser_client_unittest.cc
index 32ed67436d17beac0c7353a5aa5c703932d967cb..a456554060b9dcc4723c05495c4d42fc1bd54d4b 100644
--- a/chrome/browser/chrome_content_browser_client_unittest.cc
+++ b/chrome/browser/chrome_content_browser_client_unittest.cc
@@ -22,7 +22,7 @@
namespace chrome {
-typedef testing::Test ChromeContentBrowserClientTest;
+using ChromeContentBrowserClientTest = testing::Test;
TEST_F(ChromeContentBrowserClientTest, ShouldAssignSiteForURL) {
ChromeContentBrowserClient client;
@@ -31,6 +31,43 @@ TEST_F(ChromeContentBrowserClientTest, ShouldAssignSiteForURL) {
EXPECT_TRUE(client.ShouldAssignSiteForURL(GURL("https://www.google.com")));
}
+using ChromeContentBrowserClientWindowTest = BrowserWithTestWindowTest;
+
+// BrowserWithTestWindowTest doesn't work on iOS and Android.
+#if !defined(OS_ANDROID) && !defined(OS_IOS)
+
+// This test opens two URLs using ContentBrowserClient::OpenURL. It expects the
+// URLs to be opened in new tabs and activated, changing the active tabs after
+// each call and increasing the tab count by 2.
+TEST_F(ChromeContentBrowserClientWindowTest, OpenURL) {
+ ChromeContentBrowserClient client;
+
+ int previous_count = browser()->tab_strip_model()->count();
+
+ GURL urls[] = { GURL("https://www.google.com"),
+ GURL("https://www.chromium.org") };
+
+ for (const GURL& url : urls) {
+ content::OpenURLParams params(url,
+ content::Referrer(),
+ NEW_FOREGROUND_TAB,
+ ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
+ false);
+ content::WebContents* contents =
+ client.OpenURL(browser()->profile(), params);
+ EXPECT_TRUE(contents);
+
+ content::WebContents* active_contents = browser()->tab_strip_model()->
+ GetActiveWebContents();
+ EXPECT_EQ(contents, active_contents);
+ EXPECT_EQ(url, active_contents->GetVisibleURL());
+ }
+
+ EXPECT_EQ(previous_count + 2, browser()->tab_strip_model()->count());
+}
+
+#endif // !defined(OS_ANDROID) && !defined(OS_IOS)
+
// NOTE: Any updates to the expectations in these tests should also be done in
// the browser test WebRtcDisableEncryptionFlagBrowserTest.
class DisableWebRtcEncryptionFlagTest : public testing::Test {

Powered by Google App Engine
This is Rietveld 408576698