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

Side by Side 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: 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
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"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/browser_with_test_window_test.h" 12 #include "chrome/test/base/browser_with_test_window_test.h"
13 #include "chrome/test/base/ui_test_utils.h" 13 #include "chrome/test/base/ui_test_utils.h"
14 #include "components/content_settings/core/browser/host_content_settings_map.h" 14 #include "components/content_settings/core/browser/host_content_settings_map.h"
15 #include "components/search_engines/template_url_service.h" 15 #include "components/search_engines/template_url_service.h"
16 #include "components/variations/entropy_provider.h" 16 #include "components/variations/entropy_provider.h"
17 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 namespace chrome { 24 namespace chrome {
25 25
26 typedef testing::Test ChromeContentBrowserClientTest; 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.
38 #if !defined(OS_ANDROID) && !defined(OS_IOS)
39
40 // 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
42 // each call and increasing the tab count by 2.
43 TEST_F(ChromeContentBrowserClientWindowTest, OpenURL) {
44 ChromeContentBrowserClient client;
45
46 int previous_count = browser()->tab_strip_model()->count();
47
48 GURL urls[] = { GURL("https://www.google.com"),
49 GURL("https://www.chromium.org") };
50
51 for (const GURL& url : urls) {
52 content::OpenURLParams params(url,
53 content::Referrer(),
54 NEW_FOREGROUND_TAB,
55 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
56 false);
57 content::WebContents* contents =
58 client.OpenURL(browser()->profile(), params);
59 EXPECT_TRUE(contents);
60
61 content::WebContents* active_contents = browser()->tab_strip_model()->
62 GetActiveWebContents();
63 EXPECT_EQ(contents, active_contents);
64 EXPECT_EQ(url, active_contents->GetVisibleURL());
65 }
66
67 EXPECT_EQ(previous_count + 2, browser()->tab_strip_model()->count());
68 }
69
70 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
71
35 #if defined(ENABLE_WEBRTC) 72 #if defined(ENABLE_WEBRTC)
36 73
37 // NOTE: Any updates to the expectations in these tests should also be done in 74 // NOTE: Any updates to the expectations in these tests should also be done in
38 // the browser test WebRtcDisableEncryptionFlagBrowserTest. 75 // the browser test WebRtcDisableEncryptionFlagBrowserTest.
39 class DisableWebRtcEncryptionFlagTest : public testing::Test { 76 class DisableWebRtcEncryptionFlagTest : public testing::Test {
40 public: 77 public:
41 DisableWebRtcEncryptionFlagTest() 78 DisableWebRtcEncryptionFlagTest()
42 : from_command_line_(base::CommandLine::NO_PROGRAM), 79 : from_command_line_(base::CommandLine::NO_PROGRAM),
43 to_command_line_(base::CommandLine::NO_PROGRAM) {} 80 to_command_line_(base::CommandLine::NO_PROGRAM) {}
44 81
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 236
200 #if defined(OS_ANDROID) 237 #if defined(OS_ANDROID)
201 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, 238 SetPermission(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER,
202 CONTENT_SETTING_ALLOW); 239 CONTENT_SETTING_ALLOW);
203 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA_IDENTIFIER, 240 CheckPermissionStatus(PERMISSION_PROTECTED_MEDIA_IDENTIFIER,
204 PERMISSION_STATUS_GRANTED); 241 PERMISSION_STATUS_GRANTED);
205 #endif 242 #endif
206 } 243 }
207 244
208 } // namespace chrome 245 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698