| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 779 |
| 780 PolicyMap policies; | 780 PolicyMap policies; |
| 781 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 781 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 782 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); | 782 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); |
| 783 UpdateProviderPolicy(policies); | 783 UpdateProviderPolicy(policies); |
| 784 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); | 784 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); |
| 785 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowBookmarkBar)); | 785 EXPECT_TRUE(prefs->GetBoolean(prefs::kShowBookmarkBar)); |
| 786 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 786 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 787 | 787 |
| 788 // The NTP has special handling of the bookmark bar. | 788 // The NTP has special handling of the bookmark bar. |
| 789 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 789 ui_test_utils::NavigateToURLWithDisposition( |
| 790 browser(), GURL(chrome::kChromeUINewTabURL), CURRENT_TAB, |
| 791 ui_test_utils::BROWSER_TEST_NONE); |
| 790 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 792 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 791 | 793 |
| 792 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, | 794 policies.Set(key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, |
| 793 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); | 795 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); |
| 794 UpdateProviderPolicy(policies); | 796 UpdateProviderPolicy(policies); |
| 795 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); | 797 EXPECT_TRUE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); |
| 796 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar)); | 798 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar)); |
| 797 // The bookmark bar is hidden in the NTP when disabled by policy. | 799 // The bookmark bar is hidden in the NTP when disabled by policy. |
| 798 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 800 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
| 799 | 801 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 std::string expected_url("http://google.com/?"); | 991 std::string expected_url("http://google.com/?"); |
| 990 expected_url += std::string(chrome::kSafeSearchSafeParameter) + "&" + | 992 expected_url += std::string(chrome::kSafeSearchSafeParameter) + "&" + |
| 991 chrome::kSafeSearchSsuiParameter; | 993 chrome::kSafeSearchSsuiParameter; |
| 992 GURL expected_with_parameters(expected_url); | 994 GURL expected_with_parameters(expected_url); |
| 993 EXPECT_EQ(expected_with_parameters, web_contents->GetURL()); | 995 EXPECT_EQ(expected_with_parameters, web_contents->GetURL()); |
| 994 } | 996 } |
| 995 | 997 |
| 996 IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) { | 998 IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) { |
| 997 MakeRequestFail make_request_fail("search.example"); | 999 MakeRequestFail make_request_fail("search.example"); |
| 998 | 1000 |
| 999 chrome::EnableInstantExtendedAPIForTesting(); | 1001 chrome::EnableQueryExtractionForTesting(); |
| 1000 | 1002 |
| 1001 // Verifies that a default search is made using the provider configured via | 1003 // Verifies that a default search is made using the provider configured via |
| 1002 // policy. Also checks that default search can be completely disabled. | 1004 // policy. Also checks that default search can be completely disabled. |
| 1003 const string16 kKeyword(ASCIIToUTF16("testsearch")); | 1005 const string16 kKeyword(ASCIIToUTF16("testsearch")); |
| 1004 const std::string kSearchURL("https://www.google.com/search?q={searchTerms}"); | 1006 const std::string kSearchURL("https://www.google.com/search?q={searchTerms}"); |
| 1005 const std::string kInstantURL("http://does/not/exist"); | 1007 const std::string kInstantURL("http://does/not/exist"); |
| 1006 const std::string kAlternateURL0( | 1008 const std::string kAlternateURL0( |
| 1007 "https://www.google.com/search#q={searchTerms}"); | 1009 "https://www.google.com/search#q={searchTerms}"); |
| 1008 const std::string kAlternateURL1("https://www.google.com/#q={searchTerms}"); | 1010 const std::string kAlternateURL1("https://www.google.com/#q={searchTerms}"); |
| 1009 const std::string kSearchTermsReplacementKey( | 1011 const std::string kSearchTermsReplacementKey( |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, | 1324 policies.Set(key::kDeveloperToolsDisabled, POLICY_LEVEL_MANDATORY, |
| 1323 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); | 1325 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); |
| 1324 UpdateProviderPolicy(policies); | 1326 UpdateProviderPolicy(policies); |
| 1325 // The existing devtools window should have closed. | 1327 // The existing devtools window should have closed. |
| 1326 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); | 1328 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); |
| 1327 // And it's not possible to open it again. | 1329 // And it's not possible to open it again. |
| 1328 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); | 1330 EXPECT_FALSE(chrome::ExecuteCommand(browser(), IDC_DEV_TOOLS)); |
| 1329 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); | 1331 EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents)); |
| 1330 } | 1332 } |
| 1331 | 1333 |
| 1332 IN_PROC_BROWSER_TEST_F(PolicyTest, WebStoreIconHidden) { | 1334 // TODO(samarth): remove along with the NTP4 code. |
| 1335 IN_PROC_BROWSER_TEST_F(PolicyTest, DISABLED_WebStoreIconHidden) { |
| 1333 #if defined(OS_WIN) && defined(USE_ASH) | 1336 #if defined(OS_WIN) && defined(USE_ASH) |
| 1334 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 1337 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 1335 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 1338 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 1336 return; | 1339 return; |
| 1337 #endif | 1340 #endif |
| 1338 | 1341 |
| 1339 // Verifies that the web store icons can be hidden from the new tab page. | 1342 // Verifies that the web store icons can be hidden from the new tab page. |
| 1340 | 1343 |
| 1341 // Open new tab page and look for the web store icons. | 1344 // Open new tab page and look for the web store icons. |
| 1342 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 1345 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1695 NULL); | 1698 NULL); |
| 1696 UpdateProviderPolicy(policies); | 1699 UpdateProviderPolicy(policies); |
| 1697 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 1700 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
| 1698 content::WaitForLoadStop(contents); | 1701 content::WaitForLoadStop(contents); |
| 1699 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); | 1702 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); |
| 1700 | 1703 |
| 1701 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, | 1704 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, |
| 1702 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); | 1705 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); |
| 1703 UpdateProviderPolicy(policies); | 1706 UpdateProviderPolicy(policies); |
| 1704 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 1707 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
| 1705 content::WaitForLoadStop(contents); | 1708 contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1706 EXPECT_TRUE(chrome::IsNTPURL(contents->GetURL(),browser()->profile())); | 1709 EXPECT_TRUE(chrome::IsNTPURL(contents->GetURL(), browser()->profile())); |
| 1707 } | 1710 } |
| 1708 | 1711 |
| 1709 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { | 1712 IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { |
| 1710 // Verifies that incognito windows can't be opened when disabled by policy. | 1713 // Verifies that incognito windows can't be opened when disabled by policy. |
| 1711 | 1714 |
| 1712 const BrowserList* active_browser_list = | 1715 const BrowserList* active_browser_list = |
| 1713 BrowserList::GetInstance(chrome::GetActiveDesktop()); | 1716 BrowserList::GetInstance(chrome::GetActiveDesktop()); |
| 1714 | 1717 |
| 1715 // Disable incognito via policy and verify that incognito windows can't be | 1718 // Disable incognito via policy and verify that incognito windows can't be |
| 1716 // opened. | 1719 // opened. |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2397 #if defined(OS_WIN) && defined(USE_ASH) | 2400 #if defined(OS_WIN) && defined(USE_ASH) |
| 2398 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 2401 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 2399 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 2402 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 2400 return; | 2403 return; |
| 2401 #endif | 2404 #endif |
| 2402 | 2405 |
| 2403 TabStripModel* model = browser()->tab_strip_model(); | 2406 TabStripModel* model = browser()->tab_strip_model(); |
| 2404 int size = static_cast<int>(expected_urls_.size()); | 2407 int size = static_cast<int>(expected_urls_.size()); |
| 2405 EXPECT_EQ(size, model->count()); | 2408 EXPECT_EQ(size, model->count()); |
| 2406 for (int i = 0; i < size && i < model->count(); ++i) { | 2409 for (int i = 0; i < size && i < model->count(); ++i) { |
| 2407 EXPECT_EQ(expected_urls_[i], model->GetWebContentsAt(i)->GetURL()); | 2410 if (expected_urls_[i] == GURL(chrome::kChromeUINewTabURL)) { |
| 2411 EXPECT_TRUE(chrome::IsNTPURL(model->GetWebContentsAt(i)->GetURL(), |
| 2412 browser()->profile())); |
| 2413 } else { |
| 2414 EXPECT_EQ(expected_urls_[i], model->GetWebContentsAt(i)->GetURL()); |
| 2415 } |
| 2408 } | 2416 } |
| 2409 } | 2417 } |
| 2410 | 2418 |
| 2411 INSTANTIATE_TEST_CASE_P( | 2419 INSTANTIATE_TEST_CASE_P( |
| 2412 RestoreOnStartupPolicyTestInstance, | 2420 RestoreOnStartupPolicyTestInstance, |
| 2413 RestoreOnStartupPolicyTest, | 2421 RestoreOnStartupPolicyTest, |
| 2414 testing::Values(&RestoreOnStartupPolicyTest::HomepageIsNotNTP, | 2422 testing::Values(&RestoreOnStartupPolicyTest::HomepageIsNotNTP, |
| 2415 &RestoreOnStartupPolicyTest::HomepageIsNTP, | 2423 &RestoreOnStartupPolicyTest::HomepageIsNTP, |
| 2416 &RestoreOnStartupPolicyTest::ListOfURLs, | 2424 &RestoreOnStartupPolicyTest::ListOfURLs, |
| 2417 &RestoreOnStartupPolicyTest::NTP, | 2425 &RestoreOnStartupPolicyTest::NTP, |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2727 chrome_variations::VariationsService::GetVariationsServerURL( | 2735 chrome_variations::VariationsService::GetVariationsServerURL( |
| 2728 g_browser_process->local_state()); | 2736 g_browser_process->local_state()); |
| 2729 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); | 2737 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); |
| 2730 std::string value; | 2738 std::string value; |
| 2731 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 2739 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
| 2732 EXPECT_EQ("restricted", value); | 2740 EXPECT_EQ("restricted", value); |
| 2733 } | 2741 } |
| 2734 #endif | 2742 #endif |
| 2735 | 2743 |
| 2736 } // namespace policy | 2744 } // namespace policy |
| OLD | NEW |