OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/auto_reset.h" | 5 #include "base/auto_reset.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "chrome/browser/content_settings/content_settings_details.h" | 9 #include "chrome/browser/content_settings/content_settings_details.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
11 #include "chrome/browser/content_settings/stub_settings_observer.h" | 11 #include "chrome/browser/content_settings/stub_settings_observer.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 16 #include "chrome/test/testing_browser_process_test.h" |
16 #include "chrome/test/testing_pref_service.h" | 17 #include "chrome/test/testing_pref_service.h" |
17 #include "chrome/test/testing_profile.h" | 18 #include "chrome/test/testing_profile.h" |
18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
19 #include "net/base/static_cookie_policy.h" | 20 #include "net/base/static_cookie_policy.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 bool SettingsEqual(const ContentSettings& settings1, | 25 bool SettingsEqual(const ContentSettings& settings1, |
25 const ContentSettings& settings2) { | 26 const ContentSettings& settings2) { |
26 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 27 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
27 if (settings1.settings[i] != settings2.settings[i]) | 28 if (settings1.settings[i] != settings2.settings[i]) |
28 return false; | 29 return false; |
29 } | 30 } |
30 return true; | 31 return true; |
31 } | 32 } |
32 | 33 |
33 class HostContentSettingsMapTest : public testing::Test { | 34 class HostContentSettingsMapTest : public TestingBrowserProcessTest { |
34 public: | 35 public: |
35 HostContentSettingsMapTest() : ui_thread_(BrowserThread::UI, &message_loop_) { | 36 HostContentSettingsMapTest() : ui_thread_(BrowserThread::UI, &message_loop_) { |
36 } | 37 } |
37 | 38 |
38 protected: | 39 protected: |
39 MessageLoop message_loop_; | 40 MessageLoop message_loop_; |
40 BrowserThread ui_thread_; | 41 BrowserThread ui_thread_; |
41 }; | 42 }; |
42 | 43 |
43 TEST_F(HostContentSettingsMapTest, DefaultValues) { | 44 TEST_F(HostContentSettingsMapTest, DefaultValues) { |
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 EXPECT_TRUE(host_content_settings_map->BlockThirdPartyCookies()); | 856 EXPECT_TRUE(host_content_settings_map->BlockThirdPartyCookies()); |
856 | 857 |
857 // After unsetting the managed value for the preference BlockThirdPartyCookies | 858 // After unsetting the managed value for the preference BlockThirdPartyCookies |
858 // the default value should be returned now. | 859 // the default value should be returned now. |
859 prefs->RemoveManagedPref(prefs::kBlockThirdPartyCookies); | 860 prefs->RemoveManagedPref(prefs::kBlockThirdPartyCookies); |
860 EXPECT_FALSE(host_content_settings_map->IsBlockThirdPartyCookiesManaged()); | 861 EXPECT_FALSE(host_content_settings_map->IsBlockThirdPartyCookiesManaged()); |
861 EXPECT_FALSE(host_content_settings_map->BlockThirdPartyCookies()); | 862 EXPECT_FALSE(host_content_settings_map->BlockThirdPartyCookies()); |
862 } | 863 } |
863 | 864 |
864 } // namespace | 865 } // namespace |
OLD | NEW |