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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); | 673 EXPECT_EQ(BookmarkBar::HIDDEN, browser()->bookmark_bar_state()); |
674 | 674 |
675 policies.Clear(); | 675 policies.Clear(); |
676 UpdateProviderPolicy(policies); | 676 UpdateProviderPolicy(policies); |
677 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); | 677 EXPECT_FALSE(prefs->IsManagedPreference(prefs::kShowBookmarkBar)); |
678 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar)); | 678 EXPECT_FALSE(prefs->GetBoolean(prefs::kShowBookmarkBar)); |
679 // The bookmark bar is shown detached in the NTP, when disabled by prefs only. | 679 // The bookmark bar is shown detached in the NTP, when disabled by prefs only. |
680 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); | 680 EXPECT_EQ(BookmarkBar::DETACHED, browser()->bookmark_bar_state()); |
681 } | 681 } |
682 | 682 |
683 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_PRE_ClearSiteDataOnExit) { | 683 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_PRE_DefaultCookiesSetting) { |
684 // Verifies that cookies are deleted on shutdown. This test is split in 3 | 684 // Verifies that cookies are deleted on shutdown. This test is split in 3 |
685 // parts because it spans 2 browser restarts. | 685 // parts because it spans 2 browser restarts. |
686 | 686 |
687 Profile* profile = browser()->profile(); | 687 Profile* profile = browser()->profile(); |
688 GURL url(kURL); | 688 GURL url(kURL); |
689 // No cookies at startup. | 689 // No cookies at startup. |
690 EXPECT_TRUE(content::GetCookies(profile, url).empty()); | 690 EXPECT_TRUE(content::GetCookies(profile, url).empty()); |
691 // Set a cookie now. | 691 // Set a cookie now. |
692 std::string value = std::string(kCookieValue) + std::string(kCookieOptions); | 692 std::string value = std::string(kCookieValue) + std::string(kCookieOptions); |
693 EXPECT_TRUE(content::SetCookie(profile, url, value)); | 693 EXPECT_TRUE(content::SetCookie(profile, url, value)); |
694 // Verify it was set. | 694 // Verify it was set. |
695 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); | 695 EXPECT_EQ(kCookieValue, GetCookies(profile, url)); |
696 } | 696 } |
697 | 697 |
698 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_ClearSiteDataOnExit) { | 698 IN_PROC_BROWSER_TEST_F(PolicyTest, PRE_DefaultCookiesSetting) { |
699 // Verify that the cookie persists across restarts. | 699 // Verify that the cookie persists across restarts. |
700 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); | 700 EXPECT_EQ(kCookieValue, GetCookies(browser()->profile(), GURL(kURL))); |
701 // Now set the policy and the cookie should be gone after another restart. | 701 // Now set the policy and the cookie should be gone after another restart. |
702 PolicyMap policies; | 702 PolicyMap policies; |
703 policies.Set(key::kClearSiteDataOnExit, POLICY_LEVEL_MANDATORY, | 703 policies.Set(key::kDefaultCookiesSetting, POLICY_LEVEL_MANDATORY, |
704 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); | 704 POLICY_SCOPE_USER, base::Value::CreateIntegerValue(4)); |
705 UpdateProviderPolicy(policies); | 705 UpdateProviderPolicy(policies); |
706 } | 706 } |
707 | 707 |
708 IN_PROC_BROWSER_TEST_F(PolicyTest, ClearSiteDataOnExit) { | 708 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultCookiesSetting) { |
709 // Verify that the cookie is gone. | 709 // Verify that the cookie is gone. |
710 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); | 710 EXPECT_TRUE(GetCookies(browser()->profile(), GURL(kURL)).empty()); |
711 } | 711 } |
712 | 712 |
713 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { | 713 IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { |
714 MakeRequestFail make_request_fail("search.example"); | 714 MakeRequestFail make_request_fail("search.example"); |
715 | 715 |
716 // Verifies that a default search is made using the provider configured via | 716 // Verifies that a default search is made using the provider configured via |
717 // policy. Also checks that default search can be completely disabled. | 717 // policy. Also checks that default search can be completely disabled. |
718 const string16 kKeyword(ASCIIToUTF16("testsearch")); | 718 const string16 kKeyword(ASCIIToUTF16("testsearch")); |
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2114 chrome_variations::VariationsService::GetVariationsServerURL( | 2114 chrome_variations::VariationsService::GetVariationsServerURL( |
2115 g_browser_process->local_state()); | 2115 g_browser_process->local_state()); |
2116 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); | 2116 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); |
2117 std::string value; | 2117 std::string value; |
2118 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 2118 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
2119 EXPECT_EQ("restricted", value); | 2119 EXPECT_EQ("restricted", value); |
2120 } | 2120 } |
2121 #endif | 2121 #endif |
2122 | 2122 |
2123 } // namespace policy | 2123 } // namespace policy |
OLD | NEW |