Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/browser/cookies_tree_model_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698