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

Unified Diff: chrome/browser/chrome_content_browser_client_unittest.cc

Issue 843583005: [ServiceWorker] Implement WebServiceWorkerContextClient::openWindow(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@content_browser_client_openurl
Patch Set: review comments 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 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 fd29ffc51bf212496fb428f65215f4d1d3606ed5..42c45c5f069ae45b63369a33164bbfdf66fd1548 100644
--- a/chrome/browser/chrome_content_browser_client_unittest.cc
+++ b/chrome/browser/chrome_content_browser_client_unittest.cc
@@ -23,7 +23,7 @@
namespace chrome {
-typedef testing::Test ChromeContentBrowserClientTest;
+using ChromeContentBrowserClientTest = testing::Test;
TEST_F(ChromeContentBrowserClientTest, ShouldAssignSiteForURL) {
ChromeContentBrowserClient client;
@@ -32,6 +32,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)
+
#if defined(ENABLE_WEBRTC)
// NOTE: Any updates to the expectations in these tests should also be done in
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | content/browser/service_worker/service_worker_provider_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698