| 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 "chrome/browser/cookies_tree_model.h" | 5 #include "chrome/browser/cookies_tree_model.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/browser/content_settings/content_settings_details.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_unittest.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
| 11 #include "chrome/browser/mock_browsing_data_appcache_helper.h" | 10 #include "chrome/browser/mock_browsing_data_appcache_helper.h" |
| 12 #include "chrome/browser/mock_browsing_data_database_helper.h" | 11 #include "chrome/browser/mock_browsing_data_database_helper.h" |
| 13 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" | 12 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" |
| 14 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" | 13 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" |
| 15 #include "chrome/common/net/url_request_context_getter.h" | 14 #include "chrome/common/net/url_request_context_getter.h" |
| 16 #include "chrome/common/notification_details.h" | 15 #include "chrome/common/notification_details.h" |
| 17 #include "chrome/common/notification_service.h" | 16 #include "chrome/common/notification_service.h" |
| 18 #include "chrome/common/notification_type.h" | 17 #include "chrome/common/notification_type.h" |
| 19 #include "chrome/test/testing_profile.h" | 18 #include "chrome/test/testing_profile.h" |
| 20 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 21 |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 class StubSettingsObserver : public NotificationObserver { | |
| 27 public: | |
| 28 StubSettingsObserver() : counter(0) { | |
| 29 registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, | |
| 30 NotificationService::AllSources()); | |
| 31 } | |
| 32 | |
| 33 virtual void Observe(NotificationType type, | |
| 34 const NotificationSource& source, | |
| 35 const NotificationDetails& details) { | |
| 36 ++counter; | |
| 37 Details<ContentSettingsDetails> settings_details(details); | |
| 38 last_pattern = settings_details.ptr()->pattern(); | |
| 39 } | |
| 40 | |
| 41 ContentSettingsPattern last_pattern; | |
| 42 int counter; | |
| 43 | |
| 44 private: | |
| 45 NotificationRegistrar registrar_; | |
| 46 }; | |
| 47 | |
| 48 class CookiesTreeModelTest : public testing::Test { | 25 class CookiesTreeModelTest : public testing::Test { |
| 49 public: | 26 public: |
| 50 CookiesTreeModelTest() : ui_thread_(BrowserThread::UI, &message_loop_), | 27 CookiesTreeModelTest() : ui_thread_(BrowserThread::UI, &message_loop_), |
| 51 io_thread_(BrowserThread::IO, &message_loop_) { | 28 io_thread_(BrowserThread::IO, &message_loop_) { |
| 52 } | 29 } |
| 53 | 30 |
| 54 virtual ~CookiesTreeModelTest() { | 31 virtual ~CookiesTreeModelTest() { |
| 55 } | 32 } |
| 56 | 33 |
| 57 virtual void SetUp() { | 34 virtual void SetUp() { |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 content_settings, CONTENT_SETTING_SESSION_ONLY); | 673 content_settings, CONTENT_SETTING_SESSION_ONLY); |
| 697 | 674 |
| 698 EXPECT_EQ(2, observer.counter); | 675 EXPECT_EQ(2, observer.counter); |
| 699 EXPECT_EQ(pattern, observer.last_pattern); | 676 EXPECT_EQ(pattern, observer.last_pattern); |
| 700 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, | 677 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, |
| 701 content_settings->GetContentSetting( | 678 content_settings->GetContentSetting( |
| 702 host, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 679 host, CONTENT_SETTINGS_TYPE_COOKIES, "")); |
| 703 } | 680 } |
| 704 | 681 |
| 705 } // namespace | 682 } // namespace |
| OLD | NEW |