| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/content_settings/cookie_settings.h" | 10 #include "chrome/browser/content_settings/cookie_settings.h" |
| 11 #include "chrome/browser/content_settings/host_content_settings_map.h" | 11 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 12 #include "chrome/browser/content_settings/mock_settings_observer.h" | 12 #include "chrome/browser/content_settings/mock_settings_observer.h" |
| 13 #include "chrome/browser/mock_browsing_data_appcache_helper.h" | 13 #include "chrome/browser/mock_browsing_data_appcache_helper.h" |
| 14 #include "chrome/browser/mock_browsing_data_cookie_helper.h" | 14 #include "chrome/browser/mock_browsing_data_cookie_helper.h" |
| 15 #include "chrome/browser/mock_browsing_data_database_helper.h" | 15 #include "chrome/browser/mock_browsing_data_database_helper.h" |
| 16 #include "chrome/browser/mock_browsing_data_file_system_helper.h" | 16 #include "chrome/browser/mock_browsing_data_file_system_helper.h" |
| 17 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" | 17 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" |
| 18 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" | 18 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" |
| 19 #include "chrome/browser/mock_browsing_data_quota_helper.h" | 19 #include "chrome/browser/mock_browsing_data_quota_helper.h" |
| 20 #include "chrome/browser/mock_browsing_data_server_bound_cert_helper.h" | 20 #include "chrome/browser/mock_browsing_data_server_bound_cert_helper.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 22 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
| 23 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
| 24 #include "content/public/test/test_browser_thread.h" | 24 #include "content/public/test/test_browser_thread.h" |
| 25 #include "net/base/net_util.h" |
| 25 #include "net/url_request/url_request_context.h" | 26 #include "net/url_request/url_request_context.h" |
| 26 #include "net/url_request/url_request_context_getter.h" | 27 #include "net/url_request/url_request_context_getter.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 29 |
| 29 #include "base/utf_string_conversions.h" | 30 #include "base/utf_string_conversions.h" |
| 30 | 31 |
| 31 using ::testing::_; | 32 using ::testing::_; |
| 32 using content::BrowserThread; | 33 using content::BrowserThread; |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 61 mock_browsing_data_appcache_helper_ = | 62 mock_browsing_data_appcache_helper_ = |
| 62 new MockBrowsingDataAppCacheHelper(profile_.get()); | 63 new MockBrowsingDataAppCacheHelper(profile_.get()); |
| 63 mock_browsing_data_indexed_db_helper_ = | 64 mock_browsing_data_indexed_db_helper_ = |
| 64 new MockBrowsingDataIndexedDBHelper(); | 65 new MockBrowsingDataIndexedDBHelper(); |
| 65 mock_browsing_data_file_system_helper_ = | 66 mock_browsing_data_file_system_helper_ = |
| 66 new MockBrowsingDataFileSystemHelper(profile_.get()); | 67 new MockBrowsingDataFileSystemHelper(profile_.get()); |
| 67 mock_browsing_data_quota_helper_ = | 68 mock_browsing_data_quota_helper_ = |
| 68 new MockBrowsingDataQuotaHelper(profile_.get()); | 69 new MockBrowsingDataQuotaHelper(profile_.get()); |
| 69 mock_browsing_data_server_bound_cert_helper_ = | 70 mock_browsing_data_server_bound_cert_helper_ = |
| 70 new MockBrowsingDataServerBoundCertHelper(); | 71 new MockBrowsingDataServerBoundCertHelper(); |
| 72 |
| 73 // It is fine to reuse the profile request context for the app, since |
| 74 // the mock cookie helper maintains its own list internally and doesn't |
| 75 // really use the request context. Same is true for the rest. |
| 76 mock_browsing_data_cookie_helper_app_ = |
| 77 new MockBrowsingDataCookieHelper(profile_->GetRequestContext()); |
| 78 mock_browsing_data_database_helper_app_ = |
| 79 new MockBrowsingDataDatabaseHelper(profile_.get()); |
| 80 mock_browsing_data_local_storage_helper_app_ = |
| 81 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
| 71 } | 82 } |
| 72 | 83 |
| 73 virtual void TearDown() OVERRIDE { | 84 virtual void TearDown() OVERRIDE { |
| 74 mock_browsing_data_server_bound_cert_helper_ = NULL; | 85 mock_browsing_data_server_bound_cert_helper_ = NULL; |
| 75 mock_browsing_data_quota_helper_ = NULL; | 86 mock_browsing_data_quota_helper_ = NULL; |
| 76 mock_browsing_data_file_system_helper_ = NULL; | 87 mock_browsing_data_file_system_helper_ = NULL; |
| 77 mock_browsing_data_indexed_db_helper_ = NULL; | 88 mock_browsing_data_indexed_db_helper_ = NULL; |
| 78 mock_browsing_data_appcache_helper_ = NULL; | 89 mock_browsing_data_appcache_helper_ = NULL; |
| 79 mock_browsing_data_session_storage_helper_ = NULL; | 90 mock_browsing_data_session_storage_helper_ = NULL; |
| 80 mock_browsing_data_local_storage_helper_ = NULL; | 91 mock_browsing_data_local_storage_helper_ = NULL; |
| 81 mock_browsing_data_database_helper_ = NULL; | 92 mock_browsing_data_database_helper_ = NULL; |
| 82 message_loop_.RunAllPending(); | 93 message_loop_.RunAllPending(); |
| 83 } | 94 } |
| 84 | 95 |
| 85 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { | 96 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample(bool add_app) { |
| 86 CookiesTreeModel* cookies_model = new CookiesTreeModel( | 97 ContainerMap containers_map; |
| 98 string16 browser_id; |
| 99 |
| 100 LocalDataContainer* container = new LocalDataContainer( |
| 101 ASCIIToUTF16("Drive-By-Web"), browser_id, |
| 87 mock_browsing_data_cookie_helper_, | 102 mock_browsing_data_cookie_helper_, |
| 88 mock_browsing_data_database_helper_, | 103 mock_browsing_data_database_helper_, |
| 89 mock_browsing_data_local_storage_helper_, | 104 mock_browsing_data_local_storage_helper_, |
| 90 mock_browsing_data_session_storage_helper_, | 105 mock_browsing_data_session_storage_helper_, |
| 91 mock_browsing_data_appcache_helper_, | 106 mock_browsing_data_appcache_helper_, |
| 92 mock_browsing_data_indexed_db_helper_, | 107 mock_browsing_data_indexed_db_helper_, |
| 93 mock_browsing_data_file_system_helper_, | 108 mock_browsing_data_file_system_helper_, |
| 94 mock_browsing_data_quota_helper_, | 109 mock_browsing_data_quota_helper_, |
| 95 mock_browsing_data_server_bound_cert_helper_, | 110 mock_browsing_data_server_bound_cert_helper_); |
| 96 false); | 111 containers_map[browser_id] = container; |
| 112 |
| 113 if (add_app) { |
| 114 string16 app_id = ASCIIToUTF16("some-random-id"); |
| 115 // The three helpers are mandatory, the rest can be NULL. |
| 116 LocalDataContainer* app_container = new LocalDataContainer( |
| 117 ASCIIToUTF16("Isolated App"), app_id, |
| 118 mock_browsing_data_cookie_helper_app_, |
| 119 mock_browsing_data_database_helper_app_, |
| 120 mock_browsing_data_local_storage_helper_app_, |
| 121 NULL, |
| 122 NULL, |
| 123 NULL, |
| 124 NULL, |
| 125 NULL, |
| 126 NULL); |
| 127 containers_map[app_id] = app_container; |
| 128 } |
| 129 |
| 130 CookiesTreeModel* cookies_model = new CookiesTreeModel(containers_map, |
| 131 false); |
| 97 mock_browsing_data_cookie_helper_-> | 132 mock_browsing_data_cookie_helper_-> |
| 98 AddCookieSamples(GURL("http://foo1"), "A=1"); | 133 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 99 mock_browsing_data_cookie_helper_-> | 134 mock_browsing_data_cookie_helper_-> |
| 100 AddCookieSamples(GURL("http://foo2"), "B=1"); | 135 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 101 mock_browsing_data_cookie_helper_-> | 136 mock_browsing_data_cookie_helper_-> |
| 102 AddCookieSamples(GURL("http://foo3"), "C=1"); | 137 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 103 mock_browsing_data_cookie_helper_->Notify(); | 138 mock_browsing_data_cookie_helper_->Notify(); |
| 104 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 139 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 105 mock_browsing_data_database_helper_->Notify(); | 140 mock_browsing_data_database_helper_->Notify(); |
| 106 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 141 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 107 mock_browsing_data_local_storage_helper_->Notify(); | 142 mock_browsing_data_local_storage_helper_->Notify(); |
| 108 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 143 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 109 mock_browsing_data_session_storage_helper_->Notify(); | 144 mock_browsing_data_session_storage_helper_->Notify(); |
| 110 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 145 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 111 mock_browsing_data_indexed_db_helper_->Notify(); | 146 mock_browsing_data_indexed_db_helper_->Notify(); |
| 112 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 147 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 113 mock_browsing_data_file_system_helper_->Notify(); | 148 mock_browsing_data_file_system_helper_->Notify(); |
| 114 mock_browsing_data_quota_helper_->AddQuotaSamples(); | 149 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
| 115 mock_browsing_data_quota_helper_->Notify(); | 150 mock_browsing_data_quota_helper_->Notify(); |
| 116 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( | 151 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( |
| 117 "sbc1"); | 152 "sbc1"); |
| 118 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( | 153 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( |
| 119 "sbc2"); | 154 "sbc2"); |
| 120 mock_browsing_data_server_bound_cert_helper_->Notify(); | 155 mock_browsing_data_server_bound_cert_helper_->Notify(); |
| 156 |
| 157 if (add_app) { |
| 158 mock_browsing_data_cookie_helper_app_-> |
| 159 AddCookieSamples(GURL("http://app1"), "Z=1"); |
| 160 mock_browsing_data_cookie_helper_app_-> |
| 161 AddCookieSamples(GURL("http://app2"), "Y=1"); |
| 162 mock_browsing_data_cookie_helper_app_-> |
| 163 AddCookieSamples(GURL("http://app3"), "X=1"); |
| 164 mock_browsing_data_cookie_helper_app_->Notify(); |
| 165 } |
| 166 |
| 121 { | 167 { |
| 122 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " | 168 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " |
| 123 "2 session storages, 2 indexed DBs, 3 filesystems, " | 169 "2 session storages, 2 indexed DBs, 3 filesystems, " |
| 124 "2 quotas"); | 170 "2 quotas, 2 server bound certs"); |
| 125 // 45 because there's the root, then foo1 -> cookies -> a, | 171 // 52 because there's the root, then the app node, |
| 126 // foo2 -> cookies -> b, foo3 -> cookies -> c, | 172 // foo1 -> cookies -> a, |
| 127 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 173 // foo2 -> cookies -> b, |
| 174 // foo3 -> cookies -> c, |
| 175 // dbhost1 -> database -> db1, |
| 176 // dbhost2 -> database -> db2, |
| 177 // host1 -> localstorage -> http://host1:1/, |
| 178 // -> sessionstorage -> http://host1:1/, |
| 179 // host2 -> localstorage -> http://host2:2/. |
| 180 // -> sessionstorage -> http://host2:2/, |
| 181 // idbhost1 -> indexeddb -> http://idbhost1:1/, |
| 182 // idbhost2 -> indexeddb -> http://idbhost2:2/, |
| 128 // fshost1 -> filesystem -> http://fshost1:1/, | 183 // fshost1 -> filesystem -> http://fshost1:1/, |
| 129 // fshost2 -> filesystem -> http://fshost2:1/, | 184 // fshost2 -> filesystem -> http://fshost2:1/, |
| 130 // fshost3 -> filesystem -> http://fshost3:1/, | 185 // fshost3 -> filesystem -> http://fshost3:1/, |
| 131 // host1 -> localstorage -> http://host1:1/, | |
| 132 // host2 -> localstorage -> http://host2:2/. | |
| 133 // host1 -> sessionstorage -> http://host1:1/, | |
| 134 // host2 -> sessionstorage -> http://host2:2/, | |
| 135 // idbhost1 -> indexeddb -> http://idbhost1:1/, | |
| 136 // idbhost2 -> indexeddb -> http://idbhost2:2/, | |
| 137 // quotahost1 -> quotahost1, | 186 // quotahost1 -> quotahost1, |
| 138 // quotahost2 -> quotahost2, | 187 // quotahost2 -> quotahost2, |
| 139 // sbc1 -> sbcerts -> sbc1, | 188 // sbc1 -> sbcerts -> sbc1, |
| 140 // sbc2 -> sbcerts -> sbc2. | 189 // sbc2 -> sbcerts -> sbc2. |
| 141 EXPECT_EQ(51, cookies_model->GetRoot()->GetTotalNodeCount()); | 190 if (!add_app) { |
| 142 EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model)); | 191 EXPECT_EQ(52, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 192 EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model)); |
| 193 } else { |
| 194 // Once we add the app, we have 10 more nodes, one for the app, then |
| 195 // app1 -> cookies -> z, |
| 196 // app2 -> cookies -> y, |
| 197 // app3 -> cookies -> x, |
| 198 EXPECT_EQ(62, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 199 EXPECT_EQ("A,B,C,Z,Y,X", GetDisplayedCookies(cookies_model)); |
| 200 } |
| 143 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); | 201 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); |
| 144 EXPECT_EQ("http://host1:1/,http://host2:2/", | 202 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 145 GetDisplayedLocalStorages(cookies_model)); | 203 GetDisplayedLocalStorages(cookies_model)); |
| 146 EXPECT_EQ("http://host1:1/,http://host2:2/", | 204 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 147 GetDisplayedSessionStorages(cookies_model)); | 205 GetDisplayedSessionStorages(cookies_model)); |
| 148 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 206 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 149 GetDisplayedIndexedDBs(cookies_model)); | 207 GetDisplayedIndexedDBs(cookies_model)); |
| 150 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 208 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 151 GetDisplayedFileSystems(cookies_model)); | 209 GetDisplayedFileSystems(cookies_model)); |
| 152 EXPECT_EQ("quotahost1,quotahost2", | 210 EXPECT_EQ("quotahost1,quotahost2", |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 scoped_refptr<MockBrowsingDataAppCacheHelper> | 378 scoped_refptr<MockBrowsingDataAppCacheHelper> |
| 321 mock_browsing_data_appcache_helper_; | 379 mock_browsing_data_appcache_helper_; |
| 322 scoped_refptr<MockBrowsingDataIndexedDBHelper> | 380 scoped_refptr<MockBrowsingDataIndexedDBHelper> |
| 323 mock_browsing_data_indexed_db_helper_; | 381 mock_browsing_data_indexed_db_helper_; |
| 324 scoped_refptr<MockBrowsingDataFileSystemHelper> | 382 scoped_refptr<MockBrowsingDataFileSystemHelper> |
| 325 mock_browsing_data_file_system_helper_; | 383 mock_browsing_data_file_system_helper_; |
| 326 scoped_refptr<MockBrowsingDataQuotaHelper> | 384 scoped_refptr<MockBrowsingDataQuotaHelper> |
| 327 mock_browsing_data_quota_helper_; | 385 mock_browsing_data_quota_helper_; |
| 328 scoped_refptr<MockBrowsingDataServerBoundCertHelper> | 386 scoped_refptr<MockBrowsingDataServerBoundCertHelper> |
| 329 mock_browsing_data_server_bound_cert_helper_; | 387 mock_browsing_data_server_bound_cert_helper_; |
| 388 |
| 389 // App helpers. |
| 390 scoped_refptr<MockBrowsingDataCookieHelper> |
| 391 mock_browsing_data_cookie_helper_app_; |
| 392 scoped_refptr<MockBrowsingDataDatabaseHelper> |
| 393 mock_browsing_data_database_helper_app_; |
| 394 scoped_refptr<MockBrowsingDataLocalStorageHelper> |
| 395 mock_browsing_data_local_storage_helper_app_; |
| 330 }; | 396 }; |
| 331 | 397 |
| 332 TEST_F(CookiesTreeModelTest, RemoveAll) { | 398 TEST_F(CookiesTreeModelTest, RemoveAll) { |
| 333 scoped_ptr<CookiesTreeModel> cookies_model( | 399 scoped_ptr<CookiesTreeModel> cookies_model( |
| 334 CreateCookiesTreeModelWithInitialSample()); | 400 CreateCookiesTreeModelWithInitialSample(false)); |
| 335 | 401 |
| 336 // Reset the selection of the first row. | 402 // Reset the selection of the first row. |
| 337 { | 403 { |
| 338 SCOPED_TRACE("Before removing"); | 404 SCOPED_TRACE("Before removing"); |
| 339 EXPECT_EQ("A,B,C", | 405 EXPECT_EQ("A,B,C", |
| 340 GetDisplayedCookies(cookies_model.get())); | 406 GetDisplayedCookies(cookies_model.get())); |
| 341 EXPECT_EQ("db1,db2", | 407 EXPECT_EQ("db1,db2", |
| 342 GetDisplayedDatabases(cookies_model.get())); | 408 GetDisplayedDatabases(cookies_model.get())); |
| 343 EXPECT_EQ("http://host1:1/,http://host2:2/", | 409 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 344 GetDisplayedLocalStorages(cookies_model.get())); | 410 GetDisplayedLocalStorages(cookies_model.get())); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 358 mock_browsing_data_database_helper_->Reset(); | 424 mock_browsing_data_database_helper_->Reset(); |
| 359 mock_browsing_data_local_storage_helper_->Reset(); | 425 mock_browsing_data_local_storage_helper_->Reset(); |
| 360 mock_browsing_data_session_storage_helper_->Reset(); | 426 mock_browsing_data_session_storage_helper_->Reset(); |
| 361 mock_browsing_data_indexed_db_helper_->Reset(); | 427 mock_browsing_data_indexed_db_helper_->Reset(); |
| 362 mock_browsing_data_file_system_helper_->Reset(); | 428 mock_browsing_data_file_system_helper_->Reset(); |
| 363 | 429 |
| 364 cookies_model->DeleteAllStoredObjects(); | 430 cookies_model->DeleteAllStoredObjects(); |
| 365 | 431 |
| 366 // Make sure the nodes are also deleted from the model's cache. | 432 // Make sure the nodes are also deleted from the model's cache. |
| 367 // http://crbug.com/43249 | 433 // http://crbug.com/43249 |
| 368 cookies_model->UpdateSearchResults(std::wstring()); | 434 cookies_model->UpdateSearchResults(string16()); |
| 369 | 435 |
| 370 { | 436 { |
| 437 // 2 nodes - root and app |
| 371 SCOPED_TRACE("After removing"); | 438 SCOPED_TRACE("After removing"); |
| 372 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); | 439 EXPECT_EQ(2, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 373 EXPECT_EQ(0, cookies_model->GetRoot()->child_count()); | 440 EXPECT_EQ(1, cookies_model->GetRoot()->child_count()); |
| 374 EXPECT_EQ(std::string(""), GetDisplayedCookies(cookies_model.get())); | 441 EXPECT_EQ(std::string(""), GetDisplayedCookies(cookies_model.get())); |
| 375 EXPECT_TRUE(mock_browsing_data_cookie_helper_->AllDeleted()); | 442 EXPECT_TRUE(mock_browsing_data_cookie_helper_->AllDeleted()); |
| 376 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); | 443 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); |
| 377 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); | 444 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); |
| 378 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted()); | 445 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted()); |
| 379 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted()); | 446 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted()); |
| 380 EXPECT_TRUE(mock_browsing_data_file_system_helper_->AllDeleted()); | 447 EXPECT_TRUE(mock_browsing_data_file_system_helper_->AllDeleted()); |
| 381 EXPECT_TRUE(mock_browsing_data_server_bound_cert_helper_->AllDeleted()); | 448 EXPECT_TRUE(mock_browsing_data_server_bound_cert_helper_->AllDeleted()); |
| 382 } | 449 } |
| 383 } | 450 } |
| 384 | 451 |
| 385 TEST_F(CookiesTreeModelTest, Remove) { | 452 TEST_F(CookiesTreeModelTest, Remove) { |
| 386 scoped_ptr<CookiesTreeModel> cookies_model( | 453 scoped_ptr<CookiesTreeModel> cookies_model( |
| 387 CreateCookiesTreeModelWithInitialSample()); | 454 CreateCookiesTreeModelWithInitialSample(false)); |
| 388 | 455 |
| 389 // Children start out arranged as follows: | 456 // Children start out arranged as follows: |
| 390 // | 457 // |
| 391 // 0. `foo1` | 458 // 0. `foo1` |
| 392 // 1. `foo2` | 459 // 1. `foo2` |
| 393 // 2. `foo3` | 460 // 2. `foo3` |
| 394 // 3. `fshost1` | 461 // 3. `fshost1` |
| 395 // 4. `fshost2` | 462 // 4. `fshost2` |
| 396 // 5. `fshost3` | 463 // 5. `fshost3` |
| 397 // 6. `gdbhost1` | 464 // 6. `gdbhost1` |
| 398 // 7. `gdbhost2` | 465 // 7. `gdbhost2` |
| 399 // 8. `host1` | 466 // 8. `host1` |
| 400 // 9. `host2` | 467 // 9. `host2` |
| 401 // 10. `idbhost1` | 468 // 10. `idbhost1` |
| 402 // 11. `idbhost2` | 469 // 11. `idbhost2` |
| 403 // 12. `quotahost1` | 470 // 12. `quotahost1` |
| 404 // 13. `quotahost2` | 471 // 13. `quotahost2` |
| 405 // 14. `sbc1` | 472 // 14. `sbc1` |
| 406 // 15. `sbc2` | 473 // 15. `sbc2` |
| 407 // | 474 // |
| 408 // Here, we'll remove them one by one, starting from the end, and | 475 // Here, we'll remove them one by one, starting from the end, and |
| 409 // check that the state makes sense. | 476 // check that the state makes sense. |
| 410 | 477 |
| 411 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(15)); | 478 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(15)); |
| 412 { | 479 { |
| 413 SCOPED_TRACE("`sbc2` removed."); | 480 SCOPED_TRACE("`sbc2` removed."); |
| 414 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 481 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 415 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 482 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 416 EXPECT_EQ("http://host1:1/,http://host2:2/", | 483 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 417 GetDisplayedLocalStorages(cookies_model.get())); | 484 GetDisplayedLocalStorages(cookies_model.get())); |
| 418 EXPECT_EQ("http://host1:1/,http://host2:2/", | 485 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 419 GetDisplayedSessionStorages(cookies_model.get())); | 486 GetDisplayedSessionStorages(cookies_model.get())); |
| 420 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 487 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 421 GetDisplayedFileSystems(cookies_model.get())); | 488 GetDisplayedFileSystems(cookies_model.get())); |
| 422 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 489 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 423 GetDisplayedIndexedDBs(cookies_model.get())); | 490 GetDisplayedIndexedDBs(cookies_model.get())); |
| 424 EXPECT_EQ("quotahost1,quotahost2", | 491 EXPECT_EQ("quotahost1,quotahost2", |
| 425 GetDisplayedQuotas(cookies_model.get())); | 492 GetDisplayedQuotas(cookies_model.get())); |
| 426 EXPECT_EQ("sbc1", | 493 EXPECT_EQ("sbc1", |
| 427 GetDisplayedServerBoundCerts(cookies_model.get())); | 494 GetDisplayedServerBoundCerts(cookies_model.get())); |
| 428 EXPECT_EQ(48, cookies_model->GetRoot()->GetTotalNodeCount()); | 495 EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 429 } | 496 } |
| 430 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(14)); | 497 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(14)); |
| 431 { | 498 { |
| 432 SCOPED_TRACE("`sbc1` removed."); | 499 SCOPED_TRACE("`sbc1` removed."); |
| 433 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 500 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 434 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 501 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 435 EXPECT_EQ("http://host1:1/,http://host2:2/", | 502 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 436 GetDisplayedLocalStorages(cookies_model.get())); | 503 GetDisplayedLocalStorages(cookies_model.get())); |
| 437 EXPECT_EQ("http://host1:1/,http://host2:2/", | 504 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 438 GetDisplayedSessionStorages(cookies_model.get())); | 505 GetDisplayedSessionStorages(cookies_model.get())); |
| 439 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 506 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 440 GetDisplayedFileSystems(cookies_model.get())); | 507 GetDisplayedFileSystems(cookies_model.get())); |
| 441 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 508 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 442 GetDisplayedIndexedDBs(cookies_model.get())); | 509 GetDisplayedIndexedDBs(cookies_model.get())); |
| 443 EXPECT_EQ("quotahost1,quotahost2", | 510 EXPECT_EQ("quotahost1,quotahost2", |
| 444 GetDisplayedQuotas(cookies_model.get())); | 511 GetDisplayedQuotas(cookies_model.get())); |
| 445 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); | 512 EXPECT_EQ(46, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 446 } | 513 } |
| 447 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(13)); | 514 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(13)); |
| 448 { | 515 { |
| 449 SCOPED_TRACE("`quotahost2` removed."); | 516 SCOPED_TRACE("`quotahost2` removed."); |
| 450 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 517 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 451 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 518 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 452 EXPECT_EQ("http://host1:1/,http://host2:2/", | 519 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 453 GetDisplayedLocalStorages(cookies_model.get())); | 520 GetDisplayedLocalStorages(cookies_model.get())); |
| 454 EXPECT_EQ("http://host1:1/,http://host2:2/", | 521 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 455 GetDisplayedSessionStorages(cookies_model.get())); | 522 GetDisplayedSessionStorages(cookies_model.get())); |
| 456 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 523 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 457 GetDisplayedFileSystems(cookies_model.get())); | 524 GetDisplayedFileSystems(cookies_model.get())); |
| 458 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 525 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 459 GetDisplayedIndexedDBs(cookies_model.get())); | 526 GetDisplayedIndexedDBs(cookies_model.get())); |
| 460 EXPECT_EQ("quotahost1", | 527 EXPECT_EQ("quotahost1", |
| 461 GetDisplayedQuotas(cookies_model.get())); | 528 GetDisplayedQuotas(cookies_model.get())); |
| 462 EXPECT_EQ(43, cookies_model->GetRoot()->GetTotalNodeCount()); | 529 EXPECT_EQ(44, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 463 } | 530 } |
| 464 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(12)); | 531 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(12)); |
| 465 { | 532 { |
| 466 SCOPED_TRACE("`quotahost1` removed."); | 533 SCOPED_TRACE("`quotahost1` removed."); |
| 467 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 534 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 468 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 535 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 469 EXPECT_EQ("http://host1:1/,http://host2:2/", | 536 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 470 GetDisplayedLocalStorages(cookies_model.get())); | 537 GetDisplayedLocalStorages(cookies_model.get())); |
| 471 EXPECT_EQ("http://host1:1/,http://host2:2/", | 538 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 472 GetDisplayedSessionStorages(cookies_model.get())); | 539 GetDisplayedSessionStorages(cookies_model.get())); |
| 473 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 540 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 474 GetDisplayedFileSystems(cookies_model.get())); | 541 GetDisplayedFileSystems(cookies_model.get())); |
| 475 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 542 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 476 GetDisplayedIndexedDBs(cookies_model.get())); | 543 GetDisplayedIndexedDBs(cookies_model.get())); |
| 477 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); | 544 EXPECT_EQ(42, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 478 } | 545 } |
| 479 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(11)); | 546 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(11)); |
| 480 { | 547 { |
| 481 SCOPED_TRACE("`idbhost2` removed."); | 548 SCOPED_TRACE("`idbhost2` removed."); |
| 482 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 549 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 483 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 550 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 484 EXPECT_EQ("http://host1:1/,http://host2:2/", | 551 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 485 GetDisplayedLocalStorages(cookies_model.get())); | 552 GetDisplayedLocalStorages(cookies_model.get())); |
| 486 EXPECT_EQ("http://host1:1/,http://host2:2/", | 553 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 487 GetDisplayedSessionStorages(cookies_model.get())); | 554 GetDisplayedSessionStorages(cookies_model.get())); |
| 488 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 555 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 489 GetDisplayedFileSystems(cookies_model.get())); | 556 GetDisplayedFileSystems(cookies_model.get())); |
| 490 EXPECT_EQ("http://idbhost1:1/", | 557 EXPECT_EQ("http://idbhost1:1/", |
| 491 GetDisplayedIndexedDBs(cookies_model.get())); | 558 GetDisplayedIndexedDBs(cookies_model.get())); |
| 492 EXPECT_EQ(38, cookies_model->GetRoot()->GetTotalNodeCount()); | 559 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 493 } | 560 } |
| 494 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(10)); | 561 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(10)); |
| 495 { | 562 { |
| 496 SCOPED_TRACE("`idbhost1` removed."); | 563 SCOPED_TRACE("`idbhost1` removed."); |
| 497 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 564 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 498 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 565 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 499 EXPECT_EQ("http://host1:1/,http://host2:2/", | 566 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 500 GetDisplayedLocalStorages(cookies_model.get())); | 567 GetDisplayedLocalStorages(cookies_model.get())); |
| 501 EXPECT_EQ("http://host1:1/,http://host2:2/", | 568 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 502 GetDisplayedSessionStorages(cookies_model.get())); | 569 GetDisplayedSessionStorages(cookies_model.get())); |
| 503 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 570 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 504 GetDisplayedFileSystems(cookies_model.get())); | 571 GetDisplayedFileSystems(cookies_model.get())); |
| 505 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 572 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 506 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); | 573 EXPECT_EQ(36, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 507 } | 574 } |
| 508 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(9)); | 575 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(9)); |
| 509 { | 576 { |
| 510 SCOPED_TRACE("`host2` removed."); | 577 SCOPED_TRACE("`host2` removed."); |
| 511 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 578 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 512 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 579 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 513 EXPECT_EQ("http://host1:1/", | 580 EXPECT_EQ("http://host1:1/", |
| 514 GetDisplayedLocalStorages(cookies_model.get())); | 581 GetDisplayedLocalStorages(cookies_model.get())); |
| 515 EXPECT_EQ("http://host1:1/", | 582 EXPECT_EQ("http://host1:1/", |
| 516 GetDisplayedSessionStorages(cookies_model.get())); | 583 GetDisplayedSessionStorages(cookies_model.get())); |
| 517 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 584 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 518 GetDisplayedFileSystems(cookies_model.get())); | 585 GetDisplayedFileSystems(cookies_model.get())); |
| 519 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 586 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 520 EXPECT_EQ(30, cookies_model->GetRoot()->GetTotalNodeCount()); | 587 EXPECT_EQ(31, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 521 } | 588 } |
| 522 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)); | 589 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(8)); |
| 523 { | 590 { |
| 524 SCOPED_TRACE("`host1` removed."); | 591 SCOPED_TRACE("`host1` removed."); |
| 525 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 592 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 526 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 593 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 527 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 594 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 528 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 595 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 529 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 596 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 530 GetDisplayedFileSystems(cookies_model.get())); | 597 GetDisplayedFileSystems(cookies_model.get())); |
| 531 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 598 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 532 EXPECT_EQ(25, cookies_model->GetRoot()->GetTotalNodeCount()); | 599 EXPECT_EQ(26, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 533 } | 600 } |
| 534 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(7)); | 601 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(7)); |
| 535 { | 602 { |
| 536 SCOPED_TRACE("`gdbhost2` removed."); | 603 SCOPED_TRACE("`gdbhost2` removed."); |
| 537 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 604 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 538 EXPECT_EQ("db1", GetDisplayedDatabases(cookies_model.get())); | 605 EXPECT_EQ("db1", GetDisplayedDatabases(cookies_model.get())); |
| 539 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 606 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 540 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 607 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 541 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 608 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 542 GetDisplayedFileSystems(cookies_model.get())); | 609 GetDisplayedFileSystems(cookies_model.get())); |
| 543 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 610 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 544 EXPECT_EQ(22, cookies_model->GetRoot()->GetTotalNodeCount()); | 611 EXPECT_EQ(23, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 545 } | 612 } |
| 546 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)); | 613 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(6)); |
| 547 { | 614 { |
| 548 SCOPED_TRACE("`gdbhost1` removed."); | 615 SCOPED_TRACE("`gdbhost1` removed."); |
| 549 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 616 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 550 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 617 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 551 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 618 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 552 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 619 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 553 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 620 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 554 GetDisplayedFileSystems(cookies_model.get())); | 621 GetDisplayedFileSystems(cookies_model.get())); |
| 555 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 622 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 556 EXPECT_EQ(19, cookies_model->GetRoot()->GetTotalNodeCount()); | 623 EXPECT_EQ(20, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 557 } | 624 } |
| 558 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(5)); | 625 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(5)); |
| 559 { | 626 { |
| 560 SCOPED_TRACE("`fshost3` removed."); | 627 SCOPED_TRACE("`fshost3` removed."); |
| 561 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 628 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 562 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 629 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 563 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 630 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 564 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 631 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 565 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/", | 632 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/", |
| 566 GetDisplayedFileSystems(cookies_model.get())); | 633 GetDisplayedFileSystems(cookies_model.get())); |
| 567 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 634 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 568 EXPECT_EQ(16, cookies_model->GetRoot()->GetTotalNodeCount()); | 635 EXPECT_EQ(17, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 569 } | 636 } |
| 570 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(4)); | 637 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(4)); |
| 571 { | 638 { |
| 572 SCOPED_TRACE("`fshost2` removed."); | 639 SCOPED_TRACE("`fshost2` removed."); |
| 573 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 640 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 574 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 641 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 575 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 642 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 576 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 643 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 577 EXPECT_EQ("http://fshost1:1/", | 644 EXPECT_EQ("http://fshost1:1/", |
| 578 GetDisplayedFileSystems(cookies_model.get())); | 645 GetDisplayedFileSystems(cookies_model.get())); |
| 579 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 646 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 580 EXPECT_EQ(13, cookies_model->GetRoot()->GetTotalNodeCount()); | 647 EXPECT_EQ(14, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 581 } | 648 } |
| 582 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(3)); | 649 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(3)); |
| 583 { | 650 { |
| 584 SCOPED_TRACE("`fshost1` removed."); | 651 SCOPED_TRACE("`fshost1` removed."); |
| 585 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 652 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 586 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 653 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 587 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 654 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 588 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 655 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 589 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); | 656 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 590 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 657 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 591 EXPECT_EQ(10, cookies_model->GetRoot()->GetTotalNodeCount()); | 658 EXPECT_EQ(11, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 592 } | 659 } |
| 593 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(2)); | 660 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(2)); |
| 594 { | 661 { |
| 595 SCOPED_TRACE("`foo3` removed."); | 662 SCOPED_TRACE("`foo3` removed."); |
| 596 EXPECT_STREQ("A,B", GetDisplayedCookies(cookies_model.get()).c_str()); | 663 EXPECT_STREQ("A,B", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 597 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 664 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 598 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 665 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 599 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 666 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 600 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); | 667 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 601 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 668 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 602 EXPECT_EQ(7, cookies_model->GetRoot()->GetTotalNodeCount()); | 669 EXPECT_EQ(8, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 603 } | 670 } |
| 604 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)); | 671 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(1)); |
| 605 { | 672 { |
| 606 SCOPED_TRACE("`foo2` removed."); | 673 SCOPED_TRACE("`foo2` removed."); |
| 607 EXPECT_STREQ("A", GetDisplayedCookies(cookies_model.get()).c_str()); | 674 EXPECT_STREQ("A", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 608 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 675 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 609 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 676 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 610 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 677 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 611 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); | 678 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 612 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 679 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 613 EXPECT_EQ(4, cookies_model->GetRoot()->GetTotalNodeCount()); | 680 EXPECT_EQ(5, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 614 } | 681 } |
| 615 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)); | 682 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); |
| 616 { | 683 { |
| 617 SCOPED_TRACE("`foo1` removed."); | 684 SCOPED_TRACE("`foo1` removed."); |
| 618 EXPECT_STREQ("", GetDisplayedCookies(cookies_model.get()).c_str()); | 685 EXPECT_STREQ("", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 619 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); | 686 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 620 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 687 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 621 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 688 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 622 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); | 689 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 623 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 690 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 624 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); | 691 EXPECT_EQ(2, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 625 } | 692 } |
| 626 } | 693 } |
| 627 | 694 |
| 628 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { | 695 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { |
| 629 scoped_ptr<CookiesTreeModel> cookies_model( | 696 scoped_ptr<CookiesTreeModel> cookies_model( |
| 630 CreateCookiesTreeModelWithInitialSample()); | 697 CreateCookiesTreeModelWithInitialSample(false)); |
| 631 | 698 |
| 632 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); | 699 DeleteStoredObjects( |
| 700 cookies_model->GetRoot()->GetChild(0)->GetChild(0)->GetChild(0)); |
| 633 { | 701 { |
| 634 SCOPED_TRACE("First origin removed"); | 702 SCOPED_TRACE("First origin removed"); |
| 635 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 703 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 636 // 43 because in this case, the origin remains, although the COOKIES | 704 // 50 because in this case, the origin remains, although the COOKIES |
| 637 // node beneath it has been deleted. So, we have | 705 // node beneath it has been deleted. |
| 638 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 706 EXPECT_EQ(50, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 639 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | |
| 640 // fshost1 -> filesystem -> http://fshost1:1/, | |
| 641 // fshost2 -> filesystem -> http://fshost2:1/, | |
| 642 // fshost3 -> filesystem -> http://fshost3:1/, | |
| 643 // host1 -> localstorage -> http://host1:1/, | |
| 644 // host2 -> localstorage -> http://host2:2/, | |
| 645 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | |
| 646 // idbhost2 -> sessionstorage -> http://idbhost2:2/, | |
| 647 // quotahost1 -> quotahost1, | |
| 648 // quotahost2 -> quotahost1, | |
| 649 // sbc1 -> sbcerts -> sbc1, | |
| 650 // sbc2 -> sbcerts -> sbc2. | |
| 651 EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount()); | |
| 652 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 707 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 653 EXPECT_EQ("http://host1:1/,http://host2:2/", | 708 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 654 GetDisplayedLocalStorages(cookies_model.get())); | 709 GetDisplayedLocalStorages(cookies_model.get())); |
| 655 EXPECT_EQ("http://host1:1/,http://host2:2/", | 710 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 656 GetDisplayedSessionStorages(cookies_model.get())); | 711 GetDisplayedSessionStorages(cookies_model.get())); |
| 657 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 712 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 658 GetDisplayedIndexedDBs(cookies_model.get())); | 713 GetDisplayedIndexedDBs(cookies_model.get())); |
| 659 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 714 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 660 GetDisplayedFileSystems(cookies_model.get())); | 715 GetDisplayedFileSystems(cookies_model.get())); |
| 661 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 716 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 662 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 717 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
| 663 } | 718 } |
| 664 | 719 |
| 665 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 720 DeleteStoredObjects( |
| 721 cookies_model->GetRoot()->GetChild(0)->GetChild(6)->GetChild(0)); |
| 666 { | 722 { |
| 667 SCOPED_TRACE("First database removed"); | 723 SCOPED_TRACE("First database removed"); |
| 668 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 724 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 669 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 725 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 670 EXPECT_EQ("http://host1:1/,http://host2:2/", | 726 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 671 GetDisplayedLocalStorages(cookies_model.get())); | 727 GetDisplayedLocalStorages(cookies_model.get())); |
| 672 EXPECT_EQ("http://host1:1/,http://host2:2/", | 728 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 673 GetDisplayedSessionStorages(cookies_model.get())); | 729 GetDisplayedSessionStorages(cookies_model.get())); |
| 674 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 730 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 675 GetDisplayedIndexedDBs(cookies_model.get())); | 731 GetDisplayedIndexedDBs(cookies_model.get())); |
| 676 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 732 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 677 GetDisplayedFileSystems(cookies_model.get())); | 733 GetDisplayedFileSystems(cookies_model.get())); |
| 678 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 734 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 679 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 735 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
| 680 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount()); | 736 EXPECT_EQ(48, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 681 } | 737 } |
| 682 | 738 |
| 683 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 739 DeleteStoredObjects( |
| 740 cookies_model->GetRoot()->GetChild(0)->GetChild(8)->GetChild(0)); |
| 684 { | 741 { |
| 685 SCOPED_TRACE("First origin removed"); | 742 SCOPED_TRACE("First origin removed"); |
| 686 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 743 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 687 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 744 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 688 EXPECT_EQ("http://host2:2/", | 745 EXPECT_EQ("http://host2:2/", |
| 689 GetDisplayedLocalStorages(cookies_model.get())); | 746 GetDisplayedLocalStorages(cookies_model.get())); |
| 690 EXPECT_EQ("http://host1:1/,http://host2:2/", | 747 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 691 GetDisplayedSessionStorages(cookies_model.get())); | 748 GetDisplayedSessionStorages(cookies_model.get())); |
| 692 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 749 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 693 GetDisplayedIndexedDBs(cookies_model.get())); | 750 GetDisplayedIndexedDBs(cookies_model.get())); |
| 694 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 751 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 695 GetDisplayedFileSystems(cookies_model.get())); | 752 GetDisplayedFileSystems(cookies_model.get())); |
| 696 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 753 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 697 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 754 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
| 698 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); | 755 EXPECT_EQ(46, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 699 } | 756 } |
| 700 } | 757 } |
| 701 | 758 |
| 702 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { | 759 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { |
| 703 scoped_ptr<CookiesTreeModel> cookies_model( | 760 scoped_ptr<CookiesTreeModel> cookies_model( |
| 704 CreateCookiesTreeModelWithInitialSample()); | 761 CreateCookiesTreeModelWithInitialSample(false)); |
| 705 | 762 |
| 706 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); | 763 DeleteStoredObjects( |
| 764 cookies_model->GetRoot()->GetChild(0)->GetChild(1)->GetChild(0)); |
| 707 { | 765 { |
| 708 SCOPED_TRACE("Second origin COOKIES node removed"); | 766 SCOPED_TRACE("Second origin COOKIES node removed"); |
| 709 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 767 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 710 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 768 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 711 EXPECT_EQ("http://host1:1/,http://host2:2/", | 769 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 712 GetDisplayedLocalStorages(cookies_model.get())); | 770 GetDisplayedLocalStorages(cookies_model.get())); |
| 713 EXPECT_EQ("http://host1:1/,http://host2:2/", | 771 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 714 GetDisplayedSessionStorages(cookies_model.get())); | 772 GetDisplayedSessionStorages(cookies_model.get())); |
| 715 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 773 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 716 GetDisplayedIndexedDBs(cookies_model.get())); | 774 GetDisplayedIndexedDBs(cookies_model.get())); |
| 717 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 775 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 718 GetDisplayedFileSystems(cookies_model.get())); | 776 GetDisplayedFileSystems(cookies_model.get())); |
| 719 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 777 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 720 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 778 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
| 721 // 43 because in this case, the origin remains, although the COOKIES | 779 // 50 because in this case, the origin remains, although the COOKIES |
| 722 // node beneath it has been deleted. So, we have | 780 // node beneath it has been deleted. |
| 723 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 781 EXPECT_EQ(50, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 724 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | |
| 725 // fshost1 -> filesystem -> http://fshost1:1/, | |
| 726 // fshost2 -> filesystem -> http://fshost2:1/, | |
| 727 // fshost3 -> filesystem -> http://fshost3:1/, | |
| 728 // host1 -> localstorage -> http://host1:1/, | |
| 729 // host2 -> localstorage -> http://host2:2/, | |
| 730 // host1 -> sessionstorage -> http://host1:1/, | |
| 731 // host2 -> sessionstorage -> http://host2:2/, | |
| 732 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | |
| 733 // idbhost2 -> sessionstorage -> http://idbhost2:2/, | |
| 734 // quotahost1 -> quotahost1, | |
| 735 // quotahost2 -> quotahost2. | |
| 736 EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount()); | |
| 737 } | 782 } |
| 738 | 783 |
| 739 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 784 DeleteStoredObjects( |
| 785 cookies_model->GetRoot()->GetChild(0)->GetChild(6)->GetChild(0)); |
| 740 { | 786 { |
| 741 SCOPED_TRACE("First database removed"); | 787 SCOPED_TRACE("First database removed"); |
| 742 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 788 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 743 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 789 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 744 EXPECT_EQ("http://host1:1/,http://host2:2/", | 790 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 745 GetDisplayedLocalStorages(cookies_model.get())); | 791 GetDisplayedLocalStorages(cookies_model.get())); |
| 746 EXPECT_EQ("http://host1:1/,http://host2:2/", | 792 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 747 GetDisplayedSessionStorages(cookies_model.get())); | 793 GetDisplayedSessionStorages(cookies_model.get())); |
| 748 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 794 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 749 GetDisplayedIndexedDBs(cookies_model.get())); | 795 GetDisplayedIndexedDBs(cookies_model.get())); |
| 750 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 796 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 751 GetDisplayedFileSystems(cookies_model.get())); | 797 GetDisplayedFileSystems(cookies_model.get())); |
| 752 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 798 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 753 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 799 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
| 754 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount()); | 800 EXPECT_EQ(48, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 755 } | 801 } |
| 756 | 802 |
| 757 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 803 DeleteStoredObjects( |
| 804 cookies_model->GetRoot()->GetChild(0)->GetChild(8)->GetChild(0)); |
| 758 { | 805 { |
| 759 SCOPED_TRACE("First origin removed"); | 806 SCOPED_TRACE("First origin removed"); |
| 760 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 807 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 761 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 808 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 762 EXPECT_EQ("http://host2:2/", | 809 EXPECT_EQ("http://host2:2/", |
| 763 GetDisplayedLocalStorages(cookies_model.get())); | 810 GetDisplayedLocalStorages(cookies_model.get())); |
| 764 EXPECT_EQ("http://host1:1/,http://host2:2/", | 811 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 765 GetDisplayedSessionStorages(cookies_model.get())); | 812 GetDisplayedSessionStorages(cookies_model.get())); |
| 766 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 813 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 767 GetDisplayedIndexedDBs(cookies_model.get())); | 814 GetDisplayedIndexedDBs(cookies_model.get())); |
| 768 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 815 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 769 GetDisplayedFileSystems(cookies_model.get())); | 816 GetDisplayedFileSystems(cookies_model.get())); |
| 770 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 817 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 771 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 818 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
| 772 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); | 819 EXPECT_EQ(46, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 773 } | 820 } |
| 774 } | 821 } |
| 775 | 822 |
| 776 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { | 823 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { |
| 777 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 824 string16 name = ASCIIToUTF16("Drive-By-Web"); |
| 778 mock_browsing_data_database_helper_, | 825 string16 browser_id; |
| 779 mock_browsing_data_local_storage_helper_, | 826 ContainerMap container_map; |
| 780 mock_browsing_data_session_storage_helper_, | 827 |
| 781 mock_browsing_data_appcache_helper_, | 828 container_map[browser_id] = new LocalDataContainer( |
| 782 mock_browsing_data_indexed_db_helper_, | 829 name, browser_id, |
| 783 mock_browsing_data_file_system_helper_, | 830 mock_browsing_data_cookie_helper_, |
| 784 mock_browsing_data_quota_helper_, | 831 mock_browsing_data_database_helper_, |
| 785 mock_browsing_data_server_bound_cert_helper_, | 832 mock_browsing_data_local_storage_helper_, |
| 786 false); | 833 mock_browsing_data_session_storage_helper_, |
| 834 mock_browsing_data_appcache_helper_, |
| 835 mock_browsing_data_indexed_db_helper_, |
| 836 mock_browsing_data_file_system_helper_, |
| 837 mock_browsing_data_quota_helper_, |
| 838 mock_browsing_data_server_bound_cert_helper_); |
| 839 CookiesTreeModel cookies_model(container_map, false); |
| 840 |
| 787 mock_browsing_data_cookie_helper_-> | 841 mock_browsing_data_cookie_helper_-> |
| 788 AddCookieSamples(GURL("http://foo1"), "A=1"); | 842 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 789 mock_browsing_data_cookie_helper_-> | 843 mock_browsing_data_cookie_helper_-> |
| 790 AddCookieSamples(GURL("http://foo2"), "B=1"); | 844 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 791 mock_browsing_data_cookie_helper_-> | 845 mock_browsing_data_cookie_helper_-> |
| 792 AddCookieSamples(GURL("http://foo3"), "C=1"); | 846 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 793 mock_browsing_data_cookie_helper_-> | 847 mock_browsing_data_cookie_helper_-> |
| 794 AddCookieSamples(GURL("http://foo3"), "D=1"); | 848 AddCookieSamples(GURL("http://foo3"), "D=1"); |
| 795 mock_browsing_data_cookie_helper_->Notify(); | 849 mock_browsing_data_cookie_helper_->Notify(); |
| 796 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 850 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 797 mock_browsing_data_database_helper_->Notify(); | 851 mock_browsing_data_database_helper_->Notify(); |
| 798 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 852 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 799 mock_browsing_data_local_storage_helper_->Notify(); | 853 mock_browsing_data_local_storage_helper_->Notify(); |
| 800 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 854 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 801 mock_browsing_data_session_storage_helper_->Notify(); | 855 mock_browsing_data_session_storage_helper_->Notify(); |
| 802 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 856 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 803 mock_browsing_data_indexed_db_helper_->Notify(); | 857 mock_browsing_data_indexed_db_helper_->Notify(); |
| 804 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 858 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 805 mock_browsing_data_file_system_helper_->Notify(); | 859 mock_browsing_data_file_system_helper_->Notify(); |
| 806 mock_browsing_data_quota_helper_->AddQuotaSamples(); | 860 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
| 807 mock_browsing_data_quota_helper_->Notify(); | 861 mock_browsing_data_quota_helper_->Notify(); |
| 808 | 862 |
| 809 { | 863 { |
| 810 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " | 864 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " |
| 811 "2 session storages, 2 indexed DBs, 3 file systems, " | 865 "2 session storages, 2 indexed DBs, 3 file systems, " |
| 812 "2 quotas."); | 866 "2 quotas."); |
| 813 // 42 because there's the root, then foo1 -> cookies -> a, | 867 // 47 because there's the root, the app, then |
| 814 // foo2 -> cookies -> b, foo3 -> cookies -> c,d | 868 // foo1 -> cookies -> a, |
| 815 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 869 // foo2 -> cookies -> b, |
| 870 // foo3 -> cookies -> c,d |
| 871 // dbhost1 -> database -> db1, |
| 872 // dbhost2 -> database -> db2, |
| 873 // host1 -> localstorage -> http://host1:1/, |
| 874 // -> sessionstorage -> http://host1:1/, |
| 875 // host2 -> localstorage -> http://host2:2/, |
| 876 // -> sessionstorage -> http://host2:2/, |
| 877 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 878 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
| 816 // fshost1 -> filesystem -> http://fshost1:1/, | 879 // fshost1 -> filesystem -> http://fshost1:1/, |
| 817 // fshost2 -> filesystem -> http://fshost2:1/, | 880 // fshost2 -> filesystem -> http://fshost2:1/, |
| 818 // fshost3 -> filesystem -> http://fshost3:1/, | 881 // fshost3 -> filesystem -> http://fshost3:1/, |
| 819 // host1 -> localstorage -> http://host1:1/, | |
| 820 // host1 -> sessionstorage -> http://host1:1/, | |
| 821 // host2 -> sessionstorage -> http://host2:2/, | |
| 822 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | |
| 823 // idbhost2 -> sessionstorage -> http://idbhost2:2/, | |
| 824 // quotahost1 -> quotahost1, | 882 // quotahost1 -> quotahost1, |
| 825 // quotahost2 -> quotahost2. | 883 // quotahost2 -> quotahost2. |
| 826 EXPECT_EQ(46, cookies_model.GetRoot()->GetTotalNodeCount()); | 884 EXPECT_EQ(47, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 827 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); | 885 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); |
| 828 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 886 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 829 EXPECT_EQ("http://host1:1/,http://host2:2/", | 887 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 830 GetDisplayedLocalStorages(&cookies_model)); | 888 GetDisplayedLocalStorages(&cookies_model)); |
| 831 EXPECT_EQ("http://host1:1/,http://host2:2/", | 889 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 832 GetDisplayedSessionStorages(&cookies_model)); | 890 GetDisplayedSessionStorages(&cookies_model)); |
| 833 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 891 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 834 GetDisplayedIndexedDBs(&cookies_model)); | 892 GetDisplayedIndexedDBs(&cookies_model)); |
| 835 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 893 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 836 GetDisplayedFileSystems(&cookies_model)); | 894 GetDisplayedFileSystems(&cookies_model)); |
| 837 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); | 895 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
| 838 } | 896 } |
| 839 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); | 897 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(0)->GetChild(2)); |
| 840 { | 898 { |
| 841 SCOPED_TRACE("Third origin removed"); | 899 SCOPED_TRACE("Third origin removed"); |
| 842 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); | 900 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); |
| 843 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 901 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 844 EXPECT_EQ("http://host1:1/,http://host2:2/", | 902 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 845 GetDisplayedLocalStorages(&cookies_model)); | 903 GetDisplayedLocalStorages(&cookies_model)); |
| 846 EXPECT_EQ("http://host1:1/,http://host2:2/", | 904 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 847 GetDisplayedSessionStorages(&cookies_model)); | 905 GetDisplayedSessionStorages(&cookies_model)); |
| 848 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 906 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 849 GetDisplayedIndexedDBs(&cookies_model)); | 907 GetDisplayedIndexedDBs(&cookies_model)); |
| 850 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 908 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 851 GetDisplayedFileSystems(&cookies_model)); | 909 GetDisplayedFileSystems(&cookies_model)); |
| 852 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); | 910 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
| 853 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); | 911 EXPECT_EQ(43, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 854 } | 912 } |
| 855 } | 913 } |
| 856 | 914 |
| 857 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { | 915 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { |
| 858 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 916 string16 name = ASCIIToUTF16("Drive-By-Web"); |
| 859 mock_browsing_data_database_helper_, | 917 string16 browser_id; |
| 860 mock_browsing_data_local_storage_helper_, | 918 ContainerMap container_map; |
| 861 mock_browsing_data_session_storage_helper_, | 919 |
| 862 mock_browsing_data_appcache_helper_, | 920 container_map[browser_id] = new LocalDataContainer ( |
| 863 mock_browsing_data_indexed_db_helper_, | 921 name, browser_id, |
| 864 mock_browsing_data_file_system_helper_, | 922 mock_browsing_data_cookie_helper_, |
| 865 mock_browsing_data_quota_helper_, | 923 mock_browsing_data_database_helper_, |
| 866 mock_browsing_data_server_bound_cert_helper_, | 924 mock_browsing_data_local_storage_helper_, |
| 867 false); | 925 mock_browsing_data_session_storage_helper_, |
| 926 mock_browsing_data_appcache_helper_, |
| 927 mock_browsing_data_indexed_db_helper_, |
| 928 mock_browsing_data_file_system_helper_, |
| 929 mock_browsing_data_quota_helper_, |
| 930 mock_browsing_data_server_bound_cert_helper_); |
| 931 CookiesTreeModel cookies_model(container_map, false); |
| 932 |
| 868 mock_browsing_data_cookie_helper_-> | 933 mock_browsing_data_cookie_helper_-> |
| 869 AddCookieSamples(GURL("http://foo1"), "A=1"); | 934 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 870 mock_browsing_data_cookie_helper_-> | 935 mock_browsing_data_cookie_helper_-> |
| 871 AddCookieSamples(GURL("http://foo2"), "B=1"); | 936 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 872 mock_browsing_data_cookie_helper_-> | 937 mock_browsing_data_cookie_helper_-> |
| 873 AddCookieSamples(GURL("http://foo3"), "C=1"); | 938 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 874 mock_browsing_data_cookie_helper_-> | 939 mock_browsing_data_cookie_helper_-> |
| 875 AddCookieSamples(GURL("http://foo3"), "D=1"); | 940 AddCookieSamples(GURL("http://foo3"), "D=1"); |
| 876 mock_browsing_data_cookie_helper_-> | 941 mock_browsing_data_cookie_helper_-> |
| 877 AddCookieSamples(GURL("http://foo3"), "E=1"); | 942 AddCookieSamples(GURL("http://foo3"), "E=1"); |
| 878 mock_browsing_data_cookie_helper_->Notify(); | 943 mock_browsing_data_cookie_helper_->Notify(); |
| 879 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 944 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 880 mock_browsing_data_database_helper_->Notify(); | 945 mock_browsing_data_database_helper_->Notify(); |
| 881 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 946 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 882 mock_browsing_data_local_storage_helper_->Notify(); | 947 mock_browsing_data_local_storage_helper_->Notify(); |
| 883 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 948 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 884 mock_browsing_data_session_storage_helper_->Notify(); | 949 mock_browsing_data_session_storage_helper_->Notify(); |
| 885 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 950 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 886 mock_browsing_data_indexed_db_helper_->Notify(); | 951 mock_browsing_data_indexed_db_helper_->Notify(); |
| 887 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 952 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 888 mock_browsing_data_file_system_helper_->Notify(); | 953 mock_browsing_data_file_system_helper_->Notify(); |
| 889 mock_browsing_data_quota_helper_->AddQuotaSamples(); | 954 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
| 890 mock_browsing_data_quota_helper_->Notify(); | 955 mock_browsing_data_quota_helper_->Notify(); |
| 891 | 956 |
| 892 { | 957 { |
| 893 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " | 958 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " |
| 894 "2 session storages, 2 indexed DBs, 3 filesystems, " | 959 "2 session storages, 2 indexed DBs, 3 filesystems, " |
| 895 "2 quotas."); | 960 "2 quotas."); |
| 896 // 43 because there's the root, then foo1 -> cookies -> a, | 961 // 48 because there's the root, then the app, then |
| 897 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 962 // foo1 -> cookies -> a, |
| 898 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 963 // foo2 -> cookies -> b, |
| 964 // foo3 -> cookies -> c,d,e |
| 965 // dbhost1 -> database -> db1, |
| 966 // dbhost2 -> database -> db2, |
| 967 // host1 -> localstorage -> http://host1:1/, |
| 968 // -> sessionstorage -> http://host1:1/, |
| 969 // host2 -> localstorage -> http://host2:2/, |
| 970 // -> sessionstorage -> http://host2:2/, |
| 971 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 972 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
| 899 // fshost1 -> filesystem -> http://fshost1:1/, | 973 // fshost1 -> filesystem -> http://fshost1:1/, |
| 900 // fshost2 -> filesystem -> http://fshost2:1/, | 974 // fshost2 -> filesystem -> http://fshost2:1/, |
| 901 // fshost3 -> filesystem -> http://fshost3:1/, | 975 // fshost3 -> filesystem -> http://fshost3:1/, |
| 902 // host1 -> localstorage -> http://host1:1/, | |
| 903 // host2 -> localstorage -> http://host2:2/, | |
| 904 // host1 -> sessionstorage -> http://host1:1/, | |
| 905 // host2 -> sessionstorage -> http://host2:2/, | |
| 906 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | |
| 907 // idbhost2 -> sessionstorage -> http://idbhost2:2/, | |
| 908 // quotahost1 -> quotahost1, | 976 // quotahost1 -> quotahost1, |
| 909 // quotahost2 -> quotahost2. | 977 // quotahost2 -> quotahost2. |
| 910 EXPECT_EQ(47, cookies_model.GetRoot()->GetTotalNodeCount()); | 978 EXPECT_EQ(48, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 911 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 979 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 912 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 980 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 913 EXPECT_EQ("http://host1:1/,http://host2:2/", | 981 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 914 GetDisplayedLocalStorages(&cookies_model)); | 982 GetDisplayedLocalStorages(&cookies_model)); |
| 915 EXPECT_EQ("http://host1:1/,http://host2:2/", | 983 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 916 GetDisplayedSessionStorages(&cookies_model)); | 984 GetDisplayedSessionStorages(&cookies_model)); |
| 917 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 985 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 918 GetDisplayedIndexedDBs(&cookies_model)); | 986 GetDisplayedIndexedDBs(&cookies_model)); |
| 919 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 987 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 920 GetDisplayedFileSystems(&cookies_model)); | 988 GetDisplayedFileSystems(&cookies_model)); |
| 921 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); | 989 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
| 922 } | 990 } |
| 923 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> | 991 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(0)->GetChild(2)-> |
| 924 GetChild(1)); | 992 GetChild(0)->GetChild(1)); |
| 925 { | 993 { |
| 926 SCOPED_TRACE("Middle cookie in third origin removed"); | 994 SCOPED_TRACE("Middle cookie in third origin removed"); |
| 927 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); | 995 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 928 EXPECT_EQ(46, cookies_model.GetRoot()->GetTotalNodeCount()); | 996 EXPECT_EQ(47, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 929 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 997 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 930 EXPECT_EQ("http://host1:1/,http://host2:2/", | 998 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 931 GetDisplayedLocalStorages(&cookies_model)); | 999 GetDisplayedLocalStorages(&cookies_model)); |
| 932 EXPECT_EQ("http://host1:1/,http://host2:2/", | 1000 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 933 GetDisplayedSessionStorages(&cookies_model)); | 1001 GetDisplayedSessionStorages(&cookies_model)); |
| 934 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 1002 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 935 GetDisplayedIndexedDBs(&cookies_model)); | 1003 GetDisplayedIndexedDBs(&cookies_model)); |
| 936 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 1004 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 937 GetDisplayedFileSystems(&cookies_model)); | 1005 GetDisplayedFileSystems(&cookies_model)); |
| 938 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); | 1006 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
| 939 } | 1007 } |
| 940 } | 1008 } |
| 941 | 1009 |
| 942 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { | 1010 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { |
| 943 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 1011 string16 name = ASCIIToUTF16("Drive-By-Web"); |
| 944 mock_browsing_data_database_helper_, | 1012 string16 browser_id; |
| 945 mock_browsing_data_local_storage_helper_, | 1013 ContainerMap container_map; |
| 946 mock_browsing_data_session_storage_helper_, | 1014 |
| 947 mock_browsing_data_appcache_helper_, | 1015 container_map[browser_id] = new LocalDataContainer( |
| 948 mock_browsing_data_indexed_db_helper_, | 1016 name, browser_id, |
| 949 mock_browsing_data_file_system_helper_, | 1017 mock_browsing_data_cookie_helper_, |
| 950 mock_browsing_data_quota_helper_, | 1018 mock_browsing_data_database_helper_, |
| 951 mock_browsing_data_server_bound_cert_helper_, | 1019 mock_browsing_data_local_storage_helper_, |
| 952 false); | 1020 mock_browsing_data_session_storage_helper_, |
| 1021 mock_browsing_data_appcache_helper_, |
| 1022 mock_browsing_data_indexed_db_helper_, |
| 1023 mock_browsing_data_file_system_helper_, |
| 1024 mock_browsing_data_quota_helper_, |
| 1025 mock_browsing_data_server_bound_cert_helper_); |
| 1026 CookiesTreeModel cookies_model(container_map, false); |
| 1027 |
| 953 mock_browsing_data_cookie_helper_-> | 1028 mock_browsing_data_cookie_helper_-> |
| 954 AddCookieSamples(GURL("http://foo1"), "A=1"); | 1029 AddCookieSamples(GURL("http://foo1"), "A=1"); |
| 955 mock_browsing_data_cookie_helper_-> | 1030 mock_browsing_data_cookie_helper_-> |
| 956 AddCookieSamples(GURL("http://foo2"), "B=1"); | 1031 AddCookieSamples(GURL("http://foo2"), "B=1"); |
| 957 mock_browsing_data_cookie_helper_-> | 1032 mock_browsing_data_cookie_helper_-> |
| 958 AddCookieSamples(GURL("http://foo3"), "C=1"); | 1033 AddCookieSamples(GURL("http://foo3"), "C=1"); |
| 959 mock_browsing_data_cookie_helper_-> | 1034 mock_browsing_data_cookie_helper_-> |
| 960 AddCookieSamples(GURL("http://foo3"), "D=1"); | 1035 AddCookieSamples(GURL("http://foo3"), "D=1"); |
| 961 mock_browsing_data_cookie_helper_-> | 1036 mock_browsing_data_cookie_helper_-> |
| 962 AddCookieSamples(GURL("http://foo3"), "E=1"); | 1037 AddCookieSamples(GURL("http://foo3"), "E=1"); |
| 963 mock_browsing_data_cookie_helper_->Notify(); | 1038 mock_browsing_data_cookie_helper_->Notify(); |
| 964 | 1039 |
| 965 { | 1040 { |
| 966 SCOPED_TRACE("Initial State 5 cookies"); | 1041 SCOPED_TRACE("Initial State 5 cookies"); |
| 967 // 11 because there's the root, then foo1 -> cookies -> a, | 1042 // 13 because there's the root, the app, then foo1 -> cookies -> a, |
| 968 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 1043 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
| 969 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); | 1044 EXPECT_EQ(13, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 970 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 1045 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 971 } | 1046 } |
| 972 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); | 1047 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(0)->GetChild(1)); |
| 973 { | 1048 { |
| 974 SCOPED_TRACE("Second origin removed"); | 1049 SCOPED_TRACE("Second origin removed"); |
| 975 EXPECT_STREQ("A,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 1050 EXPECT_STREQ("A,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 976 // Left with root -> foo1 -> cookies -> a, foo3 -> cookies -> c,d,e | 1051 // Left with root -> app -> foo1 -> cookies -> a, foo3 -> cookies -> c,d,e |
| 977 EXPECT_EQ(9, cookies_model.GetRoot()->GetTotalNodeCount()); | 1052 EXPECT_EQ(10, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 978 } | 1053 } |
| 979 } | 1054 } |
| 980 | 1055 |
| 981 TEST_F(CookiesTreeModelTest, OriginOrdering) { | 1056 TEST_F(CookiesTreeModelTest, OriginOrdering) { |
| 982 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 1057 string16 name = ASCIIToUTF16("Drive-By-Web"); |
| 983 mock_browsing_data_database_helper_, | 1058 string16 browser_id; |
| 984 mock_browsing_data_local_storage_helper_, | 1059 ContainerMap container_map; |
| 985 mock_browsing_data_session_storage_helper_, | 1060 |
| 986 mock_browsing_data_appcache_helper_, | 1061 container_map[browser_id] = new LocalDataContainer( |
| 987 mock_browsing_data_indexed_db_helper_, | 1062 name, browser_id, |
| 988 mock_browsing_data_file_system_helper_, | 1063 mock_browsing_data_cookie_helper_, |
| 989 mock_browsing_data_quota_helper_, | 1064 mock_browsing_data_database_helper_, |
| 990 mock_browsing_data_server_bound_cert_helper_, | 1065 mock_browsing_data_local_storage_helper_, |
| 991 false); | 1066 mock_browsing_data_session_storage_helper_, |
| 1067 mock_browsing_data_appcache_helper_, |
| 1068 mock_browsing_data_indexed_db_helper_, |
| 1069 mock_browsing_data_file_system_helper_, |
| 1070 mock_browsing_data_quota_helper_, |
| 1071 mock_browsing_data_server_bound_cert_helper_); |
| 1072 CookiesTreeModel cookies_model(container_map, false); |
| 1073 |
| 992 mock_browsing_data_cookie_helper_-> | 1074 mock_browsing_data_cookie_helper_-> |
| 993 AddCookieSamples(GURL("http://a.foo2.com"), "A=1"); | 1075 AddCookieSamples(GURL("http://a.foo2.com"), "A=1"); |
| 994 mock_browsing_data_cookie_helper_-> | 1076 mock_browsing_data_cookie_helper_-> |
| 995 AddCookieSamples(GURL("http://foo2.com"), "B=1"); | 1077 AddCookieSamples(GURL("http://foo2.com"), "B=1"); |
| 996 mock_browsing_data_cookie_helper_-> | 1078 mock_browsing_data_cookie_helper_-> |
| 997 AddCookieSamples(GURL("http://b.foo1.com"), "C=1"); | 1079 AddCookieSamples(GURL("http://b.foo1.com"), "C=1"); |
| 998 // Leading dot on the foo4 | 1080 // Leading dot on the foo4 |
| 999 mock_browsing_data_cookie_helper_->AddCookieSamples( | 1081 mock_browsing_data_cookie_helper_->AddCookieSamples( |
| 1000 GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;"); | 1082 GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;"); |
| 1001 mock_browsing_data_cookie_helper_-> | 1083 mock_browsing_data_cookie_helper_-> |
| 1002 AddCookieSamples(GURL("http://a.foo1.com"), "E=1"); | 1084 AddCookieSamples(GURL("http://a.foo1.com"), "E=1"); |
| 1003 mock_browsing_data_cookie_helper_-> | 1085 mock_browsing_data_cookie_helper_-> |
| 1004 AddCookieSamples(GURL("http://foo1.com"), "F=1"); | 1086 AddCookieSamples(GURL("http://foo1.com"), "F=1"); |
| 1005 mock_browsing_data_cookie_helper_-> | 1087 mock_browsing_data_cookie_helper_-> |
| 1006 AddCookieSamples(GURL("http://foo3.com"), "G=1"); | 1088 AddCookieSamples(GURL("http://foo3.com"), "G=1"); |
| 1007 mock_browsing_data_cookie_helper_-> | 1089 mock_browsing_data_cookie_helper_-> |
| 1008 AddCookieSamples(GURL("http://foo4.com"), "H=1"); | 1090 AddCookieSamples(GURL("http://foo4.com"), "H=1"); |
| 1009 mock_browsing_data_cookie_helper_->Notify(); | 1091 mock_browsing_data_cookie_helper_->Notify(); |
| 1010 | 1092 |
| 1011 { | 1093 { |
| 1012 SCOPED_TRACE("Initial State 8 cookies"); | 1094 SCOPED_TRACE("Initial State 8 cookies"); |
| 1013 EXPECT_EQ(23, cookies_model.GetRoot()->GetTotalNodeCount()); | 1095 EXPECT_EQ(24, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 1014 EXPECT_STREQ("F,E,C,B,A,G,D,H", | 1096 EXPECT_STREQ("F,E,C,B,A,G,D,H", |
| 1015 GetDisplayedCookies(&cookies_model).c_str()); | 1097 GetDisplayedCookies(&cookies_model).c_str()); |
| 1016 } | 1098 } |
| 1017 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E" | 1099 // Delete "E" |
| 1100 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(0)->GetChild(1)); |
| 1018 { | 1101 { |
| 1019 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); | 1102 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); |
| 1020 } | 1103 } |
| 1021 } | 1104 } |
| 1022 | 1105 |
| 1023 TEST_F(CookiesTreeModelTest, ContentSettings) { | 1106 TEST_F(CookiesTreeModelTest, ContentSettings) { |
| 1024 GURL host("http://example.com/"); | 1107 GURL host("http://example.com/"); |
| 1025 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 1108 string16 name = ASCIIToUTF16("Drive-By-Web"); |
| 1026 mock_browsing_data_database_helper_, | 1109 string16 browser_id; |
| 1027 mock_browsing_data_local_storage_helper_, | 1110 ContainerMap container_map; |
| 1028 mock_browsing_data_session_storage_helper_, | 1111 |
| 1029 mock_browsing_data_appcache_helper_, | 1112 container_map[browser_id] = new LocalDataContainer( |
| 1030 mock_browsing_data_indexed_db_helper_, | 1113 name, browser_id, |
| 1031 mock_browsing_data_file_system_helper_, | 1114 mock_browsing_data_cookie_helper_, |
| 1032 mock_browsing_data_quota_helper_, | 1115 mock_browsing_data_database_helper_, |
| 1033 mock_browsing_data_server_bound_cert_helper_, | 1116 mock_browsing_data_local_storage_helper_, |
| 1034 false); | 1117 mock_browsing_data_session_storage_helper_, |
| 1118 mock_browsing_data_appcache_helper_, |
| 1119 mock_browsing_data_indexed_db_helper_, |
| 1120 mock_browsing_data_file_system_helper_, |
| 1121 mock_browsing_data_quota_helper_, |
| 1122 mock_browsing_data_server_bound_cert_helper_); |
| 1123 CookiesTreeModel cookies_model(container_map, false); |
| 1124 |
| 1035 mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1"); | 1125 mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1"); |
| 1036 mock_browsing_data_cookie_helper_->Notify(); | 1126 mock_browsing_data_cookie_helper_->Notify(); |
| 1037 | 1127 |
| 1038 TestingProfile profile; | 1128 TestingProfile profile; |
| 1039 HostContentSettingsMap* content_settings = | 1129 HostContentSettingsMap* content_settings = |
| 1040 profile.GetHostContentSettingsMap(); | 1130 profile.GetHostContentSettingsMap(); |
| 1041 CookieSettings* cookie_settings = | 1131 CookieSettings* cookie_settings = |
| 1042 CookieSettings::Factory::GetForProfile(&profile); | 1132 CookieSettings::Factory::GetForProfile(&profile); |
| 1043 MockSettingsObserver observer; | 1133 MockSettingsObserver observer; |
| 1044 | 1134 |
| 1045 CookieTreeRootNode* root = | 1135 CookieTreeRootNode* root = |
| 1046 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); | 1136 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); |
| 1047 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); | 1137 CookieTreeAppNode* app_node = root->GetOrCreateAppNode(name, browser_id); |
| 1138 CookieTreeOriginNode* origin = app_node->GetOrCreateOriginNode(host); |
| 1048 | 1139 |
| 1049 EXPECT_EQ(1, origin->child_count()); | 1140 EXPECT_EQ(1, origin->child_count()); |
| 1050 EXPECT_TRUE(origin->CanCreateContentException()); | 1141 EXPECT_TRUE(origin->CanCreateContentException()); |
| 1051 EXPECT_CALL(observer, | 1142 EXPECT_CALL(observer, |
| 1052 OnContentSettingsChanged( | 1143 OnContentSettingsChanged( |
| 1053 content_settings, | 1144 content_settings, |
| 1054 CONTENT_SETTINGS_TYPE_COOKIES, | 1145 CONTENT_SETTINGS_TYPE_COOKIES, |
| 1055 false, | 1146 false, |
| 1056 ContentSettingsPattern::FromURLNoWildcard(host), | 1147 ContentSettingsPattern::FromURLNoWildcard(host), |
| 1057 ContentSettingsPattern::Wildcard(), | 1148 ContentSettingsPattern::Wildcard(), |
| 1058 false)); | 1149 false)); |
| 1059 EXPECT_CALL(observer, | 1150 EXPECT_CALL(observer, |
| 1060 OnContentSettingsChanged(content_settings, | 1151 OnContentSettingsChanged(content_settings, |
| 1061 CONTENT_SETTINGS_TYPE_COOKIES, | 1152 CONTENT_SETTINGS_TYPE_COOKIES, |
| 1062 false, | 1153 false, |
| 1063 ContentSettingsPattern::FromURL(host), | 1154 ContentSettingsPattern::FromURL(host), |
| 1064 ContentSettingsPattern::Wildcard(), | 1155 ContentSettingsPattern::Wildcard(), |
| 1065 false)); | 1156 false)); |
| 1066 origin->CreateContentException( | 1157 origin->CreateContentException( |
| 1067 cookie_settings, CONTENT_SETTING_SESSION_ONLY); | 1158 cookie_settings, CONTENT_SETTING_SESSION_ONLY); |
| 1068 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(host, host)); | 1159 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(host, host)); |
| 1069 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(host)); | 1160 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(host)); |
| 1070 } | 1161 } |
| 1071 | 1162 |
| 1163 TEST_F(CookiesTreeModelTest, RemoveAppCookies) { |
| 1164 scoped_ptr<CookiesTreeModel> cookies_model( |
| 1165 CreateCookiesTreeModelWithInitialSample(true)); |
| 1166 |
| 1167 // Since we've added an app to the tree model, we expect two children of the |
| 1168 // root node. The app should have 3 children for the the 3 domains. |
| 1169 EXPECT_EQ(2, cookies_model->GetRoot()->child_count()); |
| 1170 EXPECT_EQ(3, cookies_model->GetRoot()->GetChild(1)->child_count()); |
| 1171 |
| 1172 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(1)); |
| 1173 { |
| 1174 SCOPED_TRACE("Second origin for app removed"); |
| 1175 EXPECT_STREQ("A,B,C,Z,X", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 1176 EXPECT_EQ(59, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 1177 } |
| 1178 } |
| 1179 |
| 1072 TEST_F(CookiesTreeModelTest, FileSystemFilter) { | 1180 TEST_F(CookiesTreeModelTest, FileSystemFilter) { |
| 1073 scoped_ptr<CookiesTreeModel> cookies_model( | 1181 scoped_ptr<CookiesTreeModel> cookies_model( |
| 1074 CreateCookiesTreeModelWithInitialSample()); | 1182 CreateCookiesTreeModelWithInitialSample(false)); |
| 1075 | 1183 |
| 1076 cookies_model->UpdateSearchResults(std::wstring(L"fshost1")); | 1184 cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost1"))); |
| 1077 EXPECT_EQ("http://fshost1:1/", | 1185 EXPECT_EQ("http://fshost1:1/", |
| 1078 GetDisplayedFileSystems(cookies_model.get())); | 1186 GetDisplayedFileSystems(cookies_model.get())); |
| 1079 | 1187 |
| 1080 cookies_model->UpdateSearchResults(std::wstring(L"fshost2")); | 1188 cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost2"))); |
| 1081 EXPECT_EQ("http://fshost2:2/", | 1189 EXPECT_EQ("http://fshost2:2/", |
| 1082 GetDisplayedFileSystems(cookies_model.get())); | 1190 GetDisplayedFileSystems(cookies_model.get())); |
| 1083 | 1191 |
| 1084 cookies_model->UpdateSearchResults(std::wstring(L"fshost3")); | 1192 cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost3"))); |
| 1085 EXPECT_EQ("http://fshost3:3/", | 1193 EXPECT_EQ("http://fshost3:3/", |
| 1086 GetDisplayedFileSystems(cookies_model.get())); | 1194 GetDisplayedFileSystems(cookies_model.get())); |
| 1087 | 1195 |
| 1088 cookies_model->UpdateSearchResults(std::wstring()); | 1196 cookies_model->UpdateSearchResults(string16()); |
| 1089 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 1197 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 1090 GetDisplayedFileSystems(cookies_model.get())); | 1198 GetDisplayedFileSystems(cookies_model.get())); |
| 1091 } | 1199 } |
| 1092 | 1200 |
| 1201 TEST_F(CookiesTreeModelTest, String16Filter) { |
| 1202 string16 name = ASCIIToUTF16("Drive-By-Web"); |
| 1203 string16 browser_id; |
| 1204 ContainerMap container_map; |
| 1205 |
| 1206 container_map[browser_id] = new LocalDataContainer( |
| 1207 name, browser_id, |
| 1208 mock_browsing_data_cookie_helper_, |
| 1209 mock_browsing_data_database_helper_, |
| 1210 mock_browsing_data_local_storage_helper_, |
| 1211 mock_browsing_data_session_storage_helper_, |
| 1212 mock_browsing_data_appcache_helper_, |
| 1213 mock_browsing_data_indexed_db_helper_, |
| 1214 mock_browsing_data_file_system_helper_, |
| 1215 mock_browsing_data_quota_helper_, |
| 1216 mock_browsing_data_server_bound_cert_helper_); |
| 1217 CookiesTreeModel cookies_model(container_map, false); |
| 1218 |
| 1219 mock_browsing_data_cookie_helper_-> |
| 1220 AddCookieSamples(GURL("http://123.com"), "A=1"); |
| 1221 mock_browsing_data_cookie_helper_-> |
| 1222 AddCookieSamples(GURL("http://foo1.com"), "B=1"); |
| 1223 mock_browsing_data_cookie_helper_-> |
| 1224 AddCookieSamples(GURL("http://foo2.com"), "C=1"); |
| 1225 mock_browsing_data_cookie_helper_-> |
| 1226 AddCookieSamples(GURL("http://foo3.com"), "D=1"); |
| 1227 mock_browsing_data_cookie_helper_->Notify(); |
| 1228 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); |
| 1229 |
| 1230 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo"))); |
| 1231 EXPECT_EQ("B,C,D", GetDisplayedCookies(&cookies_model)); |
| 1232 |
| 1233 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("2"))); |
| 1234 EXPECT_EQ("A,C", GetDisplayedCookies(&cookies_model)); |
| 1235 |
| 1236 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo3"))); |
| 1237 EXPECT_EQ("D", GetDisplayedCookies(&cookies_model)); |
| 1238 |
| 1239 cookies_model.UpdateSearchResults(string16()); |
| 1240 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); |
| 1241 } |
| 1242 |
| 1093 } // namespace | 1243 } // namespace |
| OLD | NEW |