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

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

Powered by Google App Engine
This is Rietveld 408576698