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