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