OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/cookies_tree_model.h" | 5 #include "chrome/browser/cookies_tree_model.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/content_settings/cookie_settings.h" | 10 #include "chrome/browser/content_settings/cookie_settings.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 virtual ~CookiesTreeModelTest() { | 44 virtual ~CookiesTreeModelTest() { |
45 // Avoid memory leaks. | 45 // Avoid memory leaks. |
46 profile_.reset(); | 46 profile_.reset(); |
47 message_loop_.RunAllPending(); | 47 message_loop_.RunAllPending(); |
48 } | 48 } |
49 | 49 |
50 virtual void SetUp() OVERRIDE { | 50 virtual void SetUp() OVERRIDE { |
51 profile_.reset(new TestingProfile()); | 51 profile_.reset(new TestingProfile()); |
52 profile_->CreateRequestContext(); | 52 profile_->CreateRequestContext(); |
53 mock_browsing_data_cookie_helper_ = | 53 mock_browsing_data_cookie_helper_ = |
54 new MockBrowsingDataCookieHelper(profile_->GetRequestContext()); | 54 new MockBrowsingDataCookieHelper(profile_->GetRequestContext()); |
55 mock_browsing_data_database_helper_ = | 55 mock_browsing_data_database_helper_ = |
56 new MockBrowsingDataDatabaseHelper(profile_.get()); | 56 new MockBrowsingDataDatabaseHelper(profile_.get()); |
57 mock_browsing_data_local_storage_helper_ = | 57 mock_browsing_data_local_storage_helper_ = |
58 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 58 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
59 mock_browsing_data_session_storage_helper_ = | 59 mock_browsing_data_session_storage_helper_ = |
60 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 60 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
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()); |
71 } | 77 } |
72 | 78 |
73 virtual void TearDown() OVERRIDE { | 79 virtual void TearDown() OVERRIDE { |
74 mock_browsing_data_server_bound_cert_helper_ = NULL; | 80 mock_browsing_data_server_bound_cert_helper_ = NULL; |
75 mock_browsing_data_quota_helper_ = NULL; | 81 mock_browsing_data_quota_helper_ = NULL; |
76 mock_browsing_data_file_system_helper_ = NULL; | 82 mock_browsing_data_file_system_helper_ = NULL; |
77 mock_browsing_data_indexed_db_helper_ = NULL; | 83 mock_browsing_data_indexed_db_helper_ = NULL; |
78 mock_browsing_data_appcache_helper_ = NULL; | 84 mock_browsing_data_appcache_helper_ = NULL; |
79 mock_browsing_data_session_storage_helper_ = NULL; | 85 mock_browsing_data_session_storage_helper_ = NULL; |
80 mock_browsing_data_local_storage_helper_ = NULL; | 86 mock_browsing_data_local_storage_helper_ = NULL; |
81 mock_browsing_data_database_helper_ = NULL; | 87 mock_browsing_data_database_helper_ = NULL; |
82 message_loop_.RunAllPending(); | 88 message_loop_.RunAllPending(); |
83 } | 89 } |
84 | 90 |
85 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { | 91 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample(bool add_app) { |
86 CookiesTreeModel* cookies_model = new CookiesTreeModel( | 92 ContainerMap containers_map; |
| 93 |
| 94 containers_map[std::string()] = new LocalDataContainer( |
| 95 "Drive-By-Web", std::string(), |
87 mock_browsing_data_cookie_helper_, | 96 mock_browsing_data_cookie_helper_, |
88 mock_browsing_data_database_helper_, | 97 mock_browsing_data_database_helper_, |
89 mock_browsing_data_local_storage_helper_, | 98 mock_browsing_data_local_storage_helper_, |
90 mock_browsing_data_session_storage_helper_, | 99 mock_browsing_data_session_storage_helper_, |
91 mock_browsing_data_appcache_helper_, | 100 mock_browsing_data_appcache_helper_, |
92 mock_browsing_data_indexed_db_helper_, | 101 mock_browsing_data_indexed_db_helper_, |
93 mock_browsing_data_file_system_helper_, | 102 mock_browsing_data_file_system_helper_, |
94 mock_browsing_data_quota_helper_, | 103 mock_browsing_data_quota_helper_, |
95 mock_browsing_data_server_bound_cert_helper_, | 104 mock_browsing_data_server_bound_cert_helper_); |
96 false); | 105 |
| 106 if (add_app) { |
| 107 std::string app_id = "some-random-id"; |
| 108 // The cookie helper is mandatory, the rest can be NULL. |
| 109 containers_map[app_id] = new LocalDataContainer( |
| 110 "Isolated App", app_id, |
| 111 mock_browsing_data_cookie_helper_app_, |
| 112 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); |
| 113 } |
| 114 |
| 115 CookiesTreeModel* cookies_model = new CookiesTreeModel(containers_map, |
| 116 false); |
97 mock_browsing_data_cookie_helper_-> | 117 mock_browsing_data_cookie_helper_-> |
98 AddCookieSamples(GURL("http://foo1"), "A=1"); | 118 AddCookieSamples(GURL("http://foo1"), "A=1"); |
99 mock_browsing_data_cookie_helper_-> | 119 mock_browsing_data_cookie_helper_-> |
100 AddCookieSamples(GURL("http://foo2"), "B=1"); | 120 AddCookieSamples(GURL("http://foo2"), "B=1"); |
101 mock_browsing_data_cookie_helper_-> | 121 mock_browsing_data_cookie_helper_-> |
102 AddCookieSamples(GURL("http://foo3"), "C=1"); | 122 AddCookieSamples(GURL("http://foo3"), "C=1"); |
103 mock_browsing_data_cookie_helper_->Notify(); | 123 mock_browsing_data_cookie_helper_->Notify(); |
104 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 124 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
105 mock_browsing_data_database_helper_->Notify(); | 125 mock_browsing_data_database_helper_->Notify(); |
106 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 126 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
107 mock_browsing_data_local_storage_helper_->Notify(); | 127 mock_browsing_data_local_storage_helper_->Notify(); |
108 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 128 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
109 mock_browsing_data_session_storage_helper_->Notify(); | 129 mock_browsing_data_session_storage_helper_->Notify(); |
110 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 130 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
111 mock_browsing_data_indexed_db_helper_->Notify(); | 131 mock_browsing_data_indexed_db_helper_->Notify(); |
112 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 132 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
113 mock_browsing_data_file_system_helper_->Notify(); | 133 mock_browsing_data_file_system_helper_->Notify(); |
114 mock_browsing_data_quota_helper_->AddQuotaSamples(); | 134 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
115 mock_browsing_data_quota_helper_->Notify(); | 135 mock_browsing_data_quota_helper_->Notify(); |
116 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( | 136 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( |
117 "sbc1"); | 137 "sbc1"); |
118 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( | 138 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( |
119 "sbc2"); | 139 "sbc2"); |
120 mock_browsing_data_server_bound_cert_helper_->Notify(); | 140 mock_browsing_data_server_bound_cert_helper_->Notify(); |
| 141 |
| 142 if (add_app) { |
| 143 mock_browsing_data_cookie_helper_app_-> |
| 144 AddCookieSamples(GURL("http://app-origin1"), "Z=1"); |
| 145 mock_browsing_data_cookie_helper_app_-> |
| 146 AddCookieSamples(GURL("http://app-origin2"), "Y=1"); |
| 147 mock_browsing_data_cookie_helper_app_-> |
| 148 AddCookieSamples(GURL("http://app-origin3"), "X=1"); |
| 149 mock_browsing_data_cookie_helper_app_->Notify(); |
| 150 } |
| 151 |
121 { | 152 { |
122 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " | 153 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " |
123 "2 session storages, 2 indexed DBs, 3 filesystems, " | 154 "2 session storages, 2 indexed DBs, 3 filesystems, " |
124 "2 quotas"); | 155 "2 quotas, 2 server bound certs"); |
125 // 45 because there's the root, then foo1 -> cookies -> a, | 156 // 51 because there's the root, then |
126 // foo2 -> cookies -> b, foo3 -> cookies -> c, | 157 // foo1 -> cookies -> a, |
127 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 158 // foo2 -> cookies -> b, |
| 159 // foo3 -> cookies -> c, |
| 160 // dbhost1 -> database -> db1, |
| 161 // dbhost2 -> database -> db2, |
| 162 // host1 -> localstorage -> http://host1:1/, |
| 163 // -> sessionstorage -> http://host1:1/, |
| 164 // host2 -> localstorage -> http://host2:2/. |
| 165 // -> sessionstorage -> http://host2:2/, |
| 166 // idbhost1 -> indexeddb -> http://idbhost1:1/, |
| 167 // idbhost2 -> indexeddb -> http://idbhost2:2/, |
128 // fshost1 -> filesystem -> http://fshost1:1/, | 168 // fshost1 -> filesystem -> http://fshost1:1/, |
129 // fshost2 -> filesystem -> http://fshost2:1/, | 169 // fshost2 -> filesystem -> http://fshost2:1/, |
130 // fshost3 -> filesystem -> http://fshost3:1/, | 170 // 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, | 171 // quotahost1 -> quotahost1, |
138 // quotahost2 -> quotahost2, | 172 // quotahost2 -> quotahost2, |
139 // sbc1 -> sbcerts -> sbc1, | 173 // sbc1 -> sbcerts -> sbc1, |
140 // sbc2 -> sbcerts -> sbc2. | 174 // sbc2 -> sbcerts -> sbc2. |
141 EXPECT_EQ(51, cookies_model->GetRoot()->GetTotalNodeCount()); | 175 if (!add_app) { |
142 EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model)); | 176 EXPECT_EQ(51, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 177 EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model)); |
| 178 } else { |
| 179 // Once we add the app, we have 9 more nodes: |
| 180 // app-origin1 -> cookies -> z, |
| 181 // app-origin2 -> cookies -> y, |
| 182 // app-origin3 -> cookies -> x, |
| 183 EXPECT_EQ(60, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 184 EXPECT_EQ("A,B,C,Z,Y,X", GetDisplayedCookies(cookies_model)); |
| 185 } |
143 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); | 186 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); |
144 EXPECT_EQ("http://host1:1/,http://host2:2/", | 187 EXPECT_EQ("http://host1:1/,http://host2:2/", |
145 GetDisplayedLocalStorages(cookies_model)); | 188 GetDisplayedLocalStorages(cookies_model)); |
146 EXPECT_EQ("http://host1:1/,http://host2:2/", | 189 EXPECT_EQ("http://host1:1/,http://host2:2/", |
147 GetDisplayedSessionStorages(cookies_model)); | 190 GetDisplayedSessionStorages(cookies_model)); |
148 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 191 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
149 GetDisplayedIndexedDBs(cookies_model)); | 192 GetDisplayedIndexedDBs(cookies_model)); |
150 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 193 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
151 GetDisplayedFileSystems(cookies_model)); | 194 GetDisplayedFileSystems(cookies_model)); |
152 EXPECT_EQ("quotahost1,quotahost2", | 195 EXPECT_EQ("quotahost1,quotahost2", |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 scoped_refptr<MockBrowsingDataAppCacheHelper> | 363 scoped_refptr<MockBrowsingDataAppCacheHelper> |
321 mock_browsing_data_appcache_helper_; | 364 mock_browsing_data_appcache_helper_; |
322 scoped_refptr<MockBrowsingDataIndexedDBHelper> | 365 scoped_refptr<MockBrowsingDataIndexedDBHelper> |
323 mock_browsing_data_indexed_db_helper_; | 366 mock_browsing_data_indexed_db_helper_; |
324 scoped_refptr<MockBrowsingDataFileSystemHelper> | 367 scoped_refptr<MockBrowsingDataFileSystemHelper> |
325 mock_browsing_data_file_system_helper_; | 368 mock_browsing_data_file_system_helper_; |
326 scoped_refptr<MockBrowsingDataQuotaHelper> | 369 scoped_refptr<MockBrowsingDataQuotaHelper> |
327 mock_browsing_data_quota_helper_; | 370 mock_browsing_data_quota_helper_; |
328 scoped_refptr<MockBrowsingDataServerBoundCertHelper> | 371 scoped_refptr<MockBrowsingDataServerBoundCertHelper> |
329 mock_browsing_data_server_bound_cert_helper_; | 372 mock_browsing_data_server_bound_cert_helper_; |
| 373 |
| 374 // App helpers. |
| 375 scoped_refptr<MockBrowsingDataCookieHelper> |
| 376 mock_browsing_data_cookie_helper_app_; |
330 }; | 377 }; |
331 | 378 |
332 TEST_F(CookiesTreeModelTest, RemoveAll) { | 379 TEST_F(CookiesTreeModelTest, RemoveAll) { |
333 scoped_ptr<CookiesTreeModel> cookies_model( | 380 scoped_ptr<CookiesTreeModel> cookies_model( |
334 CreateCookiesTreeModelWithInitialSample()); | 381 CreateCookiesTreeModelWithInitialSample(false)); |
335 | 382 |
336 // Reset the selection of the first row. | 383 // Reset the selection of the first row. |
337 { | 384 { |
338 SCOPED_TRACE("Before removing"); | 385 SCOPED_TRACE("Before removing"); |
339 EXPECT_EQ("A,B,C", | 386 EXPECT_EQ("A,B,C", |
340 GetDisplayedCookies(cookies_model.get())); | 387 GetDisplayedCookies(cookies_model.get())); |
341 EXPECT_EQ("db1,db2", | 388 EXPECT_EQ("db1,db2", |
342 GetDisplayedDatabases(cookies_model.get())); | 389 GetDisplayedDatabases(cookies_model.get())); |
343 EXPECT_EQ("http://host1:1/,http://host2:2/", | 390 EXPECT_EQ("http://host1:1/,http://host2:2/", |
344 GetDisplayedLocalStorages(cookies_model.get())); | 391 GetDisplayedLocalStorages(cookies_model.get())); |
(...skipping 13 matching lines...) Expand all Loading... |
358 mock_browsing_data_database_helper_->Reset(); | 405 mock_browsing_data_database_helper_->Reset(); |
359 mock_browsing_data_local_storage_helper_->Reset(); | 406 mock_browsing_data_local_storage_helper_->Reset(); |
360 mock_browsing_data_session_storage_helper_->Reset(); | 407 mock_browsing_data_session_storage_helper_->Reset(); |
361 mock_browsing_data_indexed_db_helper_->Reset(); | 408 mock_browsing_data_indexed_db_helper_->Reset(); |
362 mock_browsing_data_file_system_helper_->Reset(); | 409 mock_browsing_data_file_system_helper_->Reset(); |
363 | 410 |
364 cookies_model->DeleteAllStoredObjects(); | 411 cookies_model->DeleteAllStoredObjects(); |
365 | 412 |
366 // Make sure the nodes are also deleted from the model's cache. | 413 // Make sure the nodes are also deleted from the model's cache. |
367 // http://crbug.com/43249 | 414 // http://crbug.com/43249 |
368 cookies_model->UpdateSearchResults(std::wstring()); | 415 cookies_model->UpdateSearchResults(string16()); |
369 | 416 |
370 { | 417 { |
| 418 // 2 nodes - root and app |
371 SCOPED_TRACE("After removing"); | 419 SCOPED_TRACE("After removing"); |
372 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); | 420 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); |
373 EXPECT_EQ(0, cookies_model->GetRoot()->child_count()); | 421 EXPECT_EQ(0, cookies_model->GetRoot()->child_count()); |
374 EXPECT_EQ(std::string(""), GetDisplayedCookies(cookies_model.get())); | 422 EXPECT_EQ(std::string(""), GetDisplayedCookies(cookies_model.get())); |
375 EXPECT_TRUE(mock_browsing_data_cookie_helper_->AllDeleted()); | 423 EXPECT_TRUE(mock_browsing_data_cookie_helper_->AllDeleted()); |
376 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); | 424 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); |
377 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); | 425 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); |
378 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted()); | 426 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted()); |
379 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted()); | 427 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted()); |
380 EXPECT_TRUE(mock_browsing_data_file_system_helper_->AllDeleted()); | 428 EXPECT_TRUE(mock_browsing_data_file_system_helper_->AllDeleted()); |
381 EXPECT_TRUE(mock_browsing_data_server_bound_cert_helper_->AllDeleted()); | 429 EXPECT_TRUE(mock_browsing_data_server_bound_cert_helper_->AllDeleted()); |
382 } | 430 } |
383 } | 431 } |
384 | 432 |
385 TEST_F(CookiesTreeModelTest, Remove) { | 433 TEST_F(CookiesTreeModelTest, Remove) { |
386 scoped_ptr<CookiesTreeModel> cookies_model( | 434 scoped_ptr<CookiesTreeModel> cookies_model( |
387 CreateCookiesTreeModelWithInitialSample()); | 435 CreateCookiesTreeModelWithInitialSample(false)); |
388 | 436 |
389 // Children start out arranged as follows: | 437 // Children start out arranged as follows: |
390 // | 438 // |
391 // 0. `foo1` | 439 // 0. `foo1` |
392 // 1. `foo2` | 440 // 1. `foo2` |
393 // 2. `foo3` | 441 // 2. `foo3` |
394 // 3. `fshost1` | 442 // 3. `fshost1` |
395 // 4. `fshost2` | 443 // 4. `fshost2` |
396 // 5. `fshost3` | 444 // 5. `fshost3` |
397 // 6. `gdbhost1` | 445 // 6. `gdbhost1` |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); | 668 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
621 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); | 669 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
622 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); | 670 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
623 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); | 671 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
624 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); | 672 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); |
625 } | 673 } |
626 } | 674 } |
627 | 675 |
628 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { | 676 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { |
629 scoped_ptr<CookiesTreeModel> cookies_model( | 677 scoped_ptr<CookiesTreeModel> cookies_model( |
630 CreateCookiesTreeModelWithInitialSample()); | 678 CreateCookiesTreeModelWithInitialSample(false)); |
631 | 679 |
632 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); | 680 DeleteStoredObjects( |
| 681 cookies_model->GetRoot()->GetChild(0)->GetChild(0)); |
633 { | 682 { |
634 SCOPED_TRACE("First origin removed"); | 683 SCOPED_TRACE("First origin removed"); |
635 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 684 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
636 // 43 because in this case, the origin remains, although the COOKIES | 685 // 49 because in this case, the origin remains, although the COOKIES |
637 // node beneath it has been deleted. So, we have | 686 // node beneath it has been deleted. |
638 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | |
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()); | 687 EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount()); |
652 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 688 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
653 EXPECT_EQ("http://host1:1/,http://host2:2/", | 689 EXPECT_EQ("http://host1:1/,http://host2:2/", |
654 GetDisplayedLocalStorages(cookies_model.get())); | 690 GetDisplayedLocalStorages(cookies_model.get())); |
655 EXPECT_EQ("http://host1:1/,http://host2:2/", | 691 EXPECT_EQ("http://host1:1/,http://host2:2/", |
656 GetDisplayedSessionStorages(cookies_model.get())); | 692 GetDisplayedSessionStorages(cookies_model.get())); |
657 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 693 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
658 GetDisplayedIndexedDBs(cookies_model.get())); | 694 GetDisplayedIndexedDBs(cookies_model.get())); |
659 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 695 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
660 GetDisplayedFileSystems(cookies_model.get())); | 696 GetDisplayedFileSystems(cookies_model.get())); |
661 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 697 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
662 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 698 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
663 } | 699 } |
664 | 700 |
665 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 701 DeleteStoredObjects( |
| 702 cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
666 { | 703 { |
667 SCOPED_TRACE("First database removed"); | 704 SCOPED_TRACE("First database removed"); |
668 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 705 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
669 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 706 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
670 EXPECT_EQ("http://host1:1/,http://host2:2/", | 707 EXPECT_EQ("http://host1:1/,http://host2:2/", |
671 GetDisplayedLocalStorages(cookies_model.get())); | 708 GetDisplayedLocalStorages(cookies_model.get())); |
672 EXPECT_EQ("http://host1:1/,http://host2:2/", | 709 EXPECT_EQ("http://host1:1/,http://host2:2/", |
673 GetDisplayedSessionStorages(cookies_model.get())); | 710 GetDisplayedSessionStorages(cookies_model.get())); |
674 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 711 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
675 GetDisplayedIndexedDBs(cookies_model.get())); | 712 GetDisplayedIndexedDBs(cookies_model.get())); |
676 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 713 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
677 GetDisplayedFileSystems(cookies_model.get())); | 714 GetDisplayedFileSystems(cookies_model.get())); |
678 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 715 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
679 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 716 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
680 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount()); | 717 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount()); |
681 } | 718 } |
682 | 719 |
683 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 720 DeleteStoredObjects( |
| 721 cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
684 { | 722 { |
685 SCOPED_TRACE("First origin removed"); | 723 SCOPED_TRACE("First origin removed"); |
686 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 724 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
687 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 725 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
688 EXPECT_EQ("http://host2:2/", | 726 EXPECT_EQ("http://host2:2/", |
689 GetDisplayedLocalStorages(cookies_model.get())); | 727 GetDisplayedLocalStorages(cookies_model.get())); |
690 EXPECT_EQ("http://host1:1/,http://host2:2/", | 728 EXPECT_EQ("http://host1:1/,http://host2:2/", |
691 GetDisplayedSessionStorages(cookies_model.get())); | 729 GetDisplayedSessionStorages(cookies_model.get())); |
692 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 730 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
693 GetDisplayedIndexedDBs(cookies_model.get())); | 731 GetDisplayedIndexedDBs(cookies_model.get())); |
694 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 732 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
695 GetDisplayedFileSystems(cookies_model.get())); | 733 GetDisplayedFileSystems(cookies_model.get())); |
696 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 734 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
697 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 735 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
698 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); | 736 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); |
699 } | 737 } |
700 } | 738 } |
701 | 739 |
702 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { | 740 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { |
703 scoped_ptr<CookiesTreeModel> cookies_model( | 741 scoped_ptr<CookiesTreeModel> cookies_model( |
704 CreateCookiesTreeModelWithInitialSample()); | 742 CreateCookiesTreeModelWithInitialSample(false)); |
705 | 743 |
706 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); | 744 DeleteStoredObjects( |
| 745 cookies_model->GetRoot()->GetChild(1)->GetChild(0)); |
707 { | 746 { |
708 SCOPED_TRACE("Second origin COOKIES node removed"); | 747 SCOPED_TRACE("Second origin COOKIES node removed"); |
709 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 748 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
710 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 749 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
711 EXPECT_EQ("http://host1:1/,http://host2:2/", | 750 EXPECT_EQ("http://host1:1/,http://host2:2/", |
712 GetDisplayedLocalStorages(cookies_model.get())); | 751 GetDisplayedLocalStorages(cookies_model.get())); |
713 EXPECT_EQ("http://host1:1/,http://host2:2/", | 752 EXPECT_EQ("http://host1:1/,http://host2:2/", |
714 GetDisplayedSessionStorages(cookies_model.get())); | 753 GetDisplayedSessionStorages(cookies_model.get())); |
715 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 754 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
716 GetDisplayedIndexedDBs(cookies_model.get())); | 755 GetDisplayedIndexedDBs(cookies_model.get())); |
717 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 756 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
718 GetDisplayedFileSystems(cookies_model.get())); | 757 GetDisplayedFileSystems(cookies_model.get())); |
719 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 758 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
720 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 759 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
721 // 43 because in this case, the origin remains, although the COOKIES | 760 // 49 because in this case, the origin remains, although the COOKIES |
722 // node beneath it has been deleted. So, we have | 761 // node beneath it has been deleted. |
723 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | |
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()); | 762 EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount()); |
737 } | 763 } |
738 | 764 |
739 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 765 DeleteStoredObjects( |
| 766 cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
740 { | 767 { |
741 SCOPED_TRACE("First database removed"); | 768 SCOPED_TRACE("First database removed"); |
742 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 769 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
743 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 770 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
744 EXPECT_EQ("http://host1:1/,http://host2:2/", | 771 EXPECT_EQ("http://host1:1/,http://host2:2/", |
745 GetDisplayedLocalStorages(cookies_model.get())); | 772 GetDisplayedLocalStorages(cookies_model.get())); |
746 EXPECT_EQ("http://host1:1/,http://host2:2/", | 773 EXPECT_EQ("http://host1:1/,http://host2:2/", |
747 GetDisplayedSessionStorages(cookies_model.get())); | 774 GetDisplayedSessionStorages(cookies_model.get())); |
748 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 775 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
749 GetDisplayedIndexedDBs(cookies_model.get())); | 776 GetDisplayedIndexedDBs(cookies_model.get())); |
750 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 777 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
751 GetDisplayedFileSystems(cookies_model.get())); | 778 GetDisplayedFileSystems(cookies_model.get())); |
752 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 779 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
753 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 780 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
754 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount()); | 781 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount()); |
755 } | 782 } |
756 | 783 |
757 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 784 DeleteStoredObjects( |
| 785 cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
758 { | 786 { |
759 SCOPED_TRACE("First origin removed"); | 787 SCOPED_TRACE("First origin removed"); |
760 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 788 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
761 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 789 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
762 EXPECT_EQ("http://host2:2/", | 790 EXPECT_EQ("http://host2:2/", |
763 GetDisplayedLocalStorages(cookies_model.get())); | 791 GetDisplayedLocalStorages(cookies_model.get())); |
764 EXPECT_EQ("http://host1:1/,http://host2:2/", | 792 EXPECT_EQ("http://host1:1/,http://host2:2/", |
765 GetDisplayedSessionStorages(cookies_model.get())); | 793 GetDisplayedSessionStorages(cookies_model.get())); |
766 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 794 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
767 GetDisplayedIndexedDBs(cookies_model.get())); | 795 GetDisplayedIndexedDBs(cookies_model.get())); |
768 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 796 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
769 GetDisplayedFileSystems(cookies_model.get())); | 797 GetDisplayedFileSystems(cookies_model.get())); |
770 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); | 798 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
771 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); | 799 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); |
772 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); | 800 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); |
773 } | 801 } |
774 } | 802 } |
775 | 803 |
776 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { | 804 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { |
777 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 805 ContainerMap container_map; |
778 mock_browsing_data_database_helper_, | 806 |
779 mock_browsing_data_local_storage_helper_, | 807 container_map[std::string()] = new LocalDataContainer( |
780 mock_browsing_data_session_storage_helper_, | 808 "Drive-By-Web", std::string(), |
781 mock_browsing_data_appcache_helper_, | 809 mock_browsing_data_cookie_helper_, |
782 mock_browsing_data_indexed_db_helper_, | 810 mock_browsing_data_database_helper_, |
783 mock_browsing_data_file_system_helper_, | 811 mock_browsing_data_local_storage_helper_, |
784 mock_browsing_data_quota_helper_, | 812 mock_browsing_data_session_storage_helper_, |
785 mock_browsing_data_server_bound_cert_helper_, | 813 mock_browsing_data_appcache_helper_, |
786 false); | 814 mock_browsing_data_indexed_db_helper_, |
| 815 mock_browsing_data_file_system_helper_, |
| 816 mock_browsing_data_quota_helper_, |
| 817 mock_browsing_data_server_bound_cert_helper_); |
| 818 CookiesTreeModel cookies_model(container_map, false); |
| 819 |
787 mock_browsing_data_cookie_helper_-> | 820 mock_browsing_data_cookie_helper_-> |
788 AddCookieSamples(GURL("http://foo1"), "A=1"); | 821 AddCookieSamples(GURL("http://foo1"), "A=1"); |
789 mock_browsing_data_cookie_helper_-> | 822 mock_browsing_data_cookie_helper_-> |
790 AddCookieSamples(GURL("http://foo2"), "B=1"); | 823 AddCookieSamples(GURL("http://foo2"), "B=1"); |
791 mock_browsing_data_cookie_helper_-> | 824 mock_browsing_data_cookie_helper_-> |
792 AddCookieSamples(GURL("http://foo3"), "C=1"); | 825 AddCookieSamples(GURL("http://foo3"), "C=1"); |
793 mock_browsing_data_cookie_helper_-> | 826 mock_browsing_data_cookie_helper_-> |
794 AddCookieSamples(GURL("http://foo3"), "D=1"); | 827 AddCookieSamples(GURL("http://foo3"), "D=1"); |
795 mock_browsing_data_cookie_helper_->Notify(); | 828 mock_browsing_data_cookie_helper_->Notify(); |
796 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 829 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
797 mock_browsing_data_database_helper_->Notify(); | 830 mock_browsing_data_database_helper_->Notify(); |
798 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 831 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
799 mock_browsing_data_local_storage_helper_->Notify(); | 832 mock_browsing_data_local_storage_helper_->Notify(); |
800 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 833 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
801 mock_browsing_data_session_storage_helper_->Notify(); | 834 mock_browsing_data_session_storage_helper_->Notify(); |
802 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 835 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
803 mock_browsing_data_indexed_db_helper_->Notify(); | 836 mock_browsing_data_indexed_db_helper_->Notify(); |
804 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 837 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
805 mock_browsing_data_file_system_helper_->Notify(); | 838 mock_browsing_data_file_system_helper_->Notify(); |
806 mock_browsing_data_quota_helper_->AddQuotaSamples(); | 839 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
807 mock_browsing_data_quota_helper_->Notify(); | 840 mock_browsing_data_quota_helper_->Notify(); |
808 | 841 |
809 { | 842 { |
810 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " | 843 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " |
811 "2 session storages, 2 indexed DBs, 3 file systems, " | 844 "2 session storages, 2 indexed DBs, 3 file systems, " |
812 "2 quotas."); | 845 "2 quotas."); |
813 // 42 because there's the root, then foo1 -> cookies -> a, | 846 // 46 because there's the root, then |
814 // foo2 -> cookies -> b, foo3 -> cookies -> c,d | 847 // foo1 -> cookies -> a, |
815 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 848 // foo2 -> cookies -> b, |
| 849 // foo3 -> cookies -> c,d |
| 850 // dbhost1 -> database -> db1, |
| 851 // dbhost2 -> database -> db2, |
| 852 // host1 -> localstorage -> http://host1:1/, |
| 853 // -> sessionstorage -> http://host1:1/, |
| 854 // host2 -> localstorage -> http://host2:2/, |
| 855 // -> sessionstorage -> http://host2:2/, |
| 856 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 857 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
816 // fshost1 -> filesystem -> http://fshost1:1/, | 858 // fshost1 -> filesystem -> http://fshost1:1/, |
817 // fshost2 -> filesystem -> http://fshost2:1/, | 859 // fshost2 -> filesystem -> http://fshost2:1/, |
818 // fshost3 -> filesystem -> http://fshost3:1/, | 860 // 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, | 861 // quotahost1 -> quotahost1, |
825 // quotahost2 -> quotahost2. | 862 // quotahost2 -> quotahost2. |
826 EXPECT_EQ(46, cookies_model.GetRoot()->GetTotalNodeCount()); | 863 EXPECT_EQ(46, cookies_model.GetRoot()->GetTotalNodeCount()); |
827 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); | 864 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); |
828 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 865 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
829 EXPECT_EQ("http://host1:1/,http://host2:2/", | 866 EXPECT_EQ("http://host1:1/,http://host2:2/", |
830 GetDisplayedLocalStorages(&cookies_model)); | 867 GetDisplayedLocalStorages(&cookies_model)); |
831 EXPECT_EQ("http://host1:1/,http://host2:2/", | 868 EXPECT_EQ("http://host1:1/,http://host2:2/", |
832 GetDisplayedSessionStorages(&cookies_model)); | 869 GetDisplayedSessionStorages(&cookies_model)); |
833 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 870 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
(...skipping 14 matching lines...) Expand all Loading... |
848 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 885 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
849 GetDisplayedIndexedDBs(&cookies_model)); | 886 GetDisplayedIndexedDBs(&cookies_model)); |
850 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 887 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
851 GetDisplayedFileSystems(&cookies_model)); | 888 GetDisplayedFileSystems(&cookies_model)); |
852 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); | 889 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
853 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); | 890 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); |
854 } | 891 } |
855 } | 892 } |
856 | 893 |
857 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { | 894 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { |
858 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 895 ContainerMap container_map; |
859 mock_browsing_data_database_helper_, | 896 |
860 mock_browsing_data_local_storage_helper_, | 897 container_map[std::string()] = new LocalDataContainer( |
861 mock_browsing_data_session_storage_helper_, | 898 "Drive-By-Web", std::string(), |
862 mock_browsing_data_appcache_helper_, | 899 mock_browsing_data_cookie_helper_, |
863 mock_browsing_data_indexed_db_helper_, | 900 mock_browsing_data_database_helper_, |
864 mock_browsing_data_file_system_helper_, | 901 mock_browsing_data_local_storage_helper_, |
865 mock_browsing_data_quota_helper_, | 902 mock_browsing_data_session_storage_helper_, |
866 mock_browsing_data_server_bound_cert_helper_, | 903 mock_browsing_data_appcache_helper_, |
867 false); | 904 mock_browsing_data_indexed_db_helper_, |
| 905 mock_browsing_data_file_system_helper_, |
| 906 mock_browsing_data_quota_helper_, |
| 907 mock_browsing_data_server_bound_cert_helper_); |
| 908 CookiesTreeModel cookies_model(container_map, false); |
| 909 |
868 mock_browsing_data_cookie_helper_-> | 910 mock_browsing_data_cookie_helper_-> |
869 AddCookieSamples(GURL("http://foo1"), "A=1"); | 911 AddCookieSamples(GURL("http://foo1"), "A=1"); |
870 mock_browsing_data_cookie_helper_-> | 912 mock_browsing_data_cookie_helper_-> |
871 AddCookieSamples(GURL("http://foo2"), "B=1"); | 913 AddCookieSamples(GURL("http://foo2"), "B=1"); |
872 mock_browsing_data_cookie_helper_-> | 914 mock_browsing_data_cookie_helper_-> |
873 AddCookieSamples(GURL("http://foo3"), "C=1"); | 915 AddCookieSamples(GURL("http://foo3"), "C=1"); |
874 mock_browsing_data_cookie_helper_-> | 916 mock_browsing_data_cookie_helper_-> |
875 AddCookieSamples(GURL("http://foo3"), "D=1"); | 917 AddCookieSamples(GURL("http://foo3"), "D=1"); |
876 mock_browsing_data_cookie_helper_-> | 918 mock_browsing_data_cookie_helper_-> |
877 AddCookieSamples(GURL("http://foo3"), "E=1"); | 919 AddCookieSamples(GURL("http://foo3"), "E=1"); |
878 mock_browsing_data_cookie_helper_->Notify(); | 920 mock_browsing_data_cookie_helper_->Notify(); |
879 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 921 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
880 mock_browsing_data_database_helper_->Notify(); | 922 mock_browsing_data_database_helper_->Notify(); |
881 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 923 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
882 mock_browsing_data_local_storage_helper_->Notify(); | 924 mock_browsing_data_local_storage_helper_->Notify(); |
883 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 925 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
884 mock_browsing_data_session_storage_helper_->Notify(); | 926 mock_browsing_data_session_storage_helper_->Notify(); |
885 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 927 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
886 mock_browsing_data_indexed_db_helper_->Notify(); | 928 mock_browsing_data_indexed_db_helper_->Notify(); |
887 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 929 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
888 mock_browsing_data_file_system_helper_->Notify(); | 930 mock_browsing_data_file_system_helper_->Notify(); |
889 mock_browsing_data_quota_helper_->AddQuotaSamples(); | 931 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
890 mock_browsing_data_quota_helper_->Notify(); | 932 mock_browsing_data_quota_helper_->Notify(); |
891 | 933 |
892 { | 934 { |
893 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " | 935 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " |
894 "2 session storages, 2 indexed DBs, 3 filesystems, " | 936 "2 session storages, 2 indexed DBs, 3 filesystems, " |
895 "2 quotas."); | 937 "2 quotas."); |
896 // 43 because there's the root, then foo1 -> cookies -> a, | 938 // 47 because there's the root, then |
897 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 939 // foo1 -> cookies -> a, |
898 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 940 // foo2 -> cookies -> b, |
| 941 // foo3 -> cookies -> c,d,e |
| 942 // dbhost1 -> database -> db1, |
| 943 // dbhost2 -> database -> db2, |
| 944 // host1 -> localstorage -> http://host1:1/, |
| 945 // -> sessionstorage -> http://host1:1/, |
| 946 // host2 -> localstorage -> http://host2:2/, |
| 947 // -> sessionstorage -> http://host2:2/, |
| 948 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 949 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
899 // fshost1 -> filesystem -> http://fshost1:1/, | 950 // fshost1 -> filesystem -> http://fshost1:1/, |
900 // fshost2 -> filesystem -> http://fshost2:1/, | 951 // fshost2 -> filesystem -> http://fshost2:1/, |
901 // fshost3 -> filesystem -> http://fshost3:1/, | 952 // 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, | 953 // quotahost1 -> quotahost1, |
909 // quotahost2 -> quotahost2. | 954 // quotahost2 -> quotahost2. |
910 EXPECT_EQ(47, cookies_model.GetRoot()->GetTotalNodeCount()); | 955 EXPECT_EQ(47, cookies_model.GetRoot()->GetTotalNodeCount()); |
911 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 956 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
912 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 957 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
913 EXPECT_EQ("http://host1:1/,http://host2:2/", | 958 EXPECT_EQ("http://host1:1/,http://host2:2/", |
914 GetDisplayedLocalStorages(&cookies_model)); | 959 GetDisplayedLocalStorages(&cookies_model)); |
915 EXPECT_EQ("http://host1:1/,http://host2:2/", | 960 EXPECT_EQ("http://host1:1/,http://host2:2/", |
916 GetDisplayedSessionStorages(&cookies_model)); | 961 GetDisplayedSessionStorages(&cookies_model)); |
917 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 962 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
(...skipping 15 matching lines...) Expand all Loading... |
933 GetDisplayedSessionStorages(&cookies_model)); | 978 GetDisplayedSessionStorages(&cookies_model)); |
934 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 979 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
935 GetDisplayedIndexedDBs(&cookies_model)); | 980 GetDisplayedIndexedDBs(&cookies_model)); |
936 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 981 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
937 GetDisplayedFileSystems(&cookies_model)); | 982 GetDisplayedFileSystems(&cookies_model)); |
938 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); | 983 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
939 } | 984 } |
940 } | 985 } |
941 | 986 |
942 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { | 987 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { |
943 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 988 ContainerMap container_map; |
944 mock_browsing_data_database_helper_, | 989 |
945 mock_browsing_data_local_storage_helper_, | 990 container_map[std::string()] = new LocalDataContainer( |
946 mock_browsing_data_session_storage_helper_, | 991 "Drive-By-Web", std::string(), |
947 mock_browsing_data_appcache_helper_, | 992 mock_browsing_data_cookie_helper_, |
948 mock_browsing_data_indexed_db_helper_, | 993 mock_browsing_data_database_helper_, |
949 mock_browsing_data_file_system_helper_, | 994 mock_browsing_data_local_storage_helper_, |
950 mock_browsing_data_quota_helper_, | 995 mock_browsing_data_session_storage_helper_, |
951 mock_browsing_data_server_bound_cert_helper_, | 996 mock_browsing_data_appcache_helper_, |
952 false); | 997 mock_browsing_data_indexed_db_helper_, |
| 998 mock_browsing_data_file_system_helper_, |
| 999 mock_browsing_data_quota_helper_, |
| 1000 mock_browsing_data_server_bound_cert_helper_); |
| 1001 CookiesTreeModel cookies_model(container_map, false); |
| 1002 |
953 mock_browsing_data_cookie_helper_-> | 1003 mock_browsing_data_cookie_helper_-> |
954 AddCookieSamples(GURL("http://foo1"), "A=1"); | 1004 AddCookieSamples(GURL("http://foo1"), "A=1"); |
955 mock_browsing_data_cookie_helper_-> | 1005 mock_browsing_data_cookie_helper_-> |
956 AddCookieSamples(GURL("http://foo2"), "B=1"); | 1006 AddCookieSamples(GURL("http://foo2"), "B=1"); |
957 mock_browsing_data_cookie_helper_-> | 1007 mock_browsing_data_cookie_helper_-> |
958 AddCookieSamples(GURL("http://foo3"), "C=1"); | 1008 AddCookieSamples(GURL("http://foo3"), "C=1"); |
959 mock_browsing_data_cookie_helper_-> | 1009 mock_browsing_data_cookie_helper_-> |
960 AddCookieSamples(GURL("http://foo3"), "D=1"); | 1010 AddCookieSamples(GURL("http://foo3"), "D=1"); |
961 mock_browsing_data_cookie_helper_-> | 1011 mock_browsing_data_cookie_helper_-> |
962 AddCookieSamples(GURL("http://foo3"), "E=1"); | 1012 AddCookieSamples(GURL("http://foo3"), "E=1"); |
963 mock_browsing_data_cookie_helper_->Notify(); | 1013 mock_browsing_data_cookie_helper_->Notify(); |
964 | 1014 |
965 { | 1015 { |
966 SCOPED_TRACE("Initial State 5 cookies"); | 1016 SCOPED_TRACE("Initial State 5 cookies"); |
967 // 11 because there's the root, then foo1 -> cookies -> a, | 1017 // 12 because there's the root, then foo1 -> cookies -> a, |
968 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 1018 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
969 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); | 1019 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); |
970 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 1020 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
971 } | 1021 } |
972 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); | 1022 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); |
973 { | 1023 { |
974 SCOPED_TRACE("Second origin removed"); | 1024 SCOPED_TRACE("Second origin removed"); |
975 EXPECT_STREQ("A,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 1025 EXPECT_STREQ("A,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
976 // Left with root -> foo1 -> cookies -> a, foo3 -> cookies -> c,d,e | 1026 // Left with root -> foo1 -> cookies -> a, foo3 -> cookies -> c,d,e |
977 EXPECT_EQ(9, cookies_model.GetRoot()->GetTotalNodeCount()); | 1027 EXPECT_EQ(9, cookies_model.GetRoot()->GetTotalNodeCount()); |
978 } | 1028 } |
979 } | 1029 } |
980 | 1030 |
981 TEST_F(CookiesTreeModelTest, OriginOrdering) { | 1031 TEST_F(CookiesTreeModelTest, OriginOrdering) { |
982 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 1032 ContainerMap container_map; |
983 mock_browsing_data_database_helper_, | 1033 |
984 mock_browsing_data_local_storage_helper_, | 1034 container_map[std::string()] = new LocalDataContainer( |
985 mock_browsing_data_session_storage_helper_, | 1035 "Drive-By-Web", std::string(), |
986 mock_browsing_data_appcache_helper_, | 1036 mock_browsing_data_cookie_helper_, |
987 mock_browsing_data_indexed_db_helper_, | 1037 mock_browsing_data_database_helper_, |
988 mock_browsing_data_file_system_helper_, | 1038 mock_browsing_data_local_storage_helper_, |
989 mock_browsing_data_quota_helper_, | 1039 mock_browsing_data_session_storage_helper_, |
990 mock_browsing_data_server_bound_cert_helper_, | 1040 mock_browsing_data_appcache_helper_, |
991 false); | 1041 mock_browsing_data_indexed_db_helper_, |
| 1042 mock_browsing_data_file_system_helper_, |
| 1043 mock_browsing_data_quota_helper_, |
| 1044 mock_browsing_data_server_bound_cert_helper_); |
| 1045 CookiesTreeModel cookies_model(container_map, false); |
| 1046 |
992 mock_browsing_data_cookie_helper_-> | 1047 mock_browsing_data_cookie_helper_-> |
993 AddCookieSamples(GURL("http://a.foo2.com"), "A=1"); | 1048 AddCookieSamples(GURL("http://a.foo2.com"), "A=1"); |
994 mock_browsing_data_cookie_helper_-> | 1049 mock_browsing_data_cookie_helper_-> |
995 AddCookieSamples(GURL("http://foo2.com"), "B=1"); | 1050 AddCookieSamples(GURL("http://foo2.com"), "B=1"); |
996 mock_browsing_data_cookie_helper_-> | 1051 mock_browsing_data_cookie_helper_-> |
997 AddCookieSamples(GURL("http://b.foo1.com"), "C=1"); | 1052 AddCookieSamples(GURL("http://b.foo1.com"), "C=1"); |
998 // Leading dot on the foo4 | 1053 // Leading dot on the foo4 |
999 mock_browsing_data_cookie_helper_->AddCookieSamples( | 1054 mock_browsing_data_cookie_helper_->AddCookieSamples( |
1000 GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;"); | 1055 GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;"); |
1001 mock_browsing_data_cookie_helper_-> | 1056 mock_browsing_data_cookie_helper_-> |
1002 AddCookieSamples(GURL("http://a.foo1.com"), "E=1"); | 1057 AddCookieSamples(GURL("http://a.foo1.com"), "E=1"); |
1003 mock_browsing_data_cookie_helper_-> | 1058 mock_browsing_data_cookie_helper_-> |
1004 AddCookieSamples(GURL("http://foo1.com"), "F=1"); | 1059 AddCookieSamples(GURL("http://foo1.com"), "F=1"); |
1005 mock_browsing_data_cookie_helper_-> | 1060 mock_browsing_data_cookie_helper_-> |
1006 AddCookieSamples(GURL("http://foo3.com"), "G=1"); | 1061 AddCookieSamples(GURL("http://foo3.com"), "G=1"); |
1007 mock_browsing_data_cookie_helper_-> | 1062 mock_browsing_data_cookie_helper_-> |
1008 AddCookieSamples(GURL("http://foo4.com"), "H=1"); | 1063 AddCookieSamples(GURL("http://foo4.com"), "H=1"); |
1009 mock_browsing_data_cookie_helper_->Notify(); | 1064 mock_browsing_data_cookie_helper_->Notify(); |
1010 | 1065 |
1011 { | 1066 { |
1012 SCOPED_TRACE("Initial State 8 cookies"); | 1067 SCOPED_TRACE("Initial State 8 cookies"); |
1013 EXPECT_EQ(23, cookies_model.GetRoot()->GetTotalNodeCount()); | 1068 EXPECT_EQ(23, cookies_model.GetRoot()->GetTotalNodeCount()); |
1014 EXPECT_STREQ("F,E,C,B,A,G,D,H", | 1069 EXPECT_STREQ("F,E,C,B,A,G,D,H", |
1015 GetDisplayedCookies(&cookies_model).c_str()); | 1070 GetDisplayedCookies(&cookies_model).c_str()); |
1016 } | 1071 } |
1017 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E" | 1072 // Delete "E" |
| 1073 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); |
1018 { | 1074 { |
1019 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); | 1075 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); |
1020 } | 1076 } |
1021 } | 1077 } |
1022 | 1078 |
1023 TEST_F(CookiesTreeModelTest, ContentSettings) { | 1079 TEST_F(CookiesTreeModelTest, ContentSettings) { |
1024 GURL host("http://example.com/"); | 1080 GURL host("http://example.com/"); |
1025 CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_, | 1081 std::string name = "Drive-By-Web"; |
1026 mock_browsing_data_database_helper_, | 1082 std::string browser_id; |
1027 mock_browsing_data_local_storage_helper_, | 1083 ContainerMap container_map; |
1028 mock_browsing_data_session_storage_helper_, | 1084 |
1029 mock_browsing_data_appcache_helper_, | 1085 container_map[browser_id] = new LocalDataContainer( |
1030 mock_browsing_data_indexed_db_helper_, | 1086 name, browser_id, |
1031 mock_browsing_data_file_system_helper_, | 1087 mock_browsing_data_cookie_helper_, |
1032 mock_browsing_data_quota_helper_, | 1088 mock_browsing_data_database_helper_, |
1033 mock_browsing_data_server_bound_cert_helper_, | 1089 mock_browsing_data_local_storage_helper_, |
1034 false); | 1090 mock_browsing_data_session_storage_helper_, |
| 1091 mock_browsing_data_appcache_helper_, |
| 1092 mock_browsing_data_indexed_db_helper_, |
| 1093 mock_browsing_data_file_system_helper_, |
| 1094 mock_browsing_data_quota_helper_, |
| 1095 mock_browsing_data_server_bound_cert_helper_); |
| 1096 CookiesTreeModel cookies_model(container_map, false); |
| 1097 |
1035 mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1"); | 1098 mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1"); |
1036 mock_browsing_data_cookie_helper_->Notify(); | 1099 mock_browsing_data_cookie_helper_->Notify(); |
1037 | 1100 |
1038 TestingProfile profile; | 1101 TestingProfile profile; |
1039 HostContentSettingsMap* content_settings = | 1102 HostContentSettingsMap* content_settings = |
1040 profile.GetHostContentSettingsMap(); | 1103 profile.GetHostContentSettingsMap(); |
1041 CookieSettings* cookie_settings = | 1104 CookieSettings* cookie_settings = |
1042 CookieSettings::Factory::GetForProfile(&profile); | 1105 CookieSettings::Factory::GetForProfile(&profile); |
1043 MockSettingsObserver observer; | 1106 MockSettingsObserver observer; |
1044 | 1107 |
1045 CookieTreeRootNode* root = | 1108 CookieTreeRootNode* root = |
1046 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); | 1109 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); |
1047 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); | 1110 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host, |
| 1111 browser_id, |
| 1112 name); |
1048 | 1113 |
1049 EXPECT_EQ(1, origin->child_count()); | 1114 EXPECT_EQ(1, origin->child_count()); |
1050 EXPECT_TRUE(origin->CanCreateContentException()); | 1115 EXPECT_TRUE(origin->CanCreateContentException()); |
1051 EXPECT_CALL(observer, | 1116 EXPECT_CALL(observer, |
1052 OnContentSettingsChanged( | 1117 OnContentSettingsChanged( |
1053 content_settings, | 1118 content_settings, |
1054 CONTENT_SETTINGS_TYPE_COOKIES, | 1119 CONTENT_SETTINGS_TYPE_COOKIES, |
1055 false, | 1120 false, |
1056 ContentSettingsPattern::FromURLNoWildcard(host), | 1121 ContentSettingsPattern::FromURLNoWildcard(host), |
1057 ContentSettingsPattern::Wildcard(), | 1122 ContentSettingsPattern::Wildcard(), |
1058 false)); | 1123 false)); |
1059 EXPECT_CALL(observer, | 1124 EXPECT_CALL(observer, |
1060 OnContentSettingsChanged(content_settings, | 1125 OnContentSettingsChanged(content_settings, |
1061 CONTENT_SETTINGS_TYPE_COOKIES, | 1126 CONTENT_SETTINGS_TYPE_COOKIES, |
1062 false, | 1127 false, |
1063 ContentSettingsPattern::FromURL(host), | 1128 ContentSettingsPattern::FromURL(host), |
1064 ContentSettingsPattern::Wildcard(), | 1129 ContentSettingsPattern::Wildcard(), |
1065 false)); | 1130 false)); |
1066 origin->CreateContentException( | 1131 origin->CreateContentException( |
1067 cookie_settings, CONTENT_SETTING_SESSION_ONLY); | 1132 cookie_settings, CONTENT_SETTING_SESSION_ONLY); |
1068 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(host, host)); | 1133 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(host, host)); |
1069 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(host)); | 1134 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(host)); |
1070 } | 1135 } |
1071 | 1136 |
| 1137 TEST_F(CookiesTreeModelTest, AppOriginTitle) { |
| 1138 scoped_ptr<CookiesTreeModel> cookies_model( |
| 1139 CreateCookiesTreeModelWithInitialSample(true)); |
| 1140 |
| 1141 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin1"), |
| 1142 cookies_model->GetRoot()->GetChild(16)->GetTitle()); |
| 1143 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin2"), |
| 1144 cookies_model->GetRoot()->GetChild(17)->GetTitle()); |
| 1145 } |
| 1146 |
1072 TEST_F(CookiesTreeModelTest, FileSystemFilter) { | 1147 TEST_F(CookiesTreeModelTest, FileSystemFilter) { |
1073 scoped_ptr<CookiesTreeModel> cookies_model( | 1148 scoped_ptr<CookiesTreeModel> cookies_model( |
1074 CreateCookiesTreeModelWithInitialSample()); | 1149 CreateCookiesTreeModelWithInitialSample(false)); |
1075 | 1150 |
1076 cookies_model->UpdateSearchResults(std::wstring(L"fshost1")); | 1151 cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost1"))); |
1077 EXPECT_EQ("http://fshost1:1/", | 1152 EXPECT_EQ("http://fshost1:1/", |
1078 GetDisplayedFileSystems(cookies_model.get())); | 1153 GetDisplayedFileSystems(cookies_model.get())); |
1079 | 1154 |
1080 cookies_model->UpdateSearchResults(std::wstring(L"fshost2")); | 1155 cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost2"))); |
1081 EXPECT_EQ("http://fshost2:2/", | 1156 EXPECT_EQ("http://fshost2:2/", |
1082 GetDisplayedFileSystems(cookies_model.get())); | 1157 GetDisplayedFileSystems(cookies_model.get())); |
1083 | 1158 |
1084 cookies_model->UpdateSearchResults(std::wstring(L"fshost3")); | 1159 cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost3"))); |
1085 EXPECT_EQ("http://fshost3:3/", | 1160 EXPECT_EQ("http://fshost3:3/", |
1086 GetDisplayedFileSystems(cookies_model.get())); | 1161 GetDisplayedFileSystems(cookies_model.get())); |
1087 | 1162 |
1088 cookies_model->UpdateSearchResults(std::wstring()); | 1163 cookies_model->UpdateSearchResults(string16()); |
1089 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 1164 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
1090 GetDisplayedFileSystems(cookies_model.get())); | 1165 GetDisplayedFileSystems(cookies_model.get())); |
1091 } | 1166 } |
1092 | 1167 |
| 1168 TEST_F(CookiesTreeModelTest, CookiesFilter) { |
| 1169 ContainerMap container_map; |
| 1170 |
| 1171 container_map[std::string()] = new LocalDataContainer( |
| 1172 "Drive-By-Web", std::string(), |
| 1173 mock_browsing_data_cookie_helper_, |
| 1174 mock_browsing_data_database_helper_, |
| 1175 mock_browsing_data_local_storage_helper_, |
| 1176 mock_browsing_data_session_storage_helper_, |
| 1177 mock_browsing_data_appcache_helper_, |
| 1178 mock_browsing_data_indexed_db_helper_, |
| 1179 mock_browsing_data_file_system_helper_, |
| 1180 mock_browsing_data_quota_helper_, |
| 1181 mock_browsing_data_server_bound_cert_helper_); |
| 1182 CookiesTreeModel cookies_model(container_map, false); |
| 1183 |
| 1184 mock_browsing_data_cookie_helper_-> |
| 1185 AddCookieSamples(GURL("http://123.com"), "A=1"); |
| 1186 mock_browsing_data_cookie_helper_-> |
| 1187 AddCookieSamples(GURL("http://foo1.com"), "B=1"); |
| 1188 mock_browsing_data_cookie_helper_-> |
| 1189 AddCookieSamples(GURL("http://foo2.com"), "C=1"); |
| 1190 mock_browsing_data_cookie_helper_-> |
| 1191 AddCookieSamples(GURL("http://foo3.com"), "D=1"); |
| 1192 mock_browsing_data_cookie_helper_->Notify(); |
| 1193 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); |
| 1194 |
| 1195 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo"))); |
| 1196 EXPECT_EQ("B,C,D", GetDisplayedCookies(&cookies_model)); |
| 1197 |
| 1198 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("2"))); |
| 1199 EXPECT_EQ("A,C", GetDisplayedCookies(&cookies_model)); |
| 1200 |
| 1201 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo3"))); |
| 1202 EXPECT_EQ("D", GetDisplayedCookies(&cookies_model)); |
| 1203 |
| 1204 cookies_model.UpdateSearchResults(string16()); |
| 1205 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); |
| 1206 } |
| 1207 |
1093 } // namespace | 1208 } // namespace |
OLD | NEW |