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

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

Issue 2643833002: Add a New Tab page location group policy (Closed)
Patch Set: Fixed browser tests Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/pref_names.h"
13 #include "chrome/common/url_constants.h"
11 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
12 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "components/prefs/pref_service.h"
13 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
15 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
16 #include "content/public/test/browser_test_utils.h" 20 #include "content/public/test/browser_test_utils.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h" 21 #include "net/test/embedded_test_server/embedded_test_server.h"
18 #include "url/gurl.h" 22 #include "url/gurl.h"
19 23
20 namespace content { 24 namespace content {
21 25
22 class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest { 26 class ChromeContentBrowserClientBrowserTest : public InProcessBrowserTest {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 71
68 ui_test_utils::NavigateToURL(browser(), url); 72 ui_test_utils::NavigateToURL(browser(), url);
69 NavigationEntry* entry = GetLastCommittedEntry(); 73 NavigationEntry* entry = GetLastCommittedEntry();
70 74
71 ASSERT_TRUE(entry != NULL); 75 ASSERT_TRUE(entry != NULL);
72 EXPECT_EQ(url, entry->GetURL()); 76 EXPECT_EQ(url, entry->GetURL());
73 EXPECT_EQ(url, entry->GetVirtualURL()); 77 EXPECT_EQ(url, entry->GetVirtualURL());
74 } 78 }
75 79
76 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest, 80 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
81 UberURLHandler_NewTabPageOverride) {
82 PrefService* prefs = browser()->profile()->GetPrefs();
83 static const char kOverrideUrl[] = "http://override.com";
84 prefs->SetString(prefs::kNewTabPageLocationOverride, kOverrideUrl);
85 GURL ntp_url(chrome::kChromeUINewTabURL);
pastarmovj 2017/01/19 14:56:21 this can be const right?
MAD 2017/01/19 16:13:30 Done.
86
87 ui_test_utils::NavigateToURL(browser(), ntp_url);
88 NavigationEntry* entry = GetLastCommittedEntry();
89
90 ASSERT_TRUE(entry != NULL);
91 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
92 EXPECT_EQ(GURL(kOverrideUrl), entry->GetVirtualURL());
93
94 prefs->SetString(prefs::kNewTabPageLocationOverride, "");
95
96 ui_test_utils::NavigateToURL(browser(), ntp_url);
97 entry = GetLastCommittedEntry();
98
99 ASSERT_TRUE(entry != NULL);
100 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
101 EXPECT_EQ(ntp_url, entry->GetVirtualURL());
102 }
103
104 IN_PROC_BROWSER_TEST_F(ChromeContentBrowserClientBrowserTest,
77 UberURLHandler_EmptyHost) { 105 UberURLHandler_EmptyHost) {
78 const GURL url("chrome://chrome//foo"); 106 const GURL url("chrome://chrome//foo");
79 107
80 ui_test_utils::NavigateToURL(browser(), url); 108 ui_test_utils::NavigateToURL(browser(), url);
81 NavigationEntry* entry = GetLastCommittedEntry(); 109 NavigationEntry* entry = GetLastCommittedEntry();
82 110
83 ASSERT_TRUE(entry != NULL); 111 ASSERT_TRUE(entry != NULL);
84 EXPECT_TRUE(entry->GetVirtualURL().is_valid()); 112 EXPECT_TRUE(entry->GetVirtualURL().is_valid());
85 EXPECT_EQ(url, entry->GetVirtualURL()); 113 EXPECT_EQ(url, entry->GetVirtualURL());
86 } 114 }
(...skipping 23 matching lines...) Expand all
110 138
111 ui_test_utils::NavigateToURL(browser(), url); 139 ui_test_utils::NavigateToURL(browser(), url);
112 NavigationEntry* entry = GetLastCommittedEntry(); 140 NavigationEntry* entry = GetLastCommittedEntry();
113 141
114 ASSERT_TRUE(entry != NULL); 142 ASSERT_TRUE(entry != NULL);
115 EXPECT_EQ(url, entry->GetURL()); 143 EXPECT_EQ(url, entry->GetURL());
116 EXPECT_EQ(url, entry->GetVirtualURL()); 144 EXPECT_EQ(url, entry->GetVirtualURL());
117 } 145 }
118 146
119 } // namespace content 147 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698