| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mock_settings_observer.h" | 11 #include "chrome/browser/content_settings/mock_settings_observer.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 13 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/test/base/testing_browser_process_test.h" | |
| 18 #include "chrome/test/base/testing_pref_service.h" | 17 #include "chrome/test/base/testing_pref_service.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 20 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 21 #include "net/base/static_cookie_policy.h" | 20 #include "net/base/static_cookie_policy.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 22 |
| 24 using ::testing::_; | 23 using ::testing::_; |
| 25 | 24 |
| 26 namespace { | 25 namespace { |
| 27 | 26 |
| 28 bool SettingsEqual(const ContentSettings& settings1, | 27 bool SettingsEqual(const ContentSettings& settings1, |
| 29 const ContentSettings& settings2) { | 28 const ContentSettings& settings2) { |
| 30 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 29 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 31 if (settings1.settings[i] != settings2.settings[i]) { | 30 if (settings1.settings[i] != settings2.settings[i]) { |
| 32 LOG(ERROR) << "type: " << i | 31 LOG(ERROR) << "type: " << i |
| 33 << " [expected: " << settings1.settings[i] | 32 << " [expected: " << settings1.settings[i] |
| 34 << " actual: " << settings2.settings[i] << "]"; | 33 << " actual: " << settings2.settings[i] << "]"; |
| 35 return false; | 34 return false; |
| 36 } | 35 } |
| 37 } | 36 } |
| 38 return true; | 37 return true; |
| 39 } | 38 } |
| 40 | 39 |
| 41 } // namespace | 40 } // namespace |
| 42 | 41 |
| 43 class HostContentSettingsMapTest : public TestingBrowserProcessTest { | 42 class HostContentSettingsMapTest : public testing::Test { |
| 44 public: | 43 public: |
| 45 HostContentSettingsMapTest() : ui_thread_(BrowserThread::UI, &message_loop_) { | 44 HostContentSettingsMapTest() : ui_thread_(BrowserThread::UI, &message_loop_) { |
| 46 } | 45 } |
| 47 | 46 |
| 48 protected: | 47 protected: |
| 49 MessageLoop message_loop_; | 48 MessageLoop message_loop_; |
| 50 BrowserThread ui_thread_; | 49 BrowserThread ui_thread_; |
| 51 }; | 50 }; |
| 52 | 51 |
| 53 TEST_F(HostContentSettingsMapTest, DefaultValues) { | 52 TEST_F(HostContentSettingsMapTest, DefaultValues) { |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1267 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1269 host_content_settings_map->GetCookieContentSetting( | 1268 host_content_settings_map->GetCookieContentSetting( |
| 1270 kAllowedSite, kFirstPartySite, true)); | 1269 kAllowedSite, kFirstPartySite, true)); |
| 1271 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1270 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1272 host_content_settings_map->GetCookieContentSetting( | 1271 host_content_settings_map->GetCookieContentSetting( |
| 1273 kAllowedSite, kAllowedSite, false)); | 1272 kAllowedSite, kAllowedSite, false)); |
| 1274 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1273 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1275 host_content_settings_map->GetCookieContentSetting( | 1274 host_content_settings_map->GetCookieContentSetting( |
| 1276 kAllowedSite, kAllowedSite, true)); | 1275 kAllowedSite, kAllowedSite, true)); |
| 1277 } | 1276 } |
| OLD | NEW |