| 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_cookie_helper.h" |
| 12 #include "chrome/browser/mock_browsing_data_database_helper.h" | 13 #include "chrome/browser/mock_browsing_data_database_helper.h" |
| 13 #include "chrome/browser/mock_browsing_data_file_system_helper.h" | 14 #include "chrome/browser/mock_browsing_data_file_system_helper.h" |
| 14 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" | 15 #include "chrome/browser/mock_browsing_data_indexed_db_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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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() { |
| 40 profile_.reset(new TestingProfile()); | 41 profile_.reset(new TestingProfile()); |
| 41 profile_->CreateRequestContext(); | 42 profile_->CreateRequestContext(); |
| 43 mock_browsing_data_cookie_helper_ = |
| 44 new MockBrowsingDataCookieHelper(profile_.get()); |
| 42 mock_browsing_data_database_helper_ = | 45 mock_browsing_data_database_helper_ = |
| 43 new MockBrowsingDataDatabaseHelper(profile_.get()); | 46 new MockBrowsingDataDatabaseHelper(profile_.get()); |
| 44 mock_browsing_data_local_storage_helper_ = | 47 mock_browsing_data_local_storage_helper_ = |
| 45 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 48 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
| 46 mock_browsing_data_session_storage_helper_ = | 49 mock_browsing_data_session_storage_helper_ = |
| 47 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 50 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
| 48 mock_browsing_data_appcache_helper_ = | 51 mock_browsing_data_appcache_helper_ = |
| 49 new MockBrowsingDataAppCacheHelper(profile_.get()); | 52 new MockBrowsingDataAppCacheHelper(profile_.get()); |
| 50 mock_browsing_data_indexed_db_helper_ = | 53 mock_browsing_data_indexed_db_helper_ = |
| 51 new MockBrowsingDataIndexedDBHelper(profile_.get()); | 54 new MockBrowsingDataIndexedDBHelper(profile_.get()); |
| 52 mock_browsing_data_file_system_helper_ = | 55 mock_browsing_data_file_system_helper_ = |
| 53 new MockBrowsingDataFileSystemHelper(profile_.get()); | 56 new MockBrowsingDataFileSystemHelper(profile_.get()); |
| 54 } | 57 } |
| 55 | 58 |
| 56 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { | 59 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { |
| 57 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 58 monster->SetCookie(GURL("http://foo1"), "A=1"); | |
| 59 monster->SetCookie(GURL("http://foo2"), "B=1"); | |
| 60 monster->SetCookie(GURL("http://foo3"), "C=1"); | |
| 61 CookiesTreeModel* cookies_model = new CookiesTreeModel( | 60 CookiesTreeModel* cookies_model = new CookiesTreeModel( |
| 62 monster, mock_browsing_data_database_helper_, | 61 mock_browsing_data_cookie_helper_, |
| 62 mock_browsing_data_database_helper_, |
| 63 mock_browsing_data_local_storage_helper_, | 63 mock_browsing_data_local_storage_helper_, |
| 64 mock_browsing_data_session_storage_helper_, | 64 mock_browsing_data_session_storage_helper_, |
| 65 mock_browsing_data_appcache_helper_, | 65 mock_browsing_data_appcache_helper_, |
| 66 mock_browsing_data_indexed_db_helper_, | 66 mock_browsing_data_indexed_db_helper_, |
| 67 mock_browsing_data_file_system_helper_, | 67 mock_browsing_data_file_system_helper_, |
| 68 false); | 68 false); |
| 69 mock_browsing_data_cookie_helper_-> |
| 70 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 71 mock_browsing_data_cookie_helper_-> |
| 72 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 73 mock_browsing_data_cookie_helper_-> |
| 74 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 75 mock_browsing_data_cookie_helper_->Notify(); |
| 69 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 76 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 70 mock_browsing_data_database_helper_->Notify(); | 77 mock_browsing_data_database_helper_->Notify(); |
| 71 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 78 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 72 mock_browsing_data_local_storage_helper_->Notify(); | 79 mock_browsing_data_local_storage_helper_->Notify(); |
| 73 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 80 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 74 mock_browsing_data_session_storage_helper_->Notify(); | 81 mock_browsing_data_session_storage_helper_->Notify(); |
| 75 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 82 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 76 mock_browsing_data_indexed_db_helper_->Notify(); | 83 mock_browsing_data_indexed_db_helper_->Notify(); |
| 77 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 84 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 78 mock_browsing_data_file_system_helper_->Notify(); | 85 mock_browsing_data_file_system_helper_->Notify(); |
| 79 { | 86 { |
| 80 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " | 87 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " |
| 81 "2 session storages, 2 indexed DBs, 3 filesystems"); | 88 "2 session storages, 2 indexed DBs, 3 filesystems"); |
| 82 // 41 because there's the root, then foo1 -> cookies -> a, | 89 // 41 because there's the root, then foo1 -> cookies -> a, |
| 83 // foo2 -> cookies -> b, foo3 -> cookies -> c, | 90 // foo2 -> cookies -> b, foo3 -> cookies -> c, |
| 84 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 91 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 85 // fshost1 -> filesystem -> http://fshost1:1/, | 92 // fshost1 -> filesystem -> http://fshost1:1/, |
| 86 // fshost2 -> filesystem -> http://fshost2:1/, | 93 // fshost2 -> filesystem -> http://fshost2:1/, |
| 87 // fshost3 -> filesystem -> http://fshost3:1/, | 94 // fshost3 -> filesystem -> http://fshost3:1/, |
| 88 // host1 -> localstorage -> http://host1:1/, | 95 // host1 -> localstorage -> http://host1:1/, |
| 89 // host2 -> localstorage -> http://host2:2/. | 96 // host2 -> localstorage -> http://host2:2/. |
| 90 // host1 -> sessionstorage -> http://host1:1/, | 97 // host1 -> sessionstorage -> http://host1:1/, |
| 91 // host2 -> sessionstorage -> http://host2:2/, | 98 // host2 -> sessionstorage -> http://host2:2/, |
| 92 // idbhost1 -> indexeddb -> http://idbhost1:1/, | 99 // idbhost1 -> indexeddb -> http://idbhost1:1/, |
| 93 // idbhost2 -> indexeddb -> http://idbhost2:2/. | 100 // idbhost2 -> indexeddb -> http://idbhost2:2/. |
| 94 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); | 101 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 102 EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model)); |
| 95 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); | 103 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); |
| 96 EXPECT_EQ("http://host1:1/,http://host2:2/", | 104 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 97 GetDisplayedLocalStorages(cookies_model)); | 105 GetDisplayedLocalStorages(cookies_model)); |
| 98 EXPECT_EQ("http://host1:1/,http://host2:2/", | 106 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 99 GetDisplayedSessionStorages(cookies_model)); | 107 GetDisplayedSessionStorages(cookies_model)); |
| 100 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 108 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 101 GetDisplayedIndexedDBs(cookies_model)); | 109 GetDisplayedIndexedDBs(cookies_model)); |
| 102 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 110 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 103 GetDisplayedFileSystems(cookies_model)); | 111 GetDisplayedFileSystems(cookies_model)); |
| 104 } | 112 } |
| 105 return cookies_model; | 113 return cookies_model; |
| 106 } | 114 } |
| 107 | 115 |
| 108 // Get the cookie names in the cookie list, as a comma seperated string. | |
| 109 // (Note that the CookieMonster cookie list is sorted by domain.) | |
| 110 // Ex: | |
| 111 // monster->SetCookie(GURL("http://b"), "X=1") | |
| 112 // monster->SetCookie(GURL("http://a"), "Y=1") | |
| 113 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); | |
| 114 std::string GetMonsterCookies(net::CookieMonster* monster) { | |
| 115 std::vector<std::string> parts; | |
| 116 net::CookieList cookie_list = monster->GetAllCookies(); | |
| 117 for (size_t i = 0; i < cookie_list.size(); ++i) | |
| 118 parts.push_back(cookie_list[i].Name()); | |
| 119 return JoinString(parts, ','); | |
| 120 } | |
| 121 | |
| 122 std::string GetNodesOfChildren( | 116 std::string GetNodesOfChildren( |
| 123 const CookieTreeNode* node, | 117 const CookieTreeNode* node, |
| 124 CookieTreeNode::DetailedInfo::NodeType node_type) { | 118 CookieTreeNode::DetailedInfo::NodeType node_type) { |
| 125 if (!node->empty()) { | 119 if (!node->empty()) { |
| 126 std::string retval; | 120 std::string retval; |
| 127 for (int i = 0; i < node->child_count(); ++i) { | 121 for (int i = 0; i < node->child_count(); ++i) { |
| 128 retval += GetNodesOfChildren(node->GetChild(i), node_type); | 122 retval += GetNodesOfChildren(node->GetChild(i), node_type); |
| 129 } | 123 } |
| 130 return retval; | 124 return retval; |
| 131 } else { | 125 } else { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 DCHECK(parent_node); | 234 DCHECK(parent_node); |
| 241 delete parent_node->GetModel()->Remove(parent_node, node); | 235 delete parent_node->GetModel()->Remove(parent_node, node); |
| 242 } | 236 } |
| 243 | 237 |
| 244 protected: | 238 protected: |
| 245 MessageLoop message_loop_; | 239 MessageLoop message_loop_; |
| 246 BrowserThread ui_thread_; | 240 BrowserThread ui_thread_; |
| 247 BrowserThread io_thread_; | 241 BrowserThread io_thread_; |
| 248 | 242 |
| 249 scoped_ptr<TestingProfile> profile_; | 243 scoped_ptr<TestingProfile> profile_; |
| 244 scoped_refptr<MockBrowsingDataCookieHelper> |
| 245 mock_browsing_data_cookie_helper_; |
| 250 scoped_refptr<MockBrowsingDataDatabaseHelper> | 246 scoped_refptr<MockBrowsingDataDatabaseHelper> |
| 251 mock_browsing_data_database_helper_; | 247 mock_browsing_data_database_helper_; |
| 252 scoped_refptr<MockBrowsingDataLocalStorageHelper> | 248 scoped_refptr<MockBrowsingDataLocalStorageHelper> |
| 253 mock_browsing_data_local_storage_helper_; | 249 mock_browsing_data_local_storage_helper_; |
| 254 scoped_refptr<MockBrowsingDataLocalStorageHelper> | 250 scoped_refptr<MockBrowsingDataLocalStorageHelper> |
| 255 mock_browsing_data_session_storage_helper_; | 251 mock_browsing_data_session_storage_helper_; |
| 256 scoped_refptr<MockBrowsingDataAppCacheHelper> | 252 scoped_refptr<MockBrowsingDataAppCacheHelper> |
| 257 mock_browsing_data_appcache_helper_; | 253 mock_browsing_data_appcache_helper_; |
| 258 scoped_refptr<MockBrowsingDataIndexedDBHelper> | 254 scoped_refptr<MockBrowsingDataIndexedDBHelper> |
| 259 mock_browsing_data_indexed_db_helper_; | 255 mock_browsing_data_indexed_db_helper_; |
| 260 scoped_refptr<MockBrowsingDataFileSystemHelper> | 256 scoped_refptr<MockBrowsingDataFileSystemHelper> |
| 261 mock_browsing_data_file_system_helper_; | 257 mock_browsing_data_file_system_helper_; |
| 262 }; | 258 }; |
| 263 | 259 |
| 264 TEST_F(CookiesTreeModelTest, RemoveAll) { | 260 TEST_F(CookiesTreeModelTest, RemoveAll) { |
| 265 scoped_ptr<CookiesTreeModel> cookies_model( | 261 scoped_ptr<CookiesTreeModel> cookies_model( |
| 266 CreateCookiesTreeModelWithInitialSample()); | 262 CreateCookiesTreeModelWithInitialSample()); |
| 267 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 268 | 263 |
| 269 // Reset the selection of the first row. | 264 // Reset the selection of the first row. |
| 270 { | 265 { |
| 271 SCOPED_TRACE("Before removing"); | 266 SCOPED_TRACE("Before removing"); |
| 272 EXPECT_EQ(GetMonsterCookies(monster), | 267 EXPECT_EQ("A,B,C", |
| 273 GetDisplayedCookies(cookies_model.get())); | 268 GetDisplayedCookies(cookies_model.get())); |
| 274 EXPECT_EQ("db1,db2", | 269 EXPECT_EQ("db1,db2", |
| 275 GetDisplayedDatabases(cookies_model.get())); | 270 GetDisplayedDatabases(cookies_model.get())); |
| 276 EXPECT_EQ("http://host1:1/,http://host2:2/", | 271 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 277 GetDisplayedLocalStorages(cookies_model.get())); | 272 GetDisplayedLocalStorages(cookies_model.get())); |
| 278 EXPECT_EQ("http://host1:1/,http://host2:2/", | 273 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 279 GetDisplayedSessionStorages(cookies_model.get())); | 274 GetDisplayedSessionStorages(cookies_model.get())); |
| 280 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 275 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 281 GetDisplayedIndexedDBs(cookies_model.get())); | 276 GetDisplayedIndexedDBs(cookies_model.get())); |
| 282 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 277 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 283 GetDisplayedFileSystems(cookies_model.get())); | 278 GetDisplayedFileSystems(cookies_model.get())); |
| 284 } | 279 } |
| 285 | 280 |
| 281 mock_browsing_data_cookie_helper_->Reset(); |
| 286 mock_browsing_data_database_helper_->Reset(); | 282 mock_browsing_data_database_helper_->Reset(); |
| 287 mock_browsing_data_local_storage_helper_->Reset(); | 283 mock_browsing_data_local_storage_helper_->Reset(); |
| 288 mock_browsing_data_session_storage_helper_->Reset(); | 284 mock_browsing_data_session_storage_helper_->Reset(); |
| 289 mock_browsing_data_indexed_db_helper_->Reset(); | 285 mock_browsing_data_indexed_db_helper_->Reset(); |
| 290 mock_browsing_data_file_system_helper_->Reset(); | 286 mock_browsing_data_file_system_helper_->Reset(); |
| 291 | 287 |
| 292 cookies_model->DeleteAllStoredObjects(); | 288 cookies_model->DeleteAllStoredObjects(); |
| 293 | 289 |
| 294 { | 290 { |
| 295 SCOPED_TRACE("After removing"); | 291 SCOPED_TRACE("After removing"); |
| 296 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); | 292 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 297 EXPECT_EQ(0, cookies_model->GetRoot()->child_count()); | 293 EXPECT_EQ(0, cookies_model->GetRoot()->child_count()); |
| 298 EXPECT_EQ(std::string(""), GetMonsterCookies(monster)); | 294 EXPECT_EQ(std::string(""), GetDisplayedCookies(cookies_model.get())); |
| 299 EXPECT_EQ(GetMonsterCookies(monster), | 295 EXPECT_TRUE(mock_browsing_data_cookie_helper_->AllDeleted()); |
| 300 GetDisplayedCookies(cookies_model.get())); | |
| 301 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); | 296 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); |
| 302 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); | 297 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); |
| 303 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted()); | 298 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted()); |
| 304 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted()); | 299 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted()); |
| 305 EXPECT_TRUE(mock_browsing_data_file_system_helper_->AllDeleted()); | 300 EXPECT_TRUE(mock_browsing_data_file_system_helper_->AllDeleted()); |
| 306 } | 301 } |
| 307 } | 302 } |
| 308 | 303 |
| 309 TEST_F(CookiesTreeModelTest, Remove) { | 304 TEST_F(CookiesTreeModelTest, Remove) { |
| 310 scoped_ptr<CookiesTreeModel> cookies_model( | 305 scoped_ptr<CookiesTreeModel> cookies_model( |
| 311 CreateCookiesTreeModelWithInitialSample()); | 306 CreateCookiesTreeModelWithInitialSample()); |
| 312 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 313 | 307 |
| 314 // Children start out arranged as follows: | 308 // Children start out arranged as follows: |
| 315 // | 309 // |
| 316 // 0. `foo1` | 310 // 0. `foo1` |
| 317 // 1. `foo2` | 311 // 1. `foo2` |
| 318 // 2. `foo3` | 312 // 2. `foo3` |
| 319 // 3. `fshost1` | 313 // 3. `fshost1` |
| 320 // 4. `fshost2` | 314 // 4. `fshost2` |
| 321 // 5. `fshost3` | 315 // 5. `fshost3` |
| 322 // 6. `gdbhost1` | 316 // 6. `gdbhost1` |
| 323 // 7. `gdbhost2` | 317 // 7. `gdbhost2` |
| 324 // 8. `host1` | 318 // 8. `host1` |
| 325 // 9. `host2` | 319 // 9. `host2` |
| 326 // 10. `idbhost1` | 320 // 10. `idbhost1` |
| 327 // 11. `idbhost2` | 321 // 11. `idbhost2` |
| 328 // | 322 // |
| 329 // Here, we'll remove them one by one, starting from the end, and | 323 // Here, we'll remove them one by one, starting from the end, and |
| 330 // check that the state makes sense. | 324 // check that the state makes sense. |
| 331 | 325 |
| 332 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(11)); | 326 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(11)); |
| 333 { | 327 { |
| 334 SCOPED_TRACE("`idbhost2` removed."); | 328 SCOPED_TRACE("`idbhost2` removed."); |
| 335 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | |
| 336 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 329 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 337 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 330 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 338 EXPECT_EQ("http://host1:1/,http://host2:2/", | 331 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 339 GetDisplayedLocalStorages(cookies_model.get())); | 332 GetDisplayedLocalStorages(cookies_model.get())); |
| 340 EXPECT_EQ("http://host1:1/,http://host2:2/", | 333 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 341 GetDisplayedSessionStorages(cookies_model.get())); | 334 GetDisplayedSessionStorages(cookies_model.get())); |
| 342 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 335 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 343 GetDisplayedFileSystems(cookies_model.get())); | 336 GetDisplayedFileSystems(cookies_model.get())); |
| 344 EXPECT_EQ("http://idbhost1:1/", | 337 EXPECT_EQ("http://idbhost1:1/", |
| 345 GetDisplayedIndexedDBs(cookies_model.get())); | 338 GetDisplayedIndexedDBs(cookies_model.get())); |
| 346 EXPECT_EQ(38, cookies_model->GetRoot()->GetTotalNodeCount()); | 339 EXPECT_EQ(38, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 347 } | 340 } |
| 348 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(10)); | 341 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(10)); |
| 349 { | 342 { |
| 350 SCOPED_TRACE("`idbhost1` removed."); | 343 SCOPED_TRACE("`idbhost1` removed."); |
| 351 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | |
| 352 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 344 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 353 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 345 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 354 EXPECT_EQ("http://host1:1/,http://host2:2/", | 346 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 355 GetDisplayedLocalStorages(cookies_model.get())); | 347 GetDisplayedLocalStorages(cookies_model.get())); |
| 356 EXPECT_EQ("http://host1:1/,http://host2:2/", | 348 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 357 GetDisplayedSessionStorages(cookies_model.get())); | 349 GetDisplayedSessionStorages(cookies_model.get())); |
| 358 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 350 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 359 GetDisplayedFileSystems(cookies_model.get())); | 351 GetDisplayedFileSystems(cookies_model.get())); |
| 360 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 352 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 361 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); | 353 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 362 } | 354 } |
| 363 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(9)); | 355 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(9)); |
| 364 { | 356 { |
| 365 SCOPED_TRACE("`host2` removed."); | 357 SCOPED_TRACE("`host2` removed."); |
| 366 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | |
| 367 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 358 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 368 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 359 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 369 EXPECT_EQ("http://host1:1/", | 360 EXPECT_EQ("http://host1:1/", |
| 370 GetDisplayedLocalStorages(cookies_model.get())); | 361 GetDisplayedLocalStorages(cookies_model.get())); |
| 371 EXPECT_EQ("http://host1:1/", | 362 EXPECT_EQ("http://host1:1/", |
| 372 GetDisplayedSessionStorages(cookies_model.get())); | 363 GetDisplayedSessionStorages(cookies_model.get())); |
| 373 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 364 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 374 GetDisplayedFileSystems(cookies_model.get())); | 365 GetDisplayedFileSystems(cookies_model.get())); |
| 375 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 366 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 376 EXPECT_EQ(30, cookies_model->GetRoot()->GetTotalNodeCount()); | 367 EXPECT_EQ(30, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 377 } | 368 } |
| 378 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)); | 369 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)); |
| 379 { | 370 { |
| 380 SCOPED_TRACE("`host1` removed."); | 371 SCOPED_TRACE("`host1` removed."); |
| 381 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | |
| 382 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 372 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 383 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 373 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 384 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 374 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 385 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 375 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 386 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 376 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 387 GetDisplayedFileSystems(cookies_model.get())); | 377 GetDisplayedFileSystems(cookies_model.get())); |
| 388 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 378 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 389 EXPECT_EQ(25, cookies_model->GetRoot()->GetTotalNodeCount()); | 379 EXPECT_EQ(25, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 390 } | 380 } |
| 391 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(7)); | 381 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(7)); |
| 392 { | 382 { |
| 393 SCOPED_TRACE("`gdbhost2` removed."); | 383 SCOPED_TRACE("`gdbhost2` removed."); |
| 394 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | |
| 395 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 384 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 396 EXPECT_EQ("db1", GetDisplayedDatabases(cookies_model.get())); | 385 EXPECT_EQ("db1", GetDisplayedDatabases(cookies_model.get())); |
| 397 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 386 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 398 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 387 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 399 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 388 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 400 GetDisplayedFileSystems(cookies_model.get())); | 389 GetDisplayedFileSystems(cookies_model.get())); |
| 401 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 390 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 402 EXPECT_EQ(22, cookies_model->GetRoot()->GetTotalNodeCount()); | 391 EXPECT_EQ(22, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 403 } | 392 } |
| 404 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)); | 393 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)); |
| 405 { | 394 { |
| 406 SCOPED_TRACE("`gdbhost1` removed."); | 395 SCOPED_TRACE("`gdbhost1` removed."); |
| 407 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | |
| 408 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 396 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 409 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 397 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 410 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 398 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 411 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 399 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 412 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 400 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 413 GetDisplayedFileSystems(cookies_model.get())); | 401 GetDisplayedFileSystems(cookies_model.get())); |
| 414 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 402 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 415 EXPECT_EQ(19, cookies_model->GetRoot()->GetTotalNodeCount()); | 403 EXPECT_EQ(19, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 416 } | 404 } |
| 417 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(5)); | 405 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(5)); |
| 418 { | 406 { |
| 419 SCOPED_TRACE("`fshost3` removed."); | 407 SCOPED_TRACE("`fshost3` removed."); |
| 420 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | |
| 421 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 408 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 422 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 409 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 423 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 410 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 424 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 411 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 425 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/", | 412 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/", |
| 426 GetDisplayedFileSystems(cookies_model.get())); | 413 GetDisplayedFileSystems(cookies_model.get())); |
| 427 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 414 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 428 EXPECT_EQ(16, cookies_model->GetRoot()->GetTotalNodeCount()); | 415 EXPECT_EQ(16, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 429 } | 416 } |
| 430 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(4)); | 417 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(4)); |
| 431 { | 418 { |
| 432 SCOPED_TRACE("`fshost2` removed."); | 419 SCOPED_TRACE("`fshost2` removed."); |
| 433 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | |
| 434 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 420 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 435 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 421 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 436 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 422 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 437 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 423 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 438 EXPECT_EQ("http://fshost1:1/", | 424 EXPECT_EQ("http://fshost1:1/", |
| 439 GetDisplayedFileSystems(cookies_model.get())); | 425 GetDisplayedFileSystems(cookies_model.get())); |
| 440 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 426 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 441 EXPECT_EQ(13, cookies_model->GetRoot()->GetTotalNodeCount()); | 427 EXPECT_EQ(13, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 442 } | 428 } |
| 443 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(3)); | 429 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(3)); |
| 444 { | 430 { |
| 445 SCOPED_TRACE("`fshost1` removed."); | 431 SCOPED_TRACE("`fshost1` removed."); |
| 446 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | |
| 447 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 432 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 448 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 433 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 449 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 434 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 450 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 435 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 451 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); | 436 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 452 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 437 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 453 EXPECT_EQ(10, cookies_model->GetRoot()->GetTotalNodeCount()); | 438 EXPECT_EQ(10, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 454 } | 439 } |
| 455 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(2)); | 440 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(2)); |
| 456 { | 441 { |
| 457 SCOPED_TRACE("`foo3` removed."); | 442 SCOPED_TRACE("`foo3` removed."); |
| 458 EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); | |
| 459 EXPECT_STREQ("A,B", GetDisplayedCookies(cookies_model.get()).c_str()); | 443 EXPECT_STREQ("A,B", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 460 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 444 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 461 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 445 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 462 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 446 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 463 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); | 447 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 464 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 448 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 465 EXPECT_EQ(7, cookies_model->GetRoot()->GetTotalNodeCount()); | 449 EXPECT_EQ(7, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 466 } | 450 } |
| 467 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)); | 451 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)); |
| 468 { | 452 { |
| 469 SCOPED_TRACE("`foo2` removed."); | 453 SCOPED_TRACE("`foo2` removed."); |
| 470 EXPECT_STREQ("A", GetMonsterCookies(monster).c_str()); | |
| 471 EXPECT_STREQ("A", GetDisplayedCookies(cookies_model.get()).c_str()); | 454 EXPECT_STREQ("A", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 472 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 455 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 473 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 456 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 474 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 457 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 475 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); | 458 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 476 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 459 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 477 EXPECT_EQ(4, cookies_model->GetRoot()->GetTotalNodeCount()); | 460 EXPECT_EQ(4, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 478 } | 461 } |
| 479 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)); | 462 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)); |
| 480 { | 463 { |
| 481 SCOPED_TRACE("`foo1` removed."); | 464 SCOPED_TRACE("`foo1` removed."); |
| 482 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); | |
| 483 EXPECT_STREQ("", GetDisplayedCookies(cookies_model.get()).c_str()); | 465 EXPECT_STREQ("", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 484 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 466 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 485 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 467 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 486 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 468 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 487 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); | 469 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 488 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 470 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 489 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); | 471 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 490 } | 472 } |
| 491 } | 473 } |
| 492 | 474 |
| 493 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { | 475 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { |
| 494 scoped_ptr<CookiesTreeModel> cookies_model( | 476 scoped_ptr<CookiesTreeModel> cookies_model( |
| 495 CreateCookiesTreeModelWithInitialSample()); | 477 CreateCookiesTreeModelWithInitialSample()); |
| 496 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 497 | 478 |
| 498 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); | 479 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); |
| 499 { | 480 { |
| 500 SCOPED_TRACE("First origin removed"); | 481 SCOPED_TRACE("First origin removed"); |
| 501 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | |
| 502 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 482 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 503 // 39 because in this case, the origin remains, although the COOKIES | 483 // 39 because in this case, the origin remains, although the COOKIES |
| 504 // node beneath it has been deleted. So, we have | 484 // node beneath it has been deleted. So, we have |
| 505 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 485 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c |
| 506 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 486 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 507 // fshost1 -> filesystem -> http://fshost1:1/, | 487 // fshost1 -> filesystem -> http://fshost1:1/, |
| 508 // fshost2 -> filesystem -> http://fshost2:1/, | 488 // fshost2 -> filesystem -> http://fshost2:1/, |
| 509 // fshost3 -> filesystem -> http://fshost3:1/, | 489 // fshost3 -> filesystem -> http://fshost3:1/, |
| 510 // host1 -> localstorage -> http://host1:1/, | 490 // host1 -> localstorage -> http://host1:1/, |
| 511 // host2 -> localstorage -> http://host2:2/, | 491 // host2 -> localstorage -> http://host2:2/, |
| 512 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 492 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 513 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 493 // idbhost2 -> sessionstorage -> http://idbhost2:2/. |
| 514 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); | 494 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 515 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 495 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 516 EXPECT_EQ("http://host1:1/,http://host2:2/", | 496 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 517 GetDisplayedLocalStorages(cookies_model.get())); | 497 GetDisplayedLocalStorages(cookies_model.get())); |
| 518 EXPECT_EQ("http://host1:1/,http://host2:2/", | 498 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 519 GetDisplayedSessionStorages(cookies_model.get())); | 499 GetDisplayedSessionStorages(cookies_model.get())); |
| 520 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 500 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 521 GetDisplayedIndexedDBs(cookies_model.get())); | 501 GetDisplayedIndexedDBs(cookies_model.get())); |
| 522 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 502 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 523 GetDisplayedFileSystems(cookies_model.get())); | 503 GetDisplayedFileSystems(cookies_model.get())); |
| 524 } | 504 } |
| 525 | 505 |
| 526 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 506 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
| 527 { | 507 { |
| 528 SCOPED_TRACE("First database removed"); | 508 SCOPED_TRACE("First database removed"); |
| 529 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | |
| 530 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 509 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 531 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 510 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 532 EXPECT_EQ("http://host1:1/,http://host2:2/", | 511 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 533 GetDisplayedLocalStorages(cookies_model.get())); | 512 GetDisplayedLocalStorages(cookies_model.get())); |
| 534 EXPECT_EQ("http://host1:1/,http://host2:2/", | 513 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 535 GetDisplayedSessionStorages(cookies_model.get())); | 514 GetDisplayedSessionStorages(cookies_model.get())); |
| 536 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 515 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 537 GetDisplayedIndexedDBs(cookies_model.get())); | 516 GetDisplayedIndexedDBs(cookies_model.get())); |
| 538 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 517 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 539 GetDisplayedFileSystems(cookies_model.get())); | 518 GetDisplayedFileSystems(cookies_model.get())); |
| 540 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); | 519 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 541 } | 520 } |
| 542 | 521 |
| 543 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 522 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
| 544 { | 523 { |
| 545 SCOPED_TRACE("First origin removed"); | 524 SCOPED_TRACE("First origin removed"); |
| 546 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | |
| 547 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 525 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 548 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 526 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 549 EXPECT_EQ("http://host2:2/", | 527 EXPECT_EQ("http://host2:2/", |
| 550 GetDisplayedLocalStorages(cookies_model.get())); | 528 GetDisplayedLocalStorages(cookies_model.get())); |
| 551 EXPECT_EQ("http://host1:1/,http://host2:2/", | 529 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 552 GetDisplayedSessionStorages(cookies_model.get())); | 530 GetDisplayedSessionStorages(cookies_model.get())); |
| 553 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 531 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 554 GetDisplayedIndexedDBs(cookies_model.get())); | 532 GetDisplayedIndexedDBs(cookies_model.get())); |
| 555 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 533 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 556 GetDisplayedFileSystems(cookies_model.get())); | 534 GetDisplayedFileSystems(cookies_model.get())); |
| 557 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); | 535 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 558 } | 536 } |
| 559 } | 537 } |
| 560 | 538 |
| 561 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { | 539 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { |
| 562 scoped_ptr<CookiesTreeModel> cookies_model( | 540 scoped_ptr<CookiesTreeModel> cookies_model( |
| 563 CreateCookiesTreeModelWithInitialSample()); | 541 CreateCookiesTreeModelWithInitialSample()); |
| 564 net::CookieMonster* monster = profile_->GetCookieMonster(); | |
| 565 | 542 |
| 566 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); | 543 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); |
| 567 { | 544 { |
| 568 SCOPED_TRACE("Second origin COOKIES node removed"); | 545 SCOPED_TRACE("Second origin COOKIES node removed"); |
| 569 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | |
| 570 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 546 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 571 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 547 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 572 EXPECT_EQ("http://host1:1/,http://host2:2/", | 548 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 573 GetDisplayedLocalStorages(cookies_model.get())); | 549 GetDisplayedLocalStorages(cookies_model.get())); |
| 574 EXPECT_EQ("http://host1:1/,http://host2:2/", | 550 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 575 GetDisplayedSessionStorages(cookies_model.get())); | 551 GetDisplayedSessionStorages(cookies_model.get())); |
| 576 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 552 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 577 GetDisplayedIndexedDBs(cookies_model.get())); | 553 GetDisplayedIndexedDBs(cookies_model.get())); |
| 578 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 554 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 579 GetDisplayedFileSystems(cookies_model.get())); | 555 GetDisplayedFileSystems(cookies_model.get())); |
| 580 // 39 because in this case, the origin remains, although the COOKIES | 556 // 39 because in this case, the origin remains, although the COOKIES |
| 581 // node beneath it has been deleted. So, we have | 557 // node beneath it has been deleted. So, we have |
| 582 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 558 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c |
| 583 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 559 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 584 // fshost1 -> filesystem -> http://fshost1:1/, | 560 // fshost1 -> filesystem -> http://fshost1:1/, |
| 585 // fshost2 -> filesystem -> http://fshost2:1/, | 561 // fshost2 -> filesystem -> http://fshost2:1/, |
| 586 // fshost3 -> filesystem -> http://fshost3:1/, | 562 // fshost3 -> filesystem -> http://fshost3:1/, |
| 587 // host1 -> localstorage -> http://host1:1/, | 563 // host1 -> localstorage -> http://host1:1/, |
| 588 // host2 -> localstorage -> http://host2:2/, | 564 // host2 -> localstorage -> http://host2:2/, |
| 589 // host1 -> sessionstorage -> http://host1:1/, | 565 // host1 -> sessionstorage -> http://host1:1/, |
| 590 // host2 -> sessionstorage -> http://host2:2/, | 566 // host2 -> sessionstorage -> http://host2:2/, |
| 591 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 567 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 592 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 568 // idbhost2 -> sessionstorage -> http://idbhost2:2/. |
| 593 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); | 569 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 594 } | 570 } |
| 595 | 571 |
| 596 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 572 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
| 597 { | 573 { |
| 598 SCOPED_TRACE("First database removed"); | 574 SCOPED_TRACE("First database removed"); |
| 599 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | |
| 600 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 575 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 601 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 576 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 602 EXPECT_EQ("http://host1:1/,http://host2:2/", | 577 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 603 GetDisplayedLocalStorages(cookies_model.get())); | 578 GetDisplayedLocalStorages(cookies_model.get())); |
| 604 EXPECT_EQ("http://host1:1/,http://host2:2/", | 579 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 605 GetDisplayedSessionStorages(cookies_model.get())); | 580 GetDisplayedSessionStorages(cookies_model.get())); |
| 606 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 581 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 607 GetDisplayedIndexedDBs(cookies_model.get())); | 582 GetDisplayedIndexedDBs(cookies_model.get())); |
| 608 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 583 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 609 GetDisplayedFileSystems(cookies_model.get())); | 584 GetDisplayedFileSystems(cookies_model.get())); |
| 610 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); | 585 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 611 } | 586 } |
| 612 | 587 |
| 613 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 588 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
| 614 { | 589 { |
| 615 SCOPED_TRACE("First origin removed"); | 590 SCOPED_TRACE("First origin removed"); |
| 616 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | |
| 617 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 591 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 618 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 592 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 619 EXPECT_EQ("http://host2:2/", | 593 EXPECT_EQ("http://host2:2/", |
| 620 GetDisplayedLocalStorages(cookies_model.get())); | 594 GetDisplayedLocalStorages(cookies_model.get())); |
| 621 EXPECT_EQ("http://host1:1/,http://host2:2/", | 595 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 622 GetDisplayedSessionStorages(cookies_model.get())); | 596 GetDisplayedSessionStorages(cookies_model.get())); |
| 623 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 597 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 624 GetDisplayedIndexedDBs(cookies_model.get())); | 598 GetDisplayedIndexedDBs(cookies_model.get())); |
| 625 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 599 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 626 GetDisplayedFileSystems(cookies_model.get())); | 600 GetDisplayedFileSystems(cookies_model.get())); |
| 627 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); | 601 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 628 } | 602 } |
| 629 } | 603 } |
| 630 | 604 |
| 631 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { | 605 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { |
| 632 net::CookieMonster* monster = profile_->GetCookieMonster(); | 606 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, |
| 633 monster->SetCookie(GURL("http://foo1"), "A=1"); | |
| 634 monster->SetCookie(GURL("http://foo2"), "B=1"); | |
| 635 monster->SetCookie(GURL("http://foo3"), "C=1"); | |
| 636 monster->SetCookie(GURL("http://foo3"), "D=1"); | |
| 637 CookiesTreeModel cookies_model(monster, | |
| 638 mock_browsing_data_database_helper_, | 607 mock_browsing_data_database_helper_, |
| 639 mock_browsing_data_local_storage_helper_, | 608 mock_browsing_data_local_storage_helper_, |
| 640 mock_browsing_data_session_storage_helper_, | 609 mock_browsing_data_session_storage_helper_, |
| 641 mock_browsing_data_appcache_helper_, | 610 mock_browsing_data_appcache_helper_, |
| 642 mock_browsing_data_indexed_db_helper_, | 611 mock_browsing_data_indexed_db_helper_, |
| 643 mock_browsing_data_file_system_helper_, | 612 mock_browsing_data_file_system_helper_, |
| 644 false); | 613 false); |
| 614 mock_browsing_data_cookie_helper_-> |
| 615 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 616 mock_browsing_data_cookie_helper_-> |
| 617 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 618 mock_browsing_data_cookie_helper_-> |
| 619 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 620 mock_browsing_data_cookie_helper_-> |
| 621 AddCookieSamples(GURL("http://foo3"), "D=1"); |
| 622 mock_browsing_data_cookie_helper_->Notify(); |
| 645 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 623 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 646 mock_browsing_data_database_helper_->Notify(); | 624 mock_browsing_data_database_helper_->Notify(); |
| 647 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 625 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 648 mock_browsing_data_local_storage_helper_->Notify(); | 626 mock_browsing_data_local_storage_helper_->Notify(); |
| 649 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 627 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 650 mock_browsing_data_session_storage_helper_->Notify(); | 628 mock_browsing_data_session_storage_helper_->Notify(); |
| 651 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 629 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 652 mock_browsing_data_indexed_db_helper_->Notify(); | 630 mock_browsing_data_indexed_db_helper_->Notify(); |
| 653 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 631 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 654 mock_browsing_data_file_system_helper_->Notify(); | 632 mock_browsing_data_file_system_helper_->Notify(); |
| 655 | 633 |
| 656 { | 634 { |
| 657 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " | 635 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " |
| 658 "2 session storages, 2 indexed DBs, 3 file systems"); | 636 "2 session storages, 2 indexed DBs, 3 file systems"); |
| 659 // 42 because there's the root, then foo1 -> cookies -> a, | 637 // 42 because there's the root, then foo1 -> cookies -> a, |
| 660 // foo2 -> cookies -> b, foo3 -> cookies -> c,d | 638 // foo2 -> cookies -> b, foo3 -> cookies -> c,d |
| 661 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 639 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 662 // fshost1 -> filesystem -> http://fshost1:1/, | 640 // fshost1 -> filesystem -> http://fshost1:1/, |
| 663 // fshost2 -> filesystem -> http://fshost2:1/, | 641 // fshost2 -> filesystem -> http://fshost2:1/, |
| 664 // fshost3 -> filesystem -> http://fshost3:1/, | 642 // fshost3 -> filesystem -> http://fshost3:1/, |
| 665 // host1 -> localstorage -> http://host1:1/, | 643 // host1 -> localstorage -> http://host1:1/, |
| 666 // host1 -> sessionstorage -> http://host1:1/, | 644 // host1 -> sessionstorage -> http://host1:1/, |
| 667 // host2 -> sessionstorage -> http://host2:2/, | 645 // host2 -> sessionstorage -> http://host2:2/, |
| 668 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 646 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 669 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 647 // idbhost2 -> sessionstorage -> http://idbhost2:2/. |
| 670 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); | 648 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 671 EXPECT_STREQ("A,B,C,D", GetMonsterCookies(monster).c_str()); | |
| 672 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); | 649 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); |
| 673 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 650 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 674 EXPECT_EQ("http://host1:1/,http://host2:2/", | 651 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 675 GetDisplayedLocalStorages(&cookies_model)); | 652 GetDisplayedLocalStorages(&cookies_model)); |
| 676 EXPECT_EQ("http://host1:1/,http://host2:2/", | 653 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 677 GetDisplayedSessionStorages(&cookies_model)); | 654 GetDisplayedSessionStorages(&cookies_model)); |
| 678 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 655 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 679 GetDisplayedIndexedDBs(&cookies_model)); | 656 GetDisplayedIndexedDBs(&cookies_model)); |
| 680 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 657 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 681 GetDisplayedFileSystems(&cookies_model)); | 658 GetDisplayedFileSystems(&cookies_model)); |
| 682 } | 659 } |
| 683 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); | 660 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); |
| 684 { | 661 { |
| 685 SCOPED_TRACE("Third origin removed"); | 662 SCOPED_TRACE("Third origin removed"); |
| 686 EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); | |
| 687 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); | 663 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); |
| 688 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 664 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 689 EXPECT_EQ("http://host1:1/,http://host2:2/", | 665 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 690 GetDisplayedLocalStorages(&cookies_model)); | 666 GetDisplayedLocalStorages(&cookies_model)); |
| 691 EXPECT_EQ("http://host1:1/,http://host2:2/", | 667 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 692 GetDisplayedSessionStorages(&cookies_model)); | 668 GetDisplayedSessionStorages(&cookies_model)); |
| 693 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 669 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 694 GetDisplayedIndexedDBs(&cookies_model)); | 670 GetDisplayedIndexedDBs(&cookies_model)); |
| 695 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 671 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 696 GetDisplayedFileSystems(&cookies_model)); | 672 GetDisplayedFileSystems(&cookies_model)); |
| 697 EXPECT_EQ(38, cookies_model.GetRoot()->GetTotalNodeCount()); | 673 EXPECT_EQ(38, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 698 } | 674 } |
| 699 } | 675 } |
| 700 | 676 |
| 701 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { | 677 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { |
| 702 net::CookieMonster* monster = profile_->GetCookieMonster(); | 678 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, |
| 703 monster->SetCookie(GURL("http://foo1"), "A=1"); | |
| 704 monster->SetCookie(GURL("http://foo2"), "B=1"); | |
| 705 monster->SetCookie(GURL("http://foo3"), "C=1"); | |
| 706 monster->SetCookie(GURL("http://foo3"), "D=1"); | |
| 707 monster->SetCookie(GURL("http://foo3"), "E=1"); | |
| 708 CookiesTreeModel cookies_model(monster, | |
| 709 mock_browsing_data_database_helper_, | 679 mock_browsing_data_database_helper_, |
| 710 mock_browsing_data_local_storage_helper_, | 680 mock_browsing_data_local_storage_helper_, |
| 711 mock_browsing_data_session_storage_helper_, | 681 mock_browsing_data_session_storage_helper_, |
| 712 mock_browsing_data_appcache_helper_, | 682 mock_browsing_data_appcache_helper_, |
| 713 mock_browsing_data_indexed_db_helper_, | 683 mock_browsing_data_indexed_db_helper_, |
| 714 mock_browsing_data_file_system_helper_, | 684 mock_browsing_data_file_system_helper_, |
| 715 false); | 685 false); |
| 686 mock_browsing_data_cookie_helper_-> |
| 687 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 688 mock_browsing_data_cookie_helper_-> |
| 689 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 690 mock_browsing_data_cookie_helper_-> |
| 691 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 692 mock_browsing_data_cookie_helper_-> |
| 693 AddCookieSamples(GURL("http://foo3"), "D=1"); |
| 694 mock_browsing_data_cookie_helper_-> |
| 695 AddCookieSamples(GURL("http://foo3"), "E=1"); |
| 696 mock_browsing_data_cookie_helper_->Notify(); |
| 716 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 697 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 717 mock_browsing_data_database_helper_->Notify(); | 698 mock_browsing_data_database_helper_->Notify(); |
| 718 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 699 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 719 mock_browsing_data_local_storage_helper_->Notify(); | 700 mock_browsing_data_local_storage_helper_->Notify(); |
| 720 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 701 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 721 mock_browsing_data_session_storage_helper_->Notify(); | 702 mock_browsing_data_session_storage_helper_->Notify(); |
| 722 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 703 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 723 mock_browsing_data_indexed_db_helper_->Notify(); | 704 mock_browsing_data_indexed_db_helper_->Notify(); |
| 724 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 705 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 725 mock_browsing_data_file_system_helper_->Notify(); | 706 mock_browsing_data_file_system_helper_->Notify(); |
| 726 | 707 |
| 727 { | 708 { |
| 728 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " | 709 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " |
| 729 "2 session storages, 2 indexed DBs"); | 710 "2 session storages, 2 indexed DBs"); |
| 730 // 43 because there's the root, then foo1 -> cookies -> a, | 711 // 43 because there's the root, then foo1 -> cookies -> a, |
| 731 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 712 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
| 732 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 713 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 733 // fshost1 -> filesystem -> http://fshost1:1/, | 714 // fshost1 -> filesystem -> http://fshost1:1/, |
| 734 // fshost2 -> filesystem -> http://fshost2:1/, | 715 // fshost2 -> filesystem -> http://fshost2:1/, |
| 735 // fshost3 -> filesystem -> http://fshost3:1/, | 716 // fshost3 -> filesystem -> http://fshost3:1/, |
| 736 // host1 -> localstorage -> http://host1:1/, | 717 // host1 -> localstorage -> http://host1:1/, |
| 737 // host2 -> localstorage -> http://host2:2/, | 718 // host2 -> localstorage -> http://host2:2/, |
| 738 // host1 -> sessionstorage -> http://host1:1/, | 719 // host1 -> sessionstorage -> http://host1:1/, |
| 739 // host2 -> sessionstorage -> http://host2:2/, | 720 // host2 -> sessionstorage -> http://host2:2/, |
| 740 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 721 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 741 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 722 // idbhost2 -> sessionstorage -> http://idbhost2:2/. |
| 742 EXPECT_EQ(43, cookies_model.GetRoot()->GetTotalNodeCount()); | 723 EXPECT_EQ(43, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 743 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); | |
| 744 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 724 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 745 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 725 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 746 EXPECT_EQ("http://host1:1/,http://host2:2/", | 726 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 747 GetDisplayedLocalStorages(&cookies_model)); | 727 GetDisplayedLocalStorages(&cookies_model)); |
| 748 EXPECT_EQ("http://host1:1/,http://host2:2/", | 728 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 749 GetDisplayedSessionStorages(&cookies_model)); | 729 GetDisplayedSessionStorages(&cookies_model)); |
| 750 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 730 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 751 GetDisplayedIndexedDBs(&cookies_model)); | 731 GetDisplayedIndexedDBs(&cookies_model)); |
| 752 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 732 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 753 GetDisplayedFileSystems(&cookies_model)); | 733 GetDisplayedFileSystems(&cookies_model)); |
| 754 } | 734 } |
| 755 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> | 735 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> |
| 756 GetChild(1)); | 736 GetChild(1)); |
| 757 { | 737 { |
| 758 SCOPED_TRACE("Middle cookie in third origin removed"); | 738 SCOPED_TRACE("Middle cookie in third origin removed"); |
| 759 EXPECT_STREQ("A,B,C,E", GetMonsterCookies(monster).c_str()); | |
| 760 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); | 739 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 761 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); | 740 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 762 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 741 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 763 EXPECT_EQ("http://host1:1/,http://host2:2/", | 742 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 764 GetDisplayedLocalStorages(&cookies_model)); | 743 GetDisplayedLocalStorages(&cookies_model)); |
| 765 EXPECT_EQ("http://host1:1/,http://host2:2/", | 744 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 766 GetDisplayedSessionStorages(&cookies_model)); | 745 GetDisplayedSessionStorages(&cookies_model)); |
| 767 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 746 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 768 GetDisplayedIndexedDBs(&cookies_model)); | 747 GetDisplayedIndexedDBs(&cookies_model)); |
| 769 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 748 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 770 GetDisplayedFileSystems(&cookies_model)); | 749 GetDisplayedFileSystems(&cookies_model)); |
| 771 } | 750 } |
| 772 } | 751 } |
| 773 | 752 |
| 774 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { | 753 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { |
| 775 net::CookieMonster* monster = profile_->GetCookieMonster(); | 754 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, |
| 776 monster->SetCookie(GURL("http://foo1"), "A=1"); | |
| 777 monster->SetCookie(GURL("http://foo2"), "B=1"); | |
| 778 monster->SetCookie(GURL("http://foo3"), "C=1"); | |
| 779 monster->SetCookie(GURL("http://foo3"), "D=1"); | |
| 780 monster->SetCookie(GURL("http://foo3"), "E=1"); | |
| 781 CookiesTreeModel cookies_model(monster, | |
| 782 mock_browsing_data_database_helper_, | 755 mock_browsing_data_database_helper_, |
| 783 mock_browsing_data_local_storage_helper_, | 756 mock_browsing_data_local_storage_helper_, |
| 784 mock_browsing_data_session_storage_helper_, | 757 mock_browsing_data_session_storage_helper_, |
| 785 mock_browsing_data_appcache_helper_, | 758 mock_browsing_data_appcache_helper_, |
| 786 mock_browsing_data_indexed_db_helper_, | 759 mock_browsing_data_indexed_db_helper_, |
| 787 mock_browsing_data_file_system_helper_, | 760 mock_browsing_data_file_system_helper_, |
| 788 false); | 761 false); |
| 762 mock_browsing_data_cookie_helper_-> |
| 763 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 764 mock_browsing_data_cookie_helper_-> |
| 765 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 766 mock_browsing_data_cookie_helper_-> |
| 767 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 768 mock_browsing_data_cookie_helper_-> |
| 769 AddCookieSamples(GURL("http://foo3"), "D=1"); |
| 770 mock_browsing_data_cookie_helper_-> |
| 771 AddCookieSamples(GURL("http://foo3"), "E=1"); |
| 772 mock_browsing_data_cookie_helper_->Notify(); |
| 773 |
| 789 { | 774 { |
| 790 SCOPED_TRACE("Initial State 5 cookies"); | 775 SCOPED_TRACE("Initial State 5 cookies"); |
| 791 // 11 because there's the root, then foo1 -> cookies -> a, | 776 // 11 because there's the root, then foo1 -> cookies -> a, |
| 792 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 777 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
| 793 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); | 778 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 794 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); | |
| 795 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 779 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 796 } | 780 } |
| 797 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); | 781 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); |
| 798 { | 782 { |
| 799 SCOPED_TRACE("Second origin removed"); | 783 SCOPED_TRACE("Second origin removed"); |
| 800 EXPECT_STREQ("A,C,D,E", GetMonsterCookies(monster).c_str()); | |
| 801 EXPECT_STREQ("A,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 784 EXPECT_STREQ("A,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 802 // Left with root -> foo1 -> cookies -> a, foo3 -> cookies -> c,d,e | 785 // Left with root -> foo1 -> cookies -> a, foo3 -> cookies -> c,d,e |
| 803 EXPECT_EQ(9, cookies_model.GetRoot()->GetTotalNodeCount()); | 786 EXPECT_EQ(9, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 804 } | 787 } |
| 805 } | 788 } |
| 806 | 789 |
| 807 TEST_F(CookiesTreeModelTest, OriginOrdering) { | 790 TEST_F(CookiesTreeModelTest, OriginOrdering) { |
| 808 net::CookieMonster* monster = profile_->GetCookieMonster(); | 791 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, |
| 809 monster->SetCookie(GURL("http://a.foo2.com"), "A=1"); | 792 mock_browsing_data_database_helper_, |
| 810 monster->SetCookie(GURL("http://foo2.com"), "B=1"); | 793 mock_browsing_data_local_storage_helper_, |
| 811 monster->SetCookie(GURL("http://b.foo1.com"), "C=1"); | 794 mock_browsing_data_session_storage_helper_, |
| 812 monster->SetCookie(GURL("http://foo4.com"), "D=1; domain=.foo4.com;" | 795 mock_browsing_data_appcache_helper_, |
| 813 " path=/;"); // Leading dot on the foo4 | 796 mock_browsing_data_indexed_db_helper_, |
| 814 monster->SetCookie(GURL("http://a.foo1.com"), "E=1"); | 797 mock_browsing_data_file_system_helper_, |
| 815 monster->SetCookie(GURL("http://foo1.com"), "F=1"); | 798 false); |
| 816 monster->SetCookie(GURL("http://foo3.com"), "G=1"); | 799 mock_browsing_data_cookie_helper_-> |
| 817 monster->SetCookie(GURL("http://foo4.com"), "H=1"); | 800 AddCookieSamples(GURL("http://a.foo2.com"), "A=1"); |
| 818 | 801 mock_browsing_data_cookie_helper_-> |
| 819 CookiesTreeModel cookies_model(monster, | 802 AddCookieSamples(GURL("http://foo2.com"), "B=1"); |
| 820 new MockBrowsingDataDatabaseHelper(profile_.get()), | 803 mock_browsing_data_cookie_helper_-> |
| 821 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 804 AddCookieSamples(GURL("http://b.foo1.com"), "C=1"); |
| 822 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 805 // Leading dot on the foo4 |
| 823 new MockBrowsingDataAppCacheHelper(profile_.get()), | 806 mock_browsing_data_cookie_helper_->AddCookieSamples( |
| 824 new MockBrowsingDataIndexedDBHelper(profile_.get()), | 807 GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;"); |
| 825 new MockBrowsingDataFileSystemHelper(profile_.get()), | 808 mock_browsing_data_cookie_helper_-> |
| 826 false); | 809 AddCookieSamples(GURL("http://a.foo1.com"), "E=1"); |
| 810 mock_browsing_data_cookie_helper_-> |
| 811 AddCookieSamples(GURL("http://foo1.com"), "F=1"); |
| 812 mock_browsing_data_cookie_helper_-> |
| 813 AddCookieSamples(GURL("http://foo3.com"), "G=1"); |
| 814 mock_browsing_data_cookie_helper_-> |
| 815 AddCookieSamples(GURL("http://foo4.com"), "H=1"); |
| 816 mock_browsing_data_cookie_helper_->Notify(); |
| 827 | 817 |
| 828 { | 818 { |
| 829 SCOPED_TRACE("Initial State 8 cookies"); | 819 SCOPED_TRACE("Initial State 8 cookies"); |
| 830 // CookieMonster orders cookies by pathlength, then by creation time. | 820 EXPECT_EQ(23, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 831 // All paths are length 1. | |
| 832 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", | 821 EXPECT_STREQ("F,E,C,B,A,G,D,H", |
| 834 GetDisplayedCookies(&cookies_model).c_str()); | 822 GetDisplayedCookies(&cookies_model).c_str()); |
| 835 } | 823 } |
| 836 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E" | 824 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E" |
| 837 { | 825 { |
| 838 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()); | 826 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); |
| 840 } | 827 } |
| 841 } | 828 } |
| 842 | 829 |
| 843 TEST_F(CookiesTreeModelTest, ContentSettings) { | 830 TEST_F(CookiesTreeModelTest, ContentSettings) { |
| 844 GURL host("http://example.com/"); | 831 GURL host("http://example.com/"); |
| 845 net::CookieMonster* monster = profile_->GetCookieMonster(); | 832 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, |
| 846 monster->SetCookie(host, "A=1"); | 833 mock_browsing_data_database_helper_, |
| 847 | 834 mock_browsing_data_local_storage_helper_, |
| 848 CookiesTreeModel cookies_model(monster, | 835 mock_browsing_data_session_storage_helper_, |
| 849 new MockBrowsingDataDatabaseHelper(profile_.get()), | 836 mock_browsing_data_appcache_helper_, |
| 850 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 837 mock_browsing_data_indexed_db_helper_, |
| 851 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 838 mock_browsing_data_file_system_helper_, |
| 852 new MockBrowsingDataAppCacheHelper(profile_.get()), | 839 false); |
| 853 new MockBrowsingDataIndexedDBHelper(profile_.get()), | 840 mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1"); |
| 854 new MockBrowsingDataFileSystemHelper(profile_.get()), | 841 mock_browsing_data_cookie_helper_->Notify(); |
| 855 false); | |
| 856 | 842 |
| 857 TestingProfile profile; | 843 TestingProfile profile; |
| 858 HostContentSettingsMap* content_settings = | 844 HostContentSettingsMap* content_settings = |
| 859 profile.GetHostContentSettingsMap(); | 845 profile.GetHostContentSettingsMap(); |
| 860 MockSettingsObserver observer; | 846 MockSettingsObserver observer; |
| 861 | 847 |
| 862 CookieTreeRootNode* root = | 848 CookieTreeRootNode* root = |
| 863 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); | 849 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); |
| 864 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); | 850 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); |
| 865 | 851 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 cookies_model->UpdateSearchResults(std::wstring(L"fshost3")); | 887 cookies_model->UpdateSearchResults(std::wstring(L"fshost3")); |
| 902 EXPECT_EQ("http://fshost3:3/", | 888 EXPECT_EQ("http://fshost3:3/", |
| 903 GetDisplayedFileSystems(cookies_model.get())); | 889 GetDisplayedFileSystems(cookies_model.get())); |
| 904 | 890 |
| 905 cookies_model->UpdateSearchResults(std::wstring()); | 891 cookies_model->UpdateSearchResults(std::wstring()); |
| 906 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 892 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 907 GetDisplayedFileSystems(cookies_model.get())); | 893 GetDisplayedFileSystems(cookies_model.get())); |
| 908 } | 894 } |
| 909 | 895 |
| 910 } // namespace | 896 } // namespace |
| OLD | NEW |