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/mock_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_quota_helper.h" |
15 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" | 16 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" |
16 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
17 #include "chrome/test/testing_browser_process_test.h" | 18 #include "chrome/test/testing_browser_process_test.h" |
18 #include "content/common/content_notification_types.h" | 19 #include "content/common/content_notification_types.h" |
19 #include "content/common/notification_details.h" | 20 #include "content/common/notification_details.h" |
20 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
21 #include "net/url_request/url_request_context_getter.h" | 22 #include "net/url_request/url_request_context_getter.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
25 | 26 |
26 using ::testing::_; | 27 using ::testing::_; |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 class CookiesTreeModelTest : public TestingBrowserProcessTest { | 31 class CookiesTreeModelTest : public TestingBrowserProcessTest { |
31 public: | 32 public: |
32 CookiesTreeModelTest() : ui_thread_(BrowserThread::UI, &message_loop_), | 33 CookiesTreeModelTest() : ui_thread_(BrowserThread::UI, &message_loop_), |
33 io_thread_(BrowserThread::IO, &message_loop_) { | 34 io_thread_(BrowserThread::IO, &message_loop_) { |
34 } | 35 } |
35 | 36 |
36 virtual ~CookiesTreeModelTest() { | 37 virtual ~CookiesTreeModelTest() { |
37 } | 38 } |
38 | 39 |
39 virtual void SetUp() { | 40 virtual void SetUp() OVERRIDE { |
40 profile_.reset(new TestingProfile()); | 41 profile_.reset(new TestingProfile()); |
41 profile_->CreateRequestContext(); | 42 profile_->CreateRequestContext(); |
42 mock_browsing_data_database_helper_ = | 43 mock_browsing_data_database_helper_ = |
43 new MockBrowsingDataDatabaseHelper(profile_.get()); | 44 new MockBrowsingDataDatabaseHelper(profile_.get()); |
44 mock_browsing_data_local_storage_helper_ = | 45 mock_browsing_data_local_storage_helper_ = |
45 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 46 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
46 mock_browsing_data_session_storage_helper_ = | 47 mock_browsing_data_session_storage_helper_ = |
47 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 48 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
48 mock_browsing_data_appcache_helper_ = | 49 mock_browsing_data_appcache_helper_ = |
49 new MockBrowsingDataAppCacheHelper(profile_.get()); | 50 new MockBrowsingDataAppCacheHelper(profile_.get()); |
50 mock_browsing_data_indexed_db_helper_ = | 51 mock_browsing_data_indexed_db_helper_ = |
51 new MockBrowsingDataIndexedDBHelper(profile_.get()); | 52 new MockBrowsingDataIndexedDBHelper(profile_.get()); |
52 mock_browsing_data_file_system_helper_ = | 53 mock_browsing_data_file_system_helper_ = |
53 new MockBrowsingDataFileSystemHelper(profile_.get()); | 54 new MockBrowsingDataFileSystemHelper(profile_.get()); |
| 55 mock_browsing_data_quota_helper_ = |
| 56 new MockBrowsingDataQuotaHelper(profile_.get()); |
| 57 } |
| 58 |
| 59 virtual void TearDown() OVERRIDE { |
| 60 mock_browsing_data_quota_helper_ = NULL; |
| 61 mock_browsing_data_file_system_helper_ = NULL; |
| 62 mock_browsing_data_indexed_db_helper_ = NULL; |
| 63 mock_browsing_data_appcache_helper_ = NULL; |
| 64 mock_browsing_data_session_storage_helper_ = NULL; |
| 65 mock_browsing_data_local_storage_helper_ = NULL; |
| 66 mock_browsing_data_database_helper_ = NULL; |
| 67 message_loop_.RunAllPending(); |
54 } | 68 } |
55 | 69 |
56 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { | 70 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { |
57 net::CookieMonster* monster = profile_->GetCookieMonster(); | 71 net::CookieMonster* monster = profile_->GetCookieMonster(); |
58 monster->SetCookie(GURL("http://foo1"), "A=1"); | 72 monster->SetCookie(GURL("http://foo1"), "A=1"); |
59 monster->SetCookie(GURL("http://foo2"), "B=1"); | 73 monster->SetCookie(GURL("http://foo2"), "B=1"); |
60 monster->SetCookie(GURL("http://foo3"), "C=1"); | 74 monster->SetCookie(GURL("http://foo3"), "C=1"); |
61 CookiesTreeModel* cookies_model = new CookiesTreeModel( | 75 CookiesTreeModel* cookies_model = new CookiesTreeModel( |
62 monster, mock_browsing_data_database_helper_, | 76 monster, mock_browsing_data_database_helper_, |
63 mock_browsing_data_local_storage_helper_, | 77 mock_browsing_data_local_storage_helper_, |
64 mock_browsing_data_session_storage_helper_, | 78 mock_browsing_data_session_storage_helper_, |
65 mock_browsing_data_appcache_helper_, | 79 mock_browsing_data_appcache_helper_, |
66 mock_browsing_data_indexed_db_helper_, | 80 mock_browsing_data_indexed_db_helper_, |
67 mock_browsing_data_file_system_helper_, | 81 mock_browsing_data_file_system_helper_, |
| 82 mock_browsing_data_quota_helper_, |
68 false); | 83 false); |
69 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 84 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
70 mock_browsing_data_database_helper_->Notify(); | 85 mock_browsing_data_database_helper_->Notify(); |
71 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 86 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
72 mock_browsing_data_local_storage_helper_->Notify(); | 87 mock_browsing_data_local_storage_helper_->Notify(); |
73 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 88 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
74 mock_browsing_data_session_storage_helper_->Notify(); | 89 mock_browsing_data_session_storage_helper_->Notify(); |
75 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 90 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
76 mock_browsing_data_indexed_db_helper_->Notify(); | 91 mock_browsing_data_indexed_db_helper_->Notify(); |
77 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 92 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
78 mock_browsing_data_file_system_helper_->Notify(); | 93 mock_browsing_data_file_system_helper_->Notify(); |
| 94 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
| 95 mock_browsing_data_quota_helper_->Notify(); |
79 { | 96 { |
80 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " | 97 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " |
81 "2 session storages, 2 indexed DBs, 3 filesystems"); | 98 "2 session storages, 2 indexed DBs, 3 filesystems, " |
82 // 41 because there's the root, then foo1 -> cookies -> a, | 99 "2 quotas"); |
| 100 // 45 because there's the root, then foo1 -> cookies -> a, |
83 // foo2 -> cookies -> b, foo3 -> cookies -> c, | 101 // foo2 -> cookies -> b, foo3 -> cookies -> c, |
84 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 102 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
85 // fshost1 -> filesystem -> http://fshost1:1/, | 103 // fshost1 -> filesystem -> http://fshost1:1/, |
86 // fshost2 -> filesystem -> http://fshost2:1/, | 104 // fshost2 -> filesystem -> http://fshost2:1/, |
87 // fshost3 -> filesystem -> http://fshost3:1/, | 105 // fshost3 -> filesystem -> http://fshost3:1/, |
88 // host1 -> localstorage -> http://host1:1/, | 106 // host1 -> localstorage -> http://host1:1/, |
89 // host2 -> localstorage -> http://host2:2/. | 107 // host2 -> localstorage -> http://host2:2/. |
90 // host1 -> sessionstorage -> http://host1:1/, | 108 // host1 -> sessionstorage -> http://host1:1/, |
91 // host2 -> sessionstorage -> http://host2:2/, | 109 // host2 -> sessionstorage -> http://host2:2/, |
92 // idbhost1 -> indexeddb -> http://idbhost1:1/, | 110 // idbhost1 -> indexeddb -> http://idbhost1:1/, |
93 // idbhost2 -> indexeddb -> http://idbhost2:2/. | 111 // idbhost2 -> indexeddb -> http://idbhost2:2/, |
94 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); | 112 // quotahost1 -> quotahost1, |
| 113 // quotahost2 -> quotahost2. |
| 114 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); |
95 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); | 115 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); |
96 EXPECT_EQ("http://host1:1/,http://host2:2/", | 116 EXPECT_EQ("http://host1:1/,http://host2:2/", |
97 GetDisplayedLocalStorages(cookies_model)); | 117 GetDisplayedLocalStorages(cookies_model)); |
98 EXPECT_EQ("http://host1:1/,http://host2:2/", | 118 EXPECT_EQ("http://host1:1/,http://host2:2/", |
99 GetDisplayedSessionStorages(cookies_model)); | 119 GetDisplayedSessionStorages(cookies_model)); |
100 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 120 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
101 GetDisplayedIndexedDBs(cookies_model)); | 121 GetDisplayedIndexedDBs(cookies_model)); |
102 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 122 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
103 GetDisplayedFileSystems(cookies_model)); | 123 GetDisplayedFileSystems(cookies_model)); |
| 124 EXPECT_EQ("quotahost1,quotahost2", |
| 125 GetDisplayedQuotas(cookies_model)); |
104 } | 126 } |
105 return cookies_model; | 127 return cookies_model; |
106 } | 128 } |
107 | 129 |
108 // Get the cookie names in the cookie list, as a comma seperated string. | 130 // Get the cookie names in the cookie list, as a comma seperated string. |
109 // (Note that the CookieMonster cookie list is sorted by domain.) | 131 // (Note that the CookieMonster cookie list is sorted by domain.) |
110 // Ex: | 132 // Ex: |
111 // monster->SetCookie(GURL("http://b"), "X=1") | 133 // monster->SetCookie(GURL("http://b"), "X=1") |
112 // monster->SetCookie(GURL("http://a"), "Y=1") | 134 // monster->SetCookie(GURL("http://a"), "Y=1") |
113 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); | 135 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); |
(...skipping 26 matching lines...) Expand all Loading... |
140 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: | 162 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: |
141 return node->GetDetailedInfo().cookie->Name() + ","; | 163 return node->GetDetailedInfo().cookie->Name() + ","; |
142 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: | 164 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: |
143 return node->GetDetailedInfo().appcache_info->manifest_url.spec() + | 165 return node->GetDetailedInfo().appcache_info->manifest_url.spec() + |
144 ","; | 166 ","; |
145 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: | 167 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: |
146 return node->GetDetailedInfo().indexed_db_info->origin + ","; | 168 return node->GetDetailedInfo().indexed_db_info->origin + ","; |
147 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: | 169 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: |
148 return node->GetDetailedInfo().file_system_info->origin.spec() + | 170 return node->GetDetailedInfo().file_system_info->origin.spec() + |
149 ","; | 171 ","; |
| 172 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: |
| 173 return node->GetDetailedInfo().quota_info->host + ","; |
150 default: | 174 default: |
151 return ""; | 175 return ""; |
152 } | 176 } |
153 } else { | 177 } else { |
154 return ""; | 178 return ""; |
155 } | 179 } |
156 } | 180 } |
157 } | 181 } |
158 | 182 |
159 std::string GetCookiesOfChildren(const CookieTreeNode* node) { | 183 std::string GetCookiesOfChildren(const CookieTreeNode* node) { |
(...skipping 18 matching lines...) Expand all Loading... |
178 std::string GetIndexedDBsOfChildren(const CookieTreeNode* node) { | 202 std::string GetIndexedDBsOfChildren(const CookieTreeNode* node) { |
179 return GetNodesOfChildren( | 203 return GetNodesOfChildren( |
180 node, CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); | 204 node, CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); |
181 } | 205 } |
182 | 206 |
183 std::string GetFileSystemsOfChildren(const CookieTreeNode* node) { | 207 std::string GetFileSystemsOfChildren(const CookieTreeNode* node) { |
184 return GetNodesOfChildren( | 208 return GetNodesOfChildren( |
185 node, CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); | 209 node, CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); |
186 } | 210 } |
187 | 211 |
| 212 std::string GetFileQuotaOfChildren(const CookieTreeNode* node) { |
| 213 return GetNodesOfChildren( |
| 214 node, CookieTreeNode::DetailedInfo::TYPE_QUOTA); |
| 215 } |
| 216 |
188 // Get the nodes names displayed in the view (if we had one) in the order | 217 // Get the nodes names displayed in the view (if we had one) in the order |
189 // they are displayed, as a comma seperated string. | 218 // they are displayed, as a comma seperated string. |
190 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str()); | 219 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str()); |
191 std::string GetDisplayedNodes(CookiesTreeModel* cookies_model, | 220 std::string GetDisplayedNodes(CookiesTreeModel* cookies_model, |
192 CookieTreeNode::DetailedInfo::NodeType type) { | 221 CookieTreeNode::DetailedInfo::NodeType type) { |
193 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>( | 222 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>( |
194 cookies_model->GetRoot()); | 223 cookies_model->GetRoot()); |
195 std::string retval = GetNodesOfChildren(root, type); | 224 std::string retval = GetNodesOfChildren(root, type); |
196 if (retval.length() && retval[retval.length() - 1] == ',') | 225 if (retval.length() && retval[retval.length() - 1] == ',') |
197 retval.erase(retval.length() - 1); | 226 retval.erase(retval.length() - 1); |
(...skipping 28 matching lines...) Expand all Loading... |
226 std::string GetDisplayedIndexedDBs(CookiesTreeModel* cookies_model) { | 255 std::string GetDisplayedIndexedDBs(CookiesTreeModel* cookies_model) { |
227 return GetDisplayedNodes(cookies_model, | 256 return GetDisplayedNodes(cookies_model, |
228 CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); | 257 CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); |
229 } | 258 } |
230 | 259 |
231 std::string GetDisplayedFileSystems(CookiesTreeModel* cookies_model) { | 260 std::string GetDisplayedFileSystems(CookiesTreeModel* cookies_model) { |
232 return GetDisplayedNodes(cookies_model, | 261 return GetDisplayedNodes(cookies_model, |
233 CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); | 262 CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); |
234 } | 263 } |
235 | 264 |
| 265 std::string GetDisplayedQuotas(CookiesTreeModel* cookies_model) { |
| 266 return GetDisplayedNodes(cookies_model, |
| 267 CookieTreeNode::DetailedInfo::TYPE_QUOTA); |
| 268 } |
| 269 |
236 // Do not call on the root. | 270 // Do not call on the root. |
237 void DeleteStoredObjects(CookieTreeNode* node) { | 271 void DeleteStoredObjects(CookieTreeNode* node) { |
238 node->DeleteStoredObjects(); | 272 node->DeleteStoredObjects(); |
239 CookieTreeNode* parent_node = node->parent(); | 273 CookieTreeNode* parent_node = node->parent(); |
240 DCHECK(parent_node); | 274 DCHECK(parent_node); |
241 delete parent_node->GetModel()->Remove(parent_node, node); | 275 delete parent_node->GetModel()->Remove(parent_node, node); |
242 } | 276 } |
243 | 277 |
244 protected: | 278 protected: |
245 MessageLoop message_loop_; | 279 MessageLoop message_loop_; |
246 BrowserThread ui_thread_; | 280 BrowserThread ui_thread_; |
247 BrowserThread io_thread_; | 281 BrowserThread io_thread_; |
248 | 282 |
249 scoped_ptr<TestingProfile> profile_; | 283 scoped_ptr<TestingProfile> profile_; |
250 scoped_refptr<MockBrowsingDataDatabaseHelper> | 284 scoped_refptr<MockBrowsingDataDatabaseHelper> |
251 mock_browsing_data_database_helper_; | 285 mock_browsing_data_database_helper_; |
252 scoped_refptr<MockBrowsingDataLocalStorageHelper> | 286 scoped_refptr<MockBrowsingDataLocalStorageHelper> |
253 mock_browsing_data_local_storage_helper_; | 287 mock_browsing_data_local_storage_helper_; |
254 scoped_refptr<MockBrowsingDataLocalStorageHelper> | 288 scoped_refptr<MockBrowsingDataLocalStorageHelper> |
255 mock_browsing_data_session_storage_helper_; | 289 mock_browsing_data_session_storage_helper_; |
256 scoped_refptr<MockBrowsingDataAppCacheHelper> | 290 scoped_refptr<MockBrowsingDataAppCacheHelper> |
257 mock_browsing_data_appcache_helper_; | 291 mock_browsing_data_appcache_helper_; |
258 scoped_refptr<MockBrowsingDataIndexedDBHelper> | 292 scoped_refptr<MockBrowsingDataIndexedDBHelper> |
259 mock_browsing_data_indexed_db_helper_; | 293 mock_browsing_data_indexed_db_helper_; |
260 scoped_refptr<MockBrowsingDataFileSystemHelper> | 294 scoped_refptr<MockBrowsingDataFileSystemHelper> |
261 mock_browsing_data_file_system_helper_; | 295 mock_browsing_data_file_system_helper_; |
| 296 scoped_refptr<MockBrowsingDataQuotaHelper> |
| 297 mock_browsing_data_quota_helper_; |
262 }; | 298 }; |
263 | 299 |
264 TEST_F(CookiesTreeModelTest, RemoveAll) { | 300 TEST_F(CookiesTreeModelTest, RemoveAll) { |
265 scoped_ptr<CookiesTreeModel> cookies_model( | 301 scoped_ptr<CookiesTreeModel> cookies_model( |
266 CreateCookiesTreeModelWithInitialSample()); | 302 CreateCookiesTreeModelWithInitialSample()); |
267 net::CookieMonster* monster = profile_->GetCookieMonster(); | 303 net::CookieMonster* monster = profile_->GetCookieMonster(); |
268 | 304 |
269 // Reset the selection of the first row. | 305 // Reset the selection of the first row. |
270 { | 306 { |
271 SCOPED_TRACE("Before removing"); | 307 SCOPED_TRACE("Before removing"); |
272 EXPECT_EQ(GetMonsterCookies(monster), | 308 EXPECT_EQ(GetMonsterCookies(monster), |
273 GetDisplayedCookies(cookies_model.get())); | 309 GetDisplayedCookies(cookies_model.get())); |
274 EXPECT_EQ("db1,db2", | 310 EXPECT_EQ("db1,db2", |
275 GetDisplayedDatabases(cookies_model.get())); | 311 GetDisplayedDatabases(cookies_model.get())); |
276 EXPECT_EQ("http://host1:1/,http://host2:2/", | 312 EXPECT_EQ("http://host1:1/,http://host2:2/", |
277 GetDisplayedLocalStorages(cookies_model.get())); | 313 GetDisplayedLocalStorages(cookies_model.get())); |
278 EXPECT_EQ("http://host1:1/,http://host2:2/", | 314 EXPECT_EQ("http://host1:1/,http://host2:2/", |
279 GetDisplayedSessionStorages(cookies_model.get())); | 315 GetDisplayedSessionStorages(cookies_model.get())); |
280 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 316 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
281 GetDisplayedIndexedDBs(cookies_model.get())); | 317 GetDisplayedIndexedDBs(cookies_model.get())); |
282 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 318 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
283 GetDisplayedFileSystems(cookies_model.get())); | 319 GetDisplayedFileSystems(cookies_model.get())); |
| 320 EXPECT_EQ("quotahost1,quotahost2", |
| 321 GetDisplayedQuotas(cookies_model.get())); |
284 } | 322 } |
285 | 323 |
286 mock_browsing_data_database_helper_->Reset(); | 324 mock_browsing_data_database_helper_->Reset(); |
287 mock_browsing_data_local_storage_helper_->Reset(); | 325 mock_browsing_data_local_storage_helper_->Reset(); |
288 mock_browsing_data_session_storage_helper_->Reset(); | 326 mock_browsing_data_session_storage_helper_->Reset(); |
289 mock_browsing_data_indexed_db_helper_->Reset(); | 327 mock_browsing_data_indexed_db_helper_->Reset(); |
290 mock_browsing_data_file_system_helper_->Reset(); | 328 mock_browsing_data_file_system_helper_->Reset(); |
291 | 329 |
292 cookies_model->DeleteAllStoredObjects(); | 330 cookies_model->DeleteAllStoredObjects(); |
293 | 331 |
(...skipping 24 matching lines...) Expand all Loading... |
318 // 2. `foo3` | 356 // 2. `foo3` |
319 // 3. `fshost1` | 357 // 3. `fshost1` |
320 // 4. `fshost2` | 358 // 4. `fshost2` |
321 // 5. `fshost3` | 359 // 5. `fshost3` |
322 // 6. `gdbhost1` | 360 // 6. `gdbhost1` |
323 // 7. `gdbhost2` | 361 // 7. `gdbhost2` |
324 // 8. `host1` | 362 // 8. `host1` |
325 // 9. `host2` | 363 // 9. `host2` |
326 // 10. `idbhost1` | 364 // 10. `idbhost1` |
327 // 11. `idbhost2` | 365 // 11. `idbhost2` |
| 366 // 12. `quotahost1` |
| 367 // 13. `quotahost2` |
328 // | 368 // |
329 // Here, we'll remove them one by one, starting from the end, and | 369 // Here, we'll remove them one by one, starting from the end, and |
330 // check that the state makes sense. | 370 // check that the state makes sense. |
331 | 371 |
| 372 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(13)); |
| 373 { |
| 374 SCOPED_TRACE("`quotahost2` removed."); |
| 375 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 376 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 377 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 378 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 379 GetDisplayedLocalStorages(cookies_model.get())); |
| 380 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 381 GetDisplayedSessionStorages(cookies_model.get())); |
| 382 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 383 GetDisplayedFileSystems(cookies_model.get())); |
| 384 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 385 GetDisplayedIndexedDBs(cookies_model.get())); |
| 386 EXPECT_EQ("quotahost1", |
| 387 GetDisplayedQuotas(cookies_model.get())); |
| 388 EXPECT_EQ(43, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 389 } |
| 390 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(12)); |
| 391 { |
| 392 SCOPED_TRACE("`quotahost1` removed."); |
| 393 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 394 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 395 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 396 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 397 GetDisplayedLocalStorages(cookies_model.get())); |
| 398 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 399 GetDisplayedSessionStorages(cookies_model.get())); |
| 400 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 401 GetDisplayedFileSystems(cookies_model.get())); |
| 402 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 403 GetDisplayedIndexedDBs(cookies_model.get())); |
| 404 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 405 } |
332 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(11)); | 406 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(11)); |
333 { | 407 { |
334 SCOPED_TRACE("`idbhost2` removed."); | 408 SCOPED_TRACE("`idbhost2` removed."); |
335 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | 409 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
336 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 410 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
337 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 411 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
338 EXPECT_EQ("http://host1:1/,http://host2:2/", | 412 EXPECT_EQ("http://host1:1/,http://host2:2/", |
339 GetDisplayedLocalStorages(cookies_model.get())); | 413 GetDisplayedLocalStorages(cookies_model.get())); |
340 EXPECT_EQ("http://host1:1/,http://host2:2/", | 414 EXPECT_EQ("http://host1:1/,http://host2:2/", |
341 GetDisplayedSessionStorages(cookies_model.get())); | 415 GetDisplayedSessionStorages(cookies_model.get())); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { | 567 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { |
494 scoped_ptr<CookiesTreeModel> cookies_model( | 568 scoped_ptr<CookiesTreeModel> cookies_model( |
495 CreateCookiesTreeModelWithInitialSample()); | 569 CreateCookiesTreeModelWithInitialSample()); |
496 net::CookieMonster* monster = profile_->GetCookieMonster(); | 570 net::CookieMonster* monster = profile_->GetCookieMonster(); |
497 | 571 |
498 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); | 572 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); |
499 { | 573 { |
500 SCOPED_TRACE("First origin removed"); | 574 SCOPED_TRACE("First origin removed"); |
501 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 575 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); |
502 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 576 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
503 // 39 because in this case, the origin remains, although the COOKIES | 577 // 43 because in this case, the origin remains, although the COOKIES |
504 // node beneath it has been deleted. So, we have | 578 // node beneath it has been deleted. So, we have |
505 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 579 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c |
506 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 580 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
507 // fshost1 -> filesystem -> http://fshost1:1/, | 581 // fshost1 -> filesystem -> http://fshost1:1/, |
508 // fshost2 -> filesystem -> http://fshost2:1/, | 582 // fshost2 -> filesystem -> http://fshost2:1/, |
509 // fshost3 -> filesystem -> http://fshost3:1/, | 583 // fshost3 -> filesystem -> http://fshost3:1/, |
510 // host1 -> localstorage -> http://host1:1/, | 584 // host1 -> localstorage -> http://host1:1/, |
511 // host2 -> localstorage -> http://host2:2/, | 585 // host2 -> localstorage -> http://host2:2/, |
512 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 586 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
513 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 587 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
514 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); | 588 // quotahost1 -> quotahost1, |
| 589 // quotahost2 -> quotahost1. |
| 590 EXPECT_EQ(43, cookies_model->GetRoot()->GetTotalNodeCount()); |
515 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 591 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
516 EXPECT_EQ("http://host1:1/,http://host2:2/", | 592 EXPECT_EQ("http://host1:1/,http://host2:2/", |
517 GetDisplayedLocalStorages(cookies_model.get())); | 593 GetDisplayedLocalStorages(cookies_model.get())); |
518 EXPECT_EQ("http://host1:1/,http://host2:2/", | 594 EXPECT_EQ("http://host1:1/,http://host2:2/", |
519 GetDisplayedSessionStorages(cookies_model.get())); | 595 GetDisplayedSessionStorages(cookies_model.get())); |
520 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 596 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
521 GetDisplayedIndexedDBs(cookies_model.get())); | 597 GetDisplayedIndexedDBs(cookies_model.get())); |
522 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 598 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
523 GetDisplayedFileSystems(cookies_model.get())); | 599 GetDisplayedFileSystems(cookies_model.get())); |
| 600 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
524 } | 601 } |
525 | 602 |
526 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 603 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
527 { | 604 { |
528 SCOPED_TRACE("First database removed"); | 605 SCOPED_TRACE("First database removed"); |
529 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 606 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); |
530 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 607 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
531 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 608 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
532 EXPECT_EQ("http://host1:1/,http://host2:2/", | 609 EXPECT_EQ("http://host1:1/,http://host2:2/", |
533 GetDisplayedLocalStorages(cookies_model.get())); | 610 GetDisplayedLocalStorages(cookies_model.get())); |
534 EXPECT_EQ("http://host1:1/,http://host2:2/", | 611 EXPECT_EQ("http://host1:1/,http://host2:2/", |
535 GetDisplayedSessionStorages(cookies_model.get())); | 612 GetDisplayedSessionStorages(cookies_model.get())); |
536 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 613 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
537 GetDisplayedIndexedDBs(cookies_model.get())); | 614 GetDisplayedIndexedDBs(cookies_model.get())); |
538 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 615 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
539 GetDisplayedFileSystems(cookies_model.get())); | 616 GetDisplayedFileSystems(cookies_model.get())); |
540 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); | 617 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 618 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); |
541 } | 619 } |
542 | 620 |
543 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 621 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
544 { | 622 { |
545 SCOPED_TRACE("First origin removed"); | 623 SCOPED_TRACE("First origin removed"); |
546 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 624 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); |
547 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 625 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
548 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 626 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
549 EXPECT_EQ("http://host2:2/", | 627 EXPECT_EQ("http://host2:2/", |
550 GetDisplayedLocalStorages(cookies_model.get())); | 628 GetDisplayedLocalStorages(cookies_model.get())); |
551 EXPECT_EQ("http://host1:1/,http://host2:2/", | 629 EXPECT_EQ("http://host1:1/,http://host2:2/", |
552 GetDisplayedSessionStorages(cookies_model.get())); | 630 GetDisplayedSessionStorages(cookies_model.get())); |
553 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 631 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
554 GetDisplayedIndexedDBs(cookies_model.get())); | 632 GetDisplayedIndexedDBs(cookies_model.get())); |
555 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 633 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
556 GetDisplayedFileSystems(cookies_model.get())); | 634 GetDisplayedFileSystems(cookies_model.get())); |
557 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); | 635 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 636 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); |
558 } | 637 } |
559 } | 638 } |
560 | 639 |
561 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { | 640 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { |
562 scoped_ptr<CookiesTreeModel> cookies_model( | 641 scoped_ptr<CookiesTreeModel> cookies_model( |
563 CreateCookiesTreeModelWithInitialSample()); | 642 CreateCookiesTreeModelWithInitialSample()); |
564 net::CookieMonster* monster = profile_->GetCookieMonster(); | 643 net::CookieMonster* monster = profile_->GetCookieMonster(); |
565 | 644 |
566 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); | 645 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); |
567 { | 646 { |
568 SCOPED_TRACE("Second origin COOKIES node removed"); | 647 SCOPED_TRACE("Second origin COOKIES node removed"); |
569 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 648 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
570 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 649 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
571 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 650 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
572 EXPECT_EQ("http://host1:1/,http://host2:2/", | 651 EXPECT_EQ("http://host1:1/,http://host2:2/", |
573 GetDisplayedLocalStorages(cookies_model.get())); | 652 GetDisplayedLocalStorages(cookies_model.get())); |
574 EXPECT_EQ("http://host1:1/,http://host2:2/", | 653 EXPECT_EQ("http://host1:1/,http://host2:2/", |
575 GetDisplayedSessionStorages(cookies_model.get())); | 654 GetDisplayedSessionStorages(cookies_model.get())); |
576 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 655 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
577 GetDisplayedIndexedDBs(cookies_model.get())); | 656 GetDisplayedIndexedDBs(cookies_model.get())); |
578 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 657 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
579 GetDisplayedFileSystems(cookies_model.get())); | 658 GetDisplayedFileSystems(cookies_model.get())); |
580 // 39 because in this case, the origin remains, although the COOKIES | 659 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 660 // 43 because in this case, the origin remains, although the COOKIES |
581 // node beneath it has been deleted. So, we have | 661 // node beneath it has been deleted. So, we have |
582 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 662 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c |
583 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 663 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
584 // fshost1 -> filesystem -> http://fshost1:1/, | 664 // fshost1 -> filesystem -> http://fshost1:1/, |
585 // fshost2 -> filesystem -> http://fshost2:1/, | 665 // fshost2 -> filesystem -> http://fshost2:1/, |
586 // fshost3 -> filesystem -> http://fshost3:1/, | 666 // fshost3 -> filesystem -> http://fshost3:1/, |
587 // host1 -> localstorage -> http://host1:1/, | 667 // host1 -> localstorage -> http://host1:1/, |
588 // host2 -> localstorage -> http://host2:2/, | 668 // host2 -> localstorage -> http://host2:2/, |
589 // host1 -> sessionstorage -> http://host1:1/, | 669 // host1 -> sessionstorage -> http://host1:1/, |
590 // host2 -> sessionstorage -> http://host2:2/, | 670 // host2 -> sessionstorage -> http://host2:2/, |
591 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 671 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
592 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 672 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
593 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); | 673 // quotahost1 -> quotahost1, |
| 674 // quotahost2 -> quotahost2. |
| 675 EXPECT_EQ(43, cookies_model->GetRoot()->GetTotalNodeCount()); |
594 } | 676 } |
595 | 677 |
596 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 678 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
597 { | 679 { |
598 SCOPED_TRACE("First database removed"); | 680 SCOPED_TRACE("First database removed"); |
599 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 681 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
600 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 682 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
601 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 683 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
602 EXPECT_EQ("http://host1:1/,http://host2:2/", | 684 EXPECT_EQ("http://host1:1/,http://host2:2/", |
603 GetDisplayedLocalStorages(cookies_model.get())); | 685 GetDisplayedLocalStorages(cookies_model.get())); |
604 EXPECT_EQ("http://host1:1/,http://host2:2/", | 686 EXPECT_EQ("http://host1:1/,http://host2:2/", |
605 GetDisplayedSessionStorages(cookies_model.get())); | 687 GetDisplayedSessionStorages(cookies_model.get())); |
606 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 688 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
607 GetDisplayedIndexedDBs(cookies_model.get())); | 689 GetDisplayedIndexedDBs(cookies_model.get())); |
608 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 690 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
609 GetDisplayedFileSystems(cookies_model.get())); | 691 GetDisplayedFileSystems(cookies_model.get())); |
610 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); | 692 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 693 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); |
611 } | 694 } |
612 | 695 |
613 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 696 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
614 { | 697 { |
615 SCOPED_TRACE("First origin removed"); | 698 SCOPED_TRACE("First origin removed"); |
616 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 699 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
617 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 700 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
618 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 701 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
619 EXPECT_EQ("http://host2:2/", | 702 EXPECT_EQ("http://host2:2/", |
620 GetDisplayedLocalStorages(cookies_model.get())); | 703 GetDisplayedLocalStorages(cookies_model.get())); |
621 EXPECT_EQ("http://host1:1/,http://host2:2/", | 704 EXPECT_EQ("http://host1:1/,http://host2:2/", |
622 GetDisplayedSessionStorages(cookies_model.get())); | 705 GetDisplayedSessionStorages(cookies_model.get())); |
623 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 706 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
624 GetDisplayedIndexedDBs(cookies_model.get())); | 707 GetDisplayedIndexedDBs(cookies_model.get())); |
625 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 708 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
626 GetDisplayedFileSystems(cookies_model.get())); | 709 GetDisplayedFileSystems(cookies_model.get())); |
627 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); | 710 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 711 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); |
628 } | 712 } |
629 } | 713 } |
630 | 714 |
631 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { | 715 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { |
632 net::CookieMonster* monster = profile_->GetCookieMonster(); | 716 net::CookieMonster* monster = profile_->GetCookieMonster(); |
633 monster->SetCookie(GURL("http://foo1"), "A=1"); | 717 monster->SetCookie(GURL("http://foo1"), "A=1"); |
634 monster->SetCookie(GURL("http://foo2"), "B=1"); | 718 monster->SetCookie(GURL("http://foo2"), "B=1"); |
635 monster->SetCookie(GURL("http://foo3"), "C=1"); | 719 monster->SetCookie(GURL("http://foo3"), "C=1"); |
636 monster->SetCookie(GURL("http://foo3"), "D=1"); | 720 monster->SetCookie(GURL("http://foo3"), "D=1"); |
637 CookiesTreeModel cookies_model(monster, | 721 CookiesTreeModel cookies_model(monster, |
638 mock_browsing_data_database_helper_, | 722 mock_browsing_data_database_helper_, |
639 mock_browsing_data_local_storage_helper_, | 723 mock_browsing_data_local_storage_helper_, |
640 mock_browsing_data_session_storage_helper_, | 724 mock_browsing_data_session_storage_helper_, |
641 mock_browsing_data_appcache_helper_, | 725 mock_browsing_data_appcache_helper_, |
642 mock_browsing_data_indexed_db_helper_, | 726 mock_browsing_data_indexed_db_helper_, |
643 mock_browsing_data_file_system_helper_, | 727 mock_browsing_data_file_system_helper_, |
| 728 mock_browsing_data_quota_helper_, |
644 false); | 729 false); |
645 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 730 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
646 mock_browsing_data_database_helper_->Notify(); | 731 mock_browsing_data_database_helper_->Notify(); |
647 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 732 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
648 mock_browsing_data_local_storage_helper_->Notify(); | 733 mock_browsing_data_local_storage_helper_->Notify(); |
649 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 734 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
650 mock_browsing_data_session_storage_helper_->Notify(); | 735 mock_browsing_data_session_storage_helper_->Notify(); |
651 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 736 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
652 mock_browsing_data_indexed_db_helper_->Notify(); | 737 mock_browsing_data_indexed_db_helper_->Notify(); |
653 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 738 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
654 mock_browsing_data_file_system_helper_->Notify(); | 739 mock_browsing_data_file_system_helper_->Notify(); |
| 740 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
| 741 mock_browsing_data_quota_helper_->Notify(); |
655 | 742 |
656 { | 743 { |
657 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " | 744 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " |
658 "2 session storages, 2 indexed DBs, 3 file systems"); | 745 "2 session storages, 2 indexed DBs, 3 file systems, " |
| 746 "2 quotas."); |
659 // 42 because there's the root, then foo1 -> cookies -> a, | 747 // 42 because there's the root, then foo1 -> cookies -> a, |
660 // foo2 -> cookies -> b, foo3 -> cookies -> c,d | 748 // foo2 -> cookies -> b, foo3 -> cookies -> c,d |
661 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 749 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
662 // fshost1 -> filesystem -> http://fshost1:1/, | 750 // fshost1 -> filesystem -> http://fshost1:1/, |
663 // fshost2 -> filesystem -> http://fshost2:1/, | 751 // fshost2 -> filesystem -> http://fshost2:1/, |
664 // fshost3 -> filesystem -> http://fshost3:1/, | 752 // fshost3 -> filesystem -> http://fshost3:1/, |
665 // host1 -> localstorage -> http://host1:1/, | 753 // host1 -> localstorage -> http://host1:1/, |
666 // host1 -> sessionstorage -> http://host1:1/, | 754 // host1 -> sessionstorage -> http://host1:1/, |
667 // host2 -> sessionstorage -> http://host2:2/, | 755 // host2 -> sessionstorage -> http://host2:2/, |
668 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 756 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
669 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 757 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
670 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); | 758 // quotahost1 -> quotahost1, |
| 759 // quotahost2 -> quotahost2. |
| 760 EXPECT_EQ(46, cookies_model.GetRoot()->GetTotalNodeCount()); |
671 EXPECT_STREQ("A,B,C,D", GetMonsterCookies(monster).c_str()); | 761 EXPECT_STREQ("A,B,C,D", GetMonsterCookies(monster).c_str()); |
672 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); | 762 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); |
673 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 763 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
674 EXPECT_EQ("http://host1:1/,http://host2:2/", | 764 EXPECT_EQ("http://host1:1/,http://host2:2/", |
675 GetDisplayedLocalStorages(&cookies_model)); | 765 GetDisplayedLocalStorages(&cookies_model)); |
676 EXPECT_EQ("http://host1:1/,http://host2:2/", | 766 EXPECT_EQ("http://host1:1/,http://host2:2/", |
677 GetDisplayedSessionStorages(&cookies_model)); | 767 GetDisplayedSessionStorages(&cookies_model)); |
678 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 768 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
679 GetDisplayedIndexedDBs(&cookies_model)); | 769 GetDisplayedIndexedDBs(&cookies_model)); |
680 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 770 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
681 GetDisplayedFileSystems(&cookies_model)); | 771 GetDisplayedFileSystems(&cookies_model)); |
| 772 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
682 } | 773 } |
683 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); | 774 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); |
684 { | 775 { |
685 SCOPED_TRACE("Third origin removed"); | 776 SCOPED_TRACE("Third origin removed"); |
686 EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); | 777 EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); |
687 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); | 778 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); |
688 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 779 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
689 EXPECT_EQ("http://host1:1/,http://host2:2/", | 780 EXPECT_EQ("http://host1:1/,http://host2:2/", |
690 GetDisplayedLocalStorages(&cookies_model)); | 781 GetDisplayedLocalStorages(&cookies_model)); |
691 EXPECT_EQ("http://host1:1/,http://host2:2/", | 782 EXPECT_EQ("http://host1:1/,http://host2:2/", |
692 GetDisplayedSessionStorages(&cookies_model)); | 783 GetDisplayedSessionStorages(&cookies_model)); |
693 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 784 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
694 GetDisplayedIndexedDBs(&cookies_model)); | 785 GetDisplayedIndexedDBs(&cookies_model)); |
695 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 786 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
696 GetDisplayedFileSystems(&cookies_model)); | 787 GetDisplayedFileSystems(&cookies_model)); |
697 EXPECT_EQ(38, cookies_model.GetRoot()->GetTotalNodeCount()); | 788 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
| 789 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); |
698 } | 790 } |
699 } | 791 } |
700 | 792 |
701 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { | 793 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { |
702 net::CookieMonster* monster = profile_->GetCookieMonster(); | 794 net::CookieMonster* monster = profile_->GetCookieMonster(); |
703 monster->SetCookie(GURL("http://foo1"), "A=1"); | 795 monster->SetCookie(GURL("http://foo1"), "A=1"); |
704 monster->SetCookie(GURL("http://foo2"), "B=1"); | 796 monster->SetCookie(GURL("http://foo2"), "B=1"); |
705 monster->SetCookie(GURL("http://foo3"), "C=1"); | 797 monster->SetCookie(GURL("http://foo3"), "C=1"); |
706 monster->SetCookie(GURL("http://foo3"), "D=1"); | 798 monster->SetCookie(GURL("http://foo3"), "D=1"); |
707 monster->SetCookie(GURL("http://foo3"), "E=1"); | 799 monster->SetCookie(GURL("http://foo3"), "E=1"); |
708 CookiesTreeModel cookies_model(monster, | 800 CookiesTreeModel cookies_model(monster, |
709 mock_browsing_data_database_helper_, | 801 mock_browsing_data_database_helper_, |
710 mock_browsing_data_local_storage_helper_, | 802 mock_browsing_data_local_storage_helper_, |
711 mock_browsing_data_session_storage_helper_, | 803 mock_browsing_data_session_storage_helper_, |
712 mock_browsing_data_appcache_helper_, | 804 mock_browsing_data_appcache_helper_, |
713 mock_browsing_data_indexed_db_helper_, | 805 mock_browsing_data_indexed_db_helper_, |
714 mock_browsing_data_file_system_helper_, | 806 mock_browsing_data_file_system_helper_, |
| 807 mock_browsing_data_quota_helper_, |
715 false); | 808 false); |
716 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 809 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
717 mock_browsing_data_database_helper_->Notify(); | 810 mock_browsing_data_database_helper_->Notify(); |
718 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 811 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
719 mock_browsing_data_local_storage_helper_->Notify(); | 812 mock_browsing_data_local_storage_helper_->Notify(); |
720 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 813 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
721 mock_browsing_data_session_storage_helper_->Notify(); | 814 mock_browsing_data_session_storage_helper_->Notify(); |
722 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 815 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
723 mock_browsing_data_indexed_db_helper_->Notify(); | 816 mock_browsing_data_indexed_db_helper_->Notify(); |
724 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 817 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
725 mock_browsing_data_file_system_helper_->Notify(); | 818 mock_browsing_data_file_system_helper_->Notify(); |
| 819 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
| 820 mock_browsing_data_quota_helper_->Notify(); |
726 | 821 |
727 { | 822 { |
728 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " | 823 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " |
729 "2 session storages, 2 indexed DBs"); | 824 "2 session storages, 2 indexed DBs, 3 filesystems, " |
| 825 "2 quotas."); |
730 // 43 because there's the root, then foo1 -> cookies -> a, | 826 // 43 because there's the root, then foo1 -> cookies -> a, |
731 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 827 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
732 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 828 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
733 // fshost1 -> filesystem -> http://fshost1:1/, | 829 // fshost1 -> filesystem -> http://fshost1:1/, |
734 // fshost2 -> filesystem -> http://fshost2:1/, | 830 // fshost2 -> filesystem -> http://fshost2:1/, |
735 // fshost3 -> filesystem -> http://fshost3:1/, | 831 // fshost3 -> filesystem -> http://fshost3:1/, |
736 // host1 -> localstorage -> http://host1:1/, | 832 // host1 -> localstorage -> http://host1:1/, |
737 // host2 -> localstorage -> http://host2:2/, | 833 // host2 -> localstorage -> http://host2:2/, |
738 // host1 -> sessionstorage -> http://host1:1/, | 834 // host1 -> sessionstorage -> http://host1:1/, |
739 // host2 -> sessionstorage -> http://host2:2/, | 835 // host2 -> sessionstorage -> http://host2:2/, |
740 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 836 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
741 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 837 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
742 EXPECT_EQ(43, cookies_model.GetRoot()->GetTotalNodeCount()); | 838 // quotahost1 -> quotahost1, |
| 839 // quotahost2 -> quotahost2. |
| 840 EXPECT_EQ(47, cookies_model.GetRoot()->GetTotalNodeCount()); |
743 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); | 841 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); |
744 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 842 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
745 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 843 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
746 EXPECT_EQ("http://host1:1/,http://host2:2/", | 844 EXPECT_EQ("http://host1:1/,http://host2:2/", |
747 GetDisplayedLocalStorages(&cookies_model)); | 845 GetDisplayedLocalStorages(&cookies_model)); |
748 EXPECT_EQ("http://host1:1/,http://host2:2/", | 846 EXPECT_EQ("http://host1:1/,http://host2:2/", |
749 GetDisplayedSessionStorages(&cookies_model)); | 847 GetDisplayedSessionStorages(&cookies_model)); |
750 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 848 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
751 GetDisplayedIndexedDBs(&cookies_model)); | 849 GetDisplayedIndexedDBs(&cookies_model)); |
752 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 850 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
753 GetDisplayedFileSystems(&cookies_model)); | 851 GetDisplayedFileSystems(&cookies_model)); |
| 852 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
754 } | 853 } |
755 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> | 854 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> |
756 GetChild(1)); | 855 GetChild(1)); |
757 { | 856 { |
758 SCOPED_TRACE("Middle cookie in third origin removed"); | 857 SCOPED_TRACE("Middle cookie in third origin removed"); |
759 EXPECT_STREQ("A,B,C,E", GetMonsterCookies(monster).c_str()); | 858 EXPECT_STREQ("A,B,C,E", GetMonsterCookies(monster).c_str()); |
760 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); | 859 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); |
761 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); | 860 EXPECT_EQ(46, cookies_model.GetRoot()->GetTotalNodeCount()); |
762 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 861 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
763 EXPECT_EQ("http://host1:1/,http://host2:2/", | 862 EXPECT_EQ("http://host1:1/,http://host2:2/", |
764 GetDisplayedLocalStorages(&cookies_model)); | 863 GetDisplayedLocalStorages(&cookies_model)); |
765 EXPECT_EQ("http://host1:1/,http://host2:2/", | 864 EXPECT_EQ("http://host1:1/,http://host2:2/", |
766 GetDisplayedSessionStorages(&cookies_model)); | 865 GetDisplayedSessionStorages(&cookies_model)); |
767 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 866 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
768 GetDisplayedIndexedDBs(&cookies_model)); | 867 GetDisplayedIndexedDBs(&cookies_model)); |
769 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 868 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
770 GetDisplayedFileSystems(&cookies_model)); | 869 GetDisplayedFileSystems(&cookies_model)); |
| 870 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
771 } | 871 } |
772 } | 872 } |
773 | 873 |
774 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { | 874 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { |
775 net::CookieMonster* monster = profile_->GetCookieMonster(); | 875 net::CookieMonster* monster = profile_->GetCookieMonster(); |
776 monster->SetCookie(GURL("http://foo1"), "A=1"); | 876 monster->SetCookie(GURL("http://foo1"), "A=1"); |
777 monster->SetCookie(GURL("http://foo2"), "B=1"); | 877 monster->SetCookie(GURL("http://foo2"), "B=1"); |
778 monster->SetCookie(GURL("http://foo3"), "C=1"); | 878 monster->SetCookie(GURL("http://foo3"), "C=1"); |
779 monster->SetCookie(GURL("http://foo3"), "D=1"); | 879 monster->SetCookie(GURL("http://foo3"), "D=1"); |
780 monster->SetCookie(GURL("http://foo3"), "E=1"); | 880 monster->SetCookie(GURL("http://foo3"), "E=1"); |
781 CookiesTreeModel cookies_model(monster, | 881 CookiesTreeModel cookies_model(monster, |
782 mock_browsing_data_database_helper_, | 882 mock_browsing_data_database_helper_, |
783 mock_browsing_data_local_storage_helper_, | 883 mock_browsing_data_local_storage_helper_, |
784 mock_browsing_data_session_storage_helper_, | 884 mock_browsing_data_session_storage_helper_, |
785 mock_browsing_data_appcache_helper_, | 885 mock_browsing_data_appcache_helper_, |
786 mock_browsing_data_indexed_db_helper_, | 886 mock_browsing_data_indexed_db_helper_, |
787 mock_browsing_data_file_system_helper_, | 887 mock_browsing_data_file_system_helper_, |
| 888 mock_browsing_data_quota_helper_, |
788 false); | 889 false); |
789 { | 890 { |
790 SCOPED_TRACE("Initial State 5 cookies"); | 891 SCOPED_TRACE("Initial State 5 cookies"); |
791 // 11 because there's the root, then foo1 -> cookies -> a, | 892 // 11 because there's the root, then foo1 -> cookies -> a, |
792 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 893 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
793 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); | 894 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); |
794 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); | 895 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); |
795 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 896 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
796 } | 897 } |
797 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); | 898 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); |
(...skipping 18 matching lines...) Expand all Loading... |
816 monster->SetCookie(GURL("http://foo3.com"), "G=1"); | 917 monster->SetCookie(GURL("http://foo3.com"), "G=1"); |
817 monster->SetCookie(GURL("http://foo4.com"), "H=1"); | 918 monster->SetCookie(GURL("http://foo4.com"), "H=1"); |
818 | 919 |
819 CookiesTreeModel cookies_model(monster, | 920 CookiesTreeModel cookies_model(monster, |
820 new MockBrowsingDataDatabaseHelper(profile_.get()), | 921 new MockBrowsingDataDatabaseHelper(profile_.get()), |
821 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 922 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
822 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 923 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
823 new MockBrowsingDataAppCacheHelper(profile_.get()), | 924 new MockBrowsingDataAppCacheHelper(profile_.get()), |
824 new MockBrowsingDataIndexedDBHelper(profile_.get()), | 925 new MockBrowsingDataIndexedDBHelper(profile_.get()), |
825 new MockBrowsingDataFileSystemHelper(profile_.get()), | 926 new MockBrowsingDataFileSystemHelper(profile_.get()), |
| 927 new MockBrowsingDataQuotaHelper(profile_.get()), |
826 false); | 928 false); |
827 | 929 |
828 { | 930 { |
829 SCOPED_TRACE("Initial State 8 cookies"); | 931 SCOPED_TRACE("Initial State 8 cookies"); |
830 // CookieMonster orders cookies by pathlength, then by creation time. | 932 // CookieMonster orders cookies by pathlength, then by creation time. |
831 // All paths are length 1. | 933 // All paths are length 1. |
832 EXPECT_STREQ("A,B,C,D,E,F,G,H", GetMonsterCookies(monster).c_str()); | 934 EXPECT_STREQ("A,B,C,D,E,F,G,H", GetMonsterCookies(monster).c_str()); |
833 EXPECT_STREQ("F,E,C,B,A,G,D,H", | 935 EXPECT_STREQ("F,E,C,B,A,G,D,H", |
834 GetDisplayedCookies(&cookies_model).c_str()); | 936 GetDisplayedCookies(&cookies_model).c_str()); |
835 } | 937 } |
836 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E" | 938 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E" |
837 { | 939 { |
838 EXPECT_STREQ("A,B,C,D,F,G,H", GetMonsterCookies(monster).c_str()); | 940 EXPECT_STREQ("A,B,C,D,F,G,H", GetMonsterCookies(monster).c_str()); |
839 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); | 941 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); |
840 } | 942 } |
841 } | 943 } |
842 | 944 |
843 TEST_F(CookiesTreeModelTest, ContentSettings) { | 945 TEST_F(CookiesTreeModelTest, ContentSettings) { |
844 GURL host("http://example.com/"); | 946 GURL host("http://example.com/"); |
845 net::CookieMonster* monster = profile_->GetCookieMonster(); | 947 net::CookieMonster* monster = profile_->GetCookieMonster(); |
846 monster->SetCookie(host, "A=1"); | 948 monster->SetCookie(host, "A=1"); |
847 | 949 |
848 CookiesTreeModel cookies_model(monster, | 950 CookiesTreeModel cookies_model(monster, |
849 new MockBrowsingDataDatabaseHelper(profile_.get()), | 951 new MockBrowsingDataDatabaseHelper(profile_.get()), |
850 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 952 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
851 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 953 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
852 new MockBrowsingDataAppCacheHelper(profile_.get()), | 954 new MockBrowsingDataAppCacheHelper(profile_.get()), |
853 new MockBrowsingDataIndexedDBHelper(profile_.get()), | 955 new MockBrowsingDataIndexedDBHelper(profile_.get()), |
854 new MockBrowsingDataFileSystemHelper(profile_.get()), | 956 new MockBrowsingDataFileSystemHelper(profile_.get()), |
| 957 new MockBrowsingDataQuotaHelper(profile_.get()), |
855 false); | 958 false); |
856 | 959 |
857 TestingProfile profile; | 960 TestingProfile profile; |
858 HostContentSettingsMap* content_settings = | 961 HostContentSettingsMap* content_settings = |
859 profile.GetHostContentSettingsMap(); | 962 profile.GetHostContentSettingsMap(); |
860 MockSettingsObserver observer; | 963 MockSettingsObserver observer; |
861 | 964 |
862 CookieTreeRootNode* root = | 965 CookieTreeRootNode* root = |
863 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); | 966 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); |
864 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); | 967 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 cookies_model->UpdateSearchResults(std::wstring(L"fshost3")); | 1004 cookies_model->UpdateSearchResults(std::wstring(L"fshost3")); |
902 EXPECT_EQ("http://fshost3:3/", | 1005 EXPECT_EQ("http://fshost3:3/", |
903 GetDisplayedFileSystems(cookies_model.get())); | 1006 GetDisplayedFileSystems(cookies_model.get())); |
904 | 1007 |
905 cookies_model->UpdateSearchResults(std::wstring()); | 1008 cookies_model->UpdateSearchResults(std::wstring()); |
906 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 1009 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
907 GetDisplayedFileSystems(cookies_model.get())); | 1010 GetDisplayedFileSystems(cookies_model.get())); |
908 } | 1011 } |
909 | 1012 |
910 } // namespace | 1013 } // namespace |
OLD | NEW |