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 "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/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
10 #include "chrome/browser/content_settings/stub_settings_observer.h" | 10 #include "chrome/browser/content_settings/mock_settings_observer.h" |
11 #include "chrome/browser/mock_browsing_data_appcache_helper.h" | 11 #include "chrome/browser/mock_browsing_data_appcache_helper.h" |
12 #include "chrome/browser/mock_browsing_data_database_helper.h" | 12 #include "chrome/browser/mock_browsing_data_database_helper.h" |
13 #include "chrome/browser/mock_browsing_data_file_system_helper.h" | 13 #include "chrome/browser/mock_browsing_data_file_system_helper.h" |
14 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" | 14 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" |
15 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" | 15 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" |
16 #include "chrome/test/testing_profile.h" | 16 #include "chrome/test/testing_profile.h" |
17 #include "content/common/notification_details.h" | 17 #include "content/common/notification_details.h" |
18 #include "content/common/notification_type.h" | 18 #include "content/common/notification_type.h" |
19 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
20 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
24 | 24 |
| 25 using ::testing::_; |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 class CookiesTreeModelTest : public testing::Test { | 29 class CookiesTreeModelTest : public testing::Test { |
29 public: | 30 public: |
30 CookiesTreeModelTest() : ui_thread_(BrowserThread::UI, &message_loop_), | 31 CookiesTreeModelTest() : ui_thread_(BrowserThread::UI, &message_loop_), |
31 io_thread_(BrowserThread::IO, &message_loop_) { | 32 io_thread_(BrowserThread::IO, &message_loop_) { |
32 } | 33 } |
33 | 34 |
34 virtual ~CookiesTreeModelTest() { | 35 virtual ~CookiesTreeModelTest() { |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 851 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
851 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 852 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
852 new MockBrowsingDataAppCacheHelper(profile_.get()), | 853 new MockBrowsingDataAppCacheHelper(profile_.get()), |
853 new MockBrowsingDataIndexedDBHelper(profile_.get()), | 854 new MockBrowsingDataIndexedDBHelper(profile_.get()), |
854 new MockBrowsingDataFileSystemHelper(profile_.get()), | 855 new MockBrowsingDataFileSystemHelper(profile_.get()), |
855 false); | 856 false); |
856 | 857 |
857 TestingProfile profile; | 858 TestingProfile profile; |
858 HostContentSettingsMap* content_settings = | 859 HostContentSettingsMap* content_settings = |
859 profile.GetHostContentSettingsMap(); | 860 profile.GetHostContentSettingsMap(); |
860 StubSettingsObserver observer; | 861 MockSettingsObserver observer; |
861 | 862 |
862 CookieTreeRootNode* root = | 863 CookieTreeRootNode* root = |
863 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); | 864 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); |
864 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); | 865 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); |
865 | 866 |
866 EXPECT_EQ(1, origin->child_count()); | 867 EXPECT_EQ(1, origin->child_count()); |
867 EXPECT_TRUE(origin->CanCreateContentException()); | 868 EXPECT_TRUE(origin->CanCreateContentException()); |
| 869 EXPECT_CALL(observer, |
| 870 OnContentSettingsChanged(content_settings, |
| 871 CONTENT_SETTINGS_TYPE_COOKIES, false, |
| 872 _, false)); |
| 873 EXPECT_CALL(observer, |
| 874 OnContentSettingsChanged(content_settings, |
| 875 CONTENT_SETTINGS_TYPE_COOKIES, false, |
| 876 pattern, false)); |
868 origin->CreateContentException( | 877 origin->CreateContentException( |
869 content_settings, CONTENT_SETTING_SESSION_ONLY); | 878 content_settings, CONTENT_SETTING_SESSION_ONLY); |
870 | |
871 EXPECT_EQ(2, observer.counter); | |
872 EXPECT_EQ(pattern, observer.last_pattern); | |
873 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, | 879 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, |
874 content_settings->GetCookieContentSetting(host, host, true)); | 880 content_settings->GetCookieContentSetting(host, host, true)); |
875 } | 881 } |
876 | 882 |
877 } // namespace | 883 } // namespace |
OLD | NEW |