| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 10 #include "chrome/browser/content_settings/mock_settings_observer.h" | 10 #include "chrome/browser/content_settings/mock_settings_observer.h" |
| 11 #include "chrome/browser/mock_browsing_data_appcache_helper.h" | 11 #include "chrome/browser/mock_browsing_data_appcache_helper.h" |
| 12 #include "chrome/browser/mock_browsing_data_database_helper.h" | 12 #include "chrome/browser/mock_browsing_data_database_helper.h" |
| 13 #include "chrome/browser/mock_browsing_data_file_system_helper.h" | 13 #include "chrome/browser/mock_browsing_data_file_system_helper.h" |
| 14 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" | 14 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" |
| 15 #include "chrome/browser/mock_browsing_data_quota_helper.h" |
| 15 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" | 16 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
| 17 #include "content/common/content_notification_types.h" | 18 #include "content/common/content_notification_types.h" |
| 18 #include "content/common/notification_details.h" | 19 #include "content/common/notification_details.h" |
| 19 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 23 |
| 23 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
| 24 | 25 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 43 mock_browsing_data_local_storage_helper_ = | 44 mock_browsing_data_local_storage_helper_ = |
| 44 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 45 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
| 45 mock_browsing_data_session_storage_helper_ = | 46 mock_browsing_data_session_storage_helper_ = |
| 46 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 47 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
| 47 mock_browsing_data_appcache_helper_ = | 48 mock_browsing_data_appcache_helper_ = |
| 48 new MockBrowsingDataAppCacheHelper(profile_.get()); | 49 new MockBrowsingDataAppCacheHelper(profile_.get()); |
| 49 mock_browsing_data_indexed_db_helper_ = | 50 mock_browsing_data_indexed_db_helper_ = |
| 50 new MockBrowsingDataIndexedDBHelper(profile_.get()); | 51 new MockBrowsingDataIndexedDBHelper(profile_.get()); |
| 51 mock_browsing_data_file_system_helper_ = | 52 mock_browsing_data_file_system_helper_ = |
| 52 new MockBrowsingDataFileSystemHelper(profile_.get()); | 53 new MockBrowsingDataFileSystemHelper(profile_.get()); |
| 54 mock_browsing_data_quota_helper_ = |
| 55 new MockBrowsingDataQuotaHelper(profile_.get()); |
| 53 } | 56 } |
| 54 | 57 |
| 55 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { | 58 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { |
| 56 net::CookieMonster* monster = profile_->GetCookieMonster(); | 59 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 57 monster->SetCookie(GURL("http://foo1"), "A=1"); | 60 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 58 monster->SetCookie(GURL("http://foo2"), "B=1"); | 61 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 59 monster->SetCookie(GURL("http://foo3"), "C=1"); | 62 monster->SetCookie(GURL("http://foo3"), "C=1"); |
| 60 CookiesTreeModel* cookies_model = new CookiesTreeModel( | 63 CookiesTreeModel* cookies_model = new CookiesTreeModel( |
| 61 monster, mock_browsing_data_database_helper_, | 64 monster, mock_browsing_data_database_helper_, |
| 62 mock_browsing_data_local_storage_helper_, | 65 mock_browsing_data_local_storage_helper_, |
| 63 mock_browsing_data_session_storage_helper_, | 66 mock_browsing_data_session_storage_helper_, |
| 64 mock_browsing_data_appcache_helper_, | 67 mock_browsing_data_appcache_helper_, |
| 65 mock_browsing_data_indexed_db_helper_, | 68 mock_browsing_data_indexed_db_helper_, |
| 66 mock_browsing_data_file_system_helper_, | 69 mock_browsing_data_file_system_helper_, |
| 70 mock_browsing_data_quota_helper_, |
| 67 false); | 71 false); |
| 68 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 72 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 69 mock_browsing_data_database_helper_->Notify(); | 73 mock_browsing_data_database_helper_->Notify(); |
| 70 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 74 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 71 mock_browsing_data_local_storage_helper_->Notify(); | 75 mock_browsing_data_local_storage_helper_->Notify(); |
| 72 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 76 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 73 mock_browsing_data_session_storage_helper_->Notify(); | 77 mock_browsing_data_session_storage_helper_->Notify(); |
| 74 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 78 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 75 mock_browsing_data_indexed_db_helper_->Notify(); | 79 mock_browsing_data_indexed_db_helper_->Notify(); |
| 76 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 80 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 77 mock_browsing_data_file_system_helper_->Notify(); | 81 mock_browsing_data_file_system_helper_->Notify(); |
| 82 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
| 83 mock_browsing_data_quota_helper_->Notify(); |
| 78 { | 84 { |
| 79 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " | 85 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " |
| 80 "2 session storages, 2 indexed DBs, 3 filesystems"); | 86 "2 session storages, 2 indexed DBs, 3 filesystems, " |
| 81 // 41 because there's the root, then foo1 -> cookies -> a, | 87 "2 quotas"); |
| 88 // 45 because there's the root, then foo1 -> cookies -> a, |
| 82 // foo2 -> cookies -> b, foo3 -> cookies -> c, | 89 // foo2 -> cookies -> b, foo3 -> cookies -> c, |
| 83 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 90 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 84 // fshost1 -> filesystem -> http://fshost1:1/, | 91 // fshost1 -> filesystem -> http://fshost1:1/, |
| 85 // fshost2 -> filesystem -> http://fshost2:1/, | 92 // fshost2 -> filesystem -> http://fshost2:1/, |
| 86 // fshost3 -> filesystem -> http://fshost3:1/, | 93 // fshost3 -> filesystem -> http://fshost3:1/, |
| 87 // host1 -> localstorage -> http://host1:1/, | 94 // host1 -> localstorage -> http://host1:1/, |
| 88 // host2 -> localstorage -> http://host2:2/. | 95 // host2 -> localstorage -> http://host2:2/. |
| 89 // host1 -> sessionstorage -> http://host1:1/, | 96 // host1 -> sessionstorage -> http://host1:1/, |
| 90 // host2 -> sessionstorage -> http://host2:2/, | 97 // host2 -> sessionstorage -> http://host2:2/, |
| 91 // idbhost1 -> indexeddb -> http://idbhost1:1/, | 98 // idbhost1 -> indexeddb -> http://idbhost1:1/, |
| 92 // idbhost2 -> indexeddb -> http://idbhost2:2/. | 99 // idbhost2 -> indexeddb -> http://idbhost2:2/, |
| 93 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); | 100 // quotahost1 -> quotahost1, |
| 101 // quotahost2 -> quotahost2. |
| 102 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 94 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); | 103 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); |
| 95 EXPECT_EQ("http://host1:1/,http://host2:2/", | 104 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 96 GetDisplayedLocalStorages(cookies_model)); | 105 GetDisplayedLocalStorages(cookies_model)); |
| 97 EXPECT_EQ("http://host1:1/,http://host2:2/", | 106 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 98 GetDisplayedSessionStorages(cookies_model)); | 107 GetDisplayedSessionStorages(cookies_model)); |
| 99 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 108 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 100 GetDisplayedIndexedDBs(cookies_model)); | 109 GetDisplayedIndexedDBs(cookies_model)); |
| 101 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 110 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 102 GetDisplayedFileSystems(cookies_model)); | 111 GetDisplayedFileSystems(cookies_model)); |
| 112 EXPECT_EQ("quotahost1,quotahost2", |
| 113 GetDisplayedQuotas(cookies_model)); |
| 103 } | 114 } |
| 104 return cookies_model; | 115 return cookies_model; |
| 105 } | 116 } |
| 106 | 117 |
| 107 // Get the cookie names in the cookie list, as a comma seperated string. | 118 // Get the cookie names in the cookie list, as a comma seperated string. |
| 108 // (Note that the CookieMonster cookie list is sorted by domain.) | 119 // (Note that the CookieMonster cookie list is sorted by domain.) |
| 109 // Ex: | 120 // Ex: |
| 110 // monster->SetCookie(GURL("http://b"), "X=1") | 121 // monster->SetCookie(GURL("http://b"), "X=1") |
| 111 // monster->SetCookie(GURL("http://a"), "Y=1") | 122 // monster->SetCookie(GURL("http://a"), "Y=1") |
| 112 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); | 123 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 139 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: | 150 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: |
| 140 return node->GetDetailedInfo().cookie->Name() + ","; | 151 return node->GetDetailedInfo().cookie->Name() + ","; |
| 141 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: | 152 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: |
| 142 return node->GetDetailedInfo().appcache_info->manifest_url.spec() + | 153 return node->GetDetailedInfo().appcache_info->manifest_url.spec() + |
| 143 ","; | 154 ","; |
| 144 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: | 155 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: |
| 145 return node->GetDetailedInfo().indexed_db_info->origin + ","; | 156 return node->GetDetailedInfo().indexed_db_info->origin + ","; |
| 146 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: | 157 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: |
| 147 return node->GetDetailedInfo().file_system_info->origin.spec() + | 158 return node->GetDetailedInfo().file_system_info->origin.spec() + |
| 148 ","; | 159 ","; |
| 160 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: |
| 161 return node->GetDetailedInfo().quota_info->host + ","; |
| 149 default: | 162 default: |
| 150 return ""; | 163 return ""; |
| 151 } | 164 } |
| 152 } else { | 165 } else { |
| 153 return ""; | 166 return ""; |
| 154 } | 167 } |
| 155 } | 168 } |
| 156 } | 169 } |
| 157 | 170 |
| 158 std::string GetCookiesOfChildren(const CookieTreeNode* node) { | 171 std::string GetCookiesOfChildren(const CookieTreeNode* node) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 177 std::string GetIndexedDBsOfChildren(const CookieTreeNode* node) { | 190 std::string GetIndexedDBsOfChildren(const CookieTreeNode* node) { |
| 178 return GetNodesOfChildren( | 191 return GetNodesOfChildren( |
| 179 node, CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); | 192 node, CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); |
| 180 } | 193 } |
| 181 | 194 |
| 182 std::string GetFileSystemsOfChildren(const CookieTreeNode* node) { | 195 std::string GetFileSystemsOfChildren(const CookieTreeNode* node) { |
| 183 return GetNodesOfChildren( | 196 return GetNodesOfChildren( |
| 184 node, CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); | 197 node, CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); |
| 185 } | 198 } |
| 186 | 199 |
| 200 std::string GetFileQuotaOfChildren(const CookieTreeNode* node) { |
| 201 return GetNodesOfChildren( |
| 202 node, CookieTreeNode::DetailedInfo::TYPE_QUOTA); |
| 203 } |
| 204 |
| 187 // Get the nodes names displayed in the view (if we had one) in the order | 205 // Get the nodes names displayed in the view (if we had one) in the order |
| 188 // they are displayed, as a comma seperated string. | 206 // they are displayed, as a comma seperated string. |
| 189 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str()); | 207 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str()); |
| 190 std::string GetDisplayedNodes(CookiesTreeModel* cookies_model, | 208 std::string GetDisplayedNodes(CookiesTreeModel* cookies_model, |
| 191 CookieTreeNode::DetailedInfo::NodeType type) { | 209 CookieTreeNode::DetailedInfo::NodeType type) { |
| 192 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>( | 210 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>( |
| 193 cookies_model->GetRoot()); | 211 cookies_model->GetRoot()); |
| 194 std::string retval = GetNodesOfChildren(root, type); | 212 std::string retval = GetNodesOfChildren(root, type); |
| 195 if (retval.length() && retval[retval.length() - 1] == ',') | 213 if (retval.length() && retval[retval.length() - 1] == ',') |
| 196 retval.erase(retval.length() - 1); | 214 retval.erase(retval.length() - 1); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 225 std::string GetDisplayedIndexedDBs(CookiesTreeModel* cookies_model) { | 243 std::string GetDisplayedIndexedDBs(CookiesTreeModel* cookies_model) { |
| 226 return GetDisplayedNodes(cookies_model, | 244 return GetDisplayedNodes(cookies_model, |
| 227 CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); | 245 CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); |
| 228 } | 246 } |
| 229 | 247 |
| 230 std::string GetDisplayedFileSystems(CookiesTreeModel* cookies_model) { | 248 std::string GetDisplayedFileSystems(CookiesTreeModel* cookies_model) { |
| 231 return GetDisplayedNodes(cookies_model, | 249 return GetDisplayedNodes(cookies_model, |
| 232 CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); | 250 CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); |
| 233 } | 251 } |
| 234 | 252 |
| 253 std::string GetDisplayedQuotas(CookiesTreeModel* cookies_model) { |
| 254 return GetDisplayedNodes(cookies_model, |
| 255 CookieTreeNode::DetailedInfo::TYPE_QUOTA); |
| 256 } |
| 257 |
| 235 // Do not call on the root. | 258 // Do not call on the root. |
| 236 void DeleteStoredObjects(CookieTreeNode* node) { | 259 void DeleteStoredObjects(CookieTreeNode* node) { |
| 237 node->DeleteStoredObjects(); | 260 node->DeleteStoredObjects(); |
| 238 CookieTreeNode* parent_node = node->parent(); | 261 CookieTreeNode* parent_node = node->parent(); |
| 239 DCHECK(parent_node); | 262 DCHECK(parent_node); |
| 240 delete parent_node->GetModel()->Remove(parent_node, node); | 263 delete parent_node->GetModel()->Remove(parent_node, node); |
| 241 } | 264 } |
| 242 | 265 |
| 243 protected: | 266 protected: |
| 244 MessageLoop message_loop_; | 267 MessageLoop message_loop_; |
| 245 BrowserThread ui_thread_; | 268 BrowserThread ui_thread_; |
| 246 BrowserThread io_thread_; | 269 BrowserThread io_thread_; |
| 247 | 270 |
| 248 scoped_ptr<TestingProfile> profile_; | 271 scoped_ptr<TestingProfile> profile_; |
| 249 scoped_refptr<MockBrowsingDataDatabaseHelper> | 272 scoped_refptr<MockBrowsingDataDatabaseHelper> |
| 250 mock_browsing_data_database_helper_; | 273 mock_browsing_data_database_helper_; |
| 251 scoped_refptr<MockBrowsingDataLocalStorageHelper> | 274 scoped_refptr<MockBrowsingDataLocalStorageHelper> |
| 252 mock_browsing_data_local_storage_helper_; | 275 mock_browsing_data_local_storage_helper_; |
| 253 scoped_refptr<MockBrowsingDataLocalStorageHelper> | 276 scoped_refptr<MockBrowsingDataLocalStorageHelper> |
| 254 mock_browsing_data_session_storage_helper_; | 277 mock_browsing_data_session_storage_helper_; |
| 255 scoped_refptr<MockBrowsingDataAppCacheHelper> | 278 scoped_refptr<MockBrowsingDataAppCacheHelper> |
| 256 mock_browsing_data_appcache_helper_; | 279 mock_browsing_data_appcache_helper_; |
| 257 scoped_refptr<MockBrowsingDataIndexedDBHelper> | 280 scoped_refptr<MockBrowsingDataIndexedDBHelper> |
| 258 mock_browsing_data_indexed_db_helper_; | 281 mock_browsing_data_indexed_db_helper_; |
| 259 scoped_refptr<MockBrowsingDataFileSystemHelper> | 282 scoped_refptr<MockBrowsingDataFileSystemHelper> |
| 260 mock_browsing_data_file_system_helper_; | 283 mock_browsing_data_file_system_helper_; |
| 284 scoped_refptr<MockBrowsingDataQuotaHelper> |
| 285 mock_browsing_data_quota_helper_; |
| 261 }; | 286 }; |
| 262 | 287 |
| 263 TEST_F(CookiesTreeModelTest, RemoveAll) { | 288 TEST_F(CookiesTreeModelTest, RemoveAll) { |
| 264 scoped_ptr<CookiesTreeModel> cookies_model( | 289 scoped_ptr<CookiesTreeModel> cookies_model( |
| 265 CreateCookiesTreeModelWithInitialSample()); | 290 CreateCookiesTreeModelWithInitialSample()); |
| 266 net::CookieMonster* monster = profile_->GetCookieMonster(); | 291 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 267 | 292 |
| 268 // Reset the selection of the first row. | 293 // Reset the selection of the first row. |
| 269 { | 294 { |
| 270 SCOPED_TRACE("Before removing"); | 295 SCOPED_TRACE("Before removing"); |
| 271 EXPECT_EQ(GetMonsterCookies(monster), | 296 EXPECT_EQ(GetMonsterCookies(monster), |
| 272 GetDisplayedCookies(cookies_model.get())); | 297 GetDisplayedCookies(cookies_model.get())); |
| 273 EXPECT_EQ("db1,db2", | 298 EXPECT_EQ("db1,db2", |
| 274 GetDisplayedDatabases(cookies_model.get())); | 299 GetDisplayedDatabases(cookies_model.get())); |
| 275 EXPECT_EQ("http://host1:1/,http://host2:2/", | 300 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 276 GetDisplayedLocalStorages(cookies_model.get())); | 301 GetDisplayedLocalStorages(cookies_model.get())); |
| 277 EXPECT_EQ("http://host1:1/,http://host2:2/", | 302 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 278 GetDisplayedSessionStorages(cookies_model.get())); | 303 GetDisplayedSessionStorages(cookies_model.get())); |
| 279 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 304 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 280 GetDisplayedIndexedDBs(cookies_model.get())); | 305 GetDisplayedIndexedDBs(cookies_model.get())); |
| 281 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 306 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 282 GetDisplayedFileSystems(cookies_model.get())); | 307 GetDisplayedFileSystems(cookies_model.get())); |
| 308 EXPECT_EQ("quotahost1,quotahost2", |
| 309 GetDisplayedQuotas(cookies_model.get())); |
| 283 } | 310 } |
| 284 | 311 |
| 285 mock_browsing_data_database_helper_->Reset(); | 312 mock_browsing_data_database_helper_->Reset(); |
| 286 mock_browsing_data_local_storage_helper_->Reset(); | 313 mock_browsing_data_local_storage_helper_->Reset(); |
| 287 mock_browsing_data_session_storage_helper_->Reset(); | 314 mock_browsing_data_session_storage_helper_->Reset(); |
| 288 mock_browsing_data_indexed_db_helper_->Reset(); | 315 mock_browsing_data_indexed_db_helper_->Reset(); |
| 289 mock_browsing_data_file_system_helper_->Reset(); | 316 mock_browsing_data_file_system_helper_->Reset(); |
| 290 | 317 |
| 291 cookies_model->DeleteAllStoredObjects(); | 318 cookies_model->DeleteAllStoredObjects(); |
| 292 | 319 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 317 // 2. `foo3` | 344 // 2. `foo3` |
| 318 // 3. `fshost1` | 345 // 3. `fshost1` |
| 319 // 4. `fshost2` | 346 // 4. `fshost2` |
| 320 // 5. `fshost3` | 347 // 5. `fshost3` |
| 321 // 6. `gdbhost1` | 348 // 6. `gdbhost1` |
| 322 // 7. `gdbhost2` | 349 // 7. `gdbhost2` |
| 323 // 8. `host1` | 350 // 8. `host1` |
| 324 // 9. `host2` | 351 // 9. `host2` |
| 325 // 10. `idbhost1` | 352 // 10. `idbhost1` |
| 326 // 11. `idbhost2` | 353 // 11. `idbhost2` |
| 354 // 12. `quotahost1` |
| 355 // 13. `quotahost2` |
| 327 // | 356 // |
| 328 // Here, we'll remove them one by one, starting from the end, and | 357 // Here, we'll remove them one by one, starting from the end, and |
| 329 // check that the state makes sense. | 358 // check that the state makes sense. |
| 330 | 359 |
| 360 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(13)); |
| 361 { |
| 362 SCOPED_TRACE("`quotahost2` removed."); |
| 363 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 364 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 365 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 366 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 367 GetDisplayedLocalStorages(cookies_model.get())); |
| 368 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 369 GetDisplayedSessionStorages(cookies_model.get())); |
| 370 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 371 GetDisplayedFileSystems(cookies_model.get())); |
| 372 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 373 GetDisplayedIndexedDBs(cookies_model.get())); |
| 374 EXPECT_EQ("quotahost1", |
| 375 GetDisplayedQuotas(cookies_model.get())); |
| 376 EXPECT_EQ(43, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 377 } |
| 378 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(12)); |
| 379 { |
| 380 SCOPED_TRACE("`quotahost1` removed."); |
| 381 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 382 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 383 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 384 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 385 GetDisplayedLocalStorages(cookies_model.get())); |
| 386 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 387 GetDisplayedSessionStorages(cookies_model.get())); |
| 388 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 389 GetDisplayedFileSystems(cookies_model.get())); |
| 390 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 391 GetDisplayedIndexedDBs(cookies_model.get())); |
| 392 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 393 } |
| 331 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(11)); | 394 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(11)); |
| 332 { | 395 { |
| 333 SCOPED_TRACE("`idbhost2` removed."); | 396 SCOPED_TRACE("`idbhost2` removed."); |
| 334 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); | 397 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 335 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 398 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 336 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 399 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 337 EXPECT_EQ("http://host1:1/,http://host2:2/", | 400 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 338 GetDisplayedLocalStorages(cookies_model.get())); | 401 GetDisplayedLocalStorages(cookies_model.get())); |
| 339 EXPECT_EQ("http://host1:1/,http://host2:2/", | 402 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 340 GetDisplayedSessionStorages(cookies_model.get())); | 403 GetDisplayedSessionStorages(cookies_model.get())); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { | 555 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { |
| 493 scoped_ptr<CookiesTreeModel> cookies_model( | 556 scoped_ptr<CookiesTreeModel> cookies_model( |
| 494 CreateCookiesTreeModelWithInitialSample()); | 557 CreateCookiesTreeModelWithInitialSample()); |
| 495 net::CookieMonster* monster = profile_->GetCookieMonster(); | 558 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 496 | 559 |
| 497 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); | 560 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); |
| 498 { | 561 { |
| 499 SCOPED_TRACE("First origin removed"); | 562 SCOPED_TRACE("First origin removed"); |
| 500 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 563 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); |
| 501 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 564 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 502 // 39 because in this case, the origin remains, although the COOKIES | 565 // 43 because in this case, the origin remains, although the COOKIES |
| 503 // node beneath it has been deleted. So, we have | 566 // node beneath it has been deleted. So, we have |
| 504 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 567 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c |
| 505 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 568 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 506 // fshost1 -> filesystem -> http://fshost1:1/, | 569 // fshost1 -> filesystem -> http://fshost1:1/, |
| 507 // fshost2 -> filesystem -> http://fshost2:1/, | 570 // fshost2 -> filesystem -> http://fshost2:1/, |
| 508 // fshost3 -> filesystem -> http://fshost3:1/, | 571 // fshost3 -> filesystem -> http://fshost3:1/, |
| 509 // host1 -> localstorage -> http://host1:1/, | 572 // host1 -> localstorage -> http://host1:1/, |
| 510 // host2 -> localstorage -> http://host2:2/, | 573 // host2 -> localstorage -> http://host2:2/, |
| 511 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 574 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 512 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 575 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
| 513 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); | 576 // quotahost1 -> quotahost1, |
| 577 // quotahost2 -> quotahost1. |
| 578 EXPECT_EQ(43, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 514 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 579 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 515 EXPECT_EQ("http://host1:1/,http://host2:2/", | 580 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 516 GetDisplayedLocalStorages(cookies_model.get())); | 581 GetDisplayedLocalStorages(cookies_model.get())); |
| 517 EXPECT_EQ("http://host1:1/,http://host2:2/", | 582 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 518 GetDisplayedSessionStorages(cookies_model.get())); | 583 GetDisplayedSessionStorages(cookies_model.get())); |
| 519 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 584 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 520 GetDisplayedIndexedDBs(cookies_model.get())); | 585 GetDisplayedIndexedDBs(cookies_model.get())); |
| 521 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 586 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 522 GetDisplayedFileSystems(cookies_model.get())); | 587 GetDisplayedFileSystems(cookies_model.get())); |
| 588 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 523 } | 589 } |
| 524 | 590 |
| 525 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 591 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
| 526 { | 592 { |
| 527 SCOPED_TRACE("First database removed"); | 593 SCOPED_TRACE("First database removed"); |
| 528 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 594 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); |
| 529 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 595 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 530 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 596 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 531 EXPECT_EQ("http://host1:1/,http://host2:2/", | 597 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 532 GetDisplayedLocalStorages(cookies_model.get())); | 598 GetDisplayedLocalStorages(cookies_model.get())); |
| 533 EXPECT_EQ("http://host1:1/,http://host2:2/", | 599 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 534 GetDisplayedSessionStorages(cookies_model.get())); | 600 GetDisplayedSessionStorages(cookies_model.get())); |
| 535 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 601 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 536 GetDisplayedIndexedDBs(cookies_model.get())); | 602 GetDisplayedIndexedDBs(cookies_model.get())); |
| 537 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 603 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 538 GetDisplayedFileSystems(cookies_model.get())); | 604 GetDisplayedFileSystems(cookies_model.get())); |
| 539 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); | 605 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 606 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 540 } | 607 } |
| 541 | 608 |
| 542 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 609 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
| 543 { | 610 { |
| 544 SCOPED_TRACE("First origin removed"); | 611 SCOPED_TRACE("First origin removed"); |
| 545 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 612 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); |
| 546 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 613 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 547 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 614 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 548 EXPECT_EQ("http://host2:2/", | 615 EXPECT_EQ("http://host2:2/", |
| 549 GetDisplayedLocalStorages(cookies_model.get())); | 616 GetDisplayedLocalStorages(cookies_model.get())); |
| 550 EXPECT_EQ("http://host1:1/,http://host2:2/", | 617 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 551 GetDisplayedSessionStorages(cookies_model.get())); | 618 GetDisplayedSessionStorages(cookies_model.get())); |
| 552 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 619 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 553 GetDisplayedIndexedDBs(cookies_model.get())); | 620 GetDisplayedIndexedDBs(cookies_model.get())); |
| 554 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 621 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 555 GetDisplayedFileSystems(cookies_model.get())); | 622 GetDisplayedFileSystems(cookies_model.get())); |
| 556 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); | 623 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 624 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 557 } | 625 } |
| 558 } | 626 } |
| 559 | 627 |
| 560 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { | 628 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { |
| 561 scoped_ptr<CookiesTreeModel> cookies_model( | 629 scoped_ptr<CookiesTreeModel> cookies_model( |
| 562 CreateCookiesTreeModelWithInitialSample()); | 630 CreateCookiesTreeModelWithInitialSample()); |
| 563 net::CookieMonster* monster = profile_->GetCookieMonster(); | 631 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 564 | 632 |
| 565 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); | 633 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); |
| 566 { | 634 { |
| 567 SCOPED_TRACE("Second origin COOKIES node removed"); | 635 SCOPED_TRACE("Second origin COOKIES node removed"); |
| 568 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 636 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
| 569 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 637 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 570 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 638 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 571 EXPECT_EQ("http://host1:1/,http://host2:2/", | 639 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 572 GetDisplayedLocalStorages(cookies_model.get())); | 640 GetDisplayedLocalStorages(cookies_model.get())); |
| 573 EXPECT_EQ("http://host1:1/,http://host2:2/", | 641 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 574 GetDisplayedSessionStorages(cookies_model.get())); | 642 GetDisplayedSessionStorages(cookies_model.get())); |
| 575 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 643 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 576 GetDisplayedIndexedDBs(cookies_model.get())); | 644 GetDisplayedIndexedDBs(cookies_model.get())); |
| 577 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 645 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 578 GetDisplayedFileSystems(cookies_model.get())); | 646 GetDisplayedFileSystems(cookies_model.get())); |
| 579 // 39 because in this case, the origin remains, although the COOKIES | 647 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 648 // 43 because in this case, the origin remains, although the COOKIES |
| 580 // node beneath it has been deleted. So, we have | 649 // node beneath it has been deleted. So, we have |
| 581 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 650 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c |
| 582 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 651 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 583 // fshost1 -> filesystem -> http://fshost1:1/, | 652 // fshost1 -> filesystem -> http://fshost1:1/, |
| 584 // fshost2 -> filesystem -> http://fshost2:1/, | 653 // fshost2 -> filesystem -> http://fshost2:1/, |
| 585 // fshost3 -> filesystem -> http://fshost3:1/, | 654 // fshost3 -> filesystem -> http://fshost3:1/, |
| 586 // host1 -> localstorage -> http://host1:1/, | 655 // host1 -> localstorage -> http://host1:1/, |
| 587 // host2 -> localstorage -> http://host2:2/, | 656 // host2 -> localstorage -> http://host2:2/, |
| 588 // host1 -> sessionstorage -> http://host1:1/, | 657 // host1 -> sessionstorage -> http://host1:1/, |
| 589 // host2 -> sessionstorage -> http://host2:2/, | 658 // host2 -> sessionstorage -> http://host2:2/, |
| 590 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 659 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 591 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 660 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
| 592 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); | 661 // quotahost1 -> quotahost1, |
| 662 // quotahost2 -> quotahost2. |
| 663 EXPECT_EQ(43, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 593 } | 664 } |
| 594 | 665 |
| 595 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); | 666 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
| 596 { | 667 { |
| 597 SCOPED_TRACE("First database removed"); | 668 SCOPED_TRACE("First database removed"); |
| 598 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 669 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
| 599 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 670 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 600 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 671 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 601 EXPECT_EQ("http://host1:1/,http://host2:2/", | 672 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 602 GetDisplayedLocalStorages(cookies_model.get())); | 673 GetDisplayedLocalStorages(cookies_model.get())); |
| 603 EXPECT_EQ("http://host1:1/,http://host2:2/", | 674 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 604 GetDisplayedSessionStorages(cookies_model.get())); | 675 GetDisplayedSessionStorages(cookies_model.get())); |
| 605 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 676 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 606 GetDisplayedIndexedDBs(cookies_model.get())); | 677 GetDisplayedIndexedDBs(cookies_model.get())); |
| 607 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 678 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 608 GetDisplayedFileSystems(cookies_model.get())); | 679 GetDisplayedFileSystems(cookies_model.get())); |
| 609 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); | 680 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 681 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 610 } | 682 } |
| 611 | 683 |
| 612 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); | 684 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
| 613 { | 685 { |
| 614 SCOPED_TRACE("First origin removed"); | 686 SCOPED_TRACE("First origin removed"); |
| 615 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 687 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
| 616 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 688 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 617 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 689 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 618 EXPECT_EQ("http://host2:2/", | 690 EXPECT_EQ("http://host2:2/", |
| 619 GetDisplayedLocalStorages(cookies_model.get())); | 691 GetDisplayedLocalStorages(cookies_model.get())); |
| 620 EXPECT_EQ("http://host1:1/,http://host2:2/", | 692 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 621 GetDisplayedSessionStorages(cookies_model.get())); | 693 GetDisplayedSessionStorages(cookies_model.get())); |
| 622 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 694 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 623 GetDisplayedIndexedDBs(cookies_model.get())); | 695 GetDisplayedIndexedDBs(cookies_model.get())); |
| 624 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 696 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 625 GetDisplayedFileSystems(cookies_model.get())); | 697 GetDisplayedFileSystems(cookies_model.get())); |
| 626 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); | 698 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); |
| 699 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 627 } | 700 } |
| 628 } | 701 } |
| 629 | 702 |
| 630 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { | 703 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { |
| 631 net::CookieMonster* monster = profile_->GetCookieMonster(); | 704 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 632 monster->SetCookie(GURL("http://foo1"), "A=1"); | 705 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 633 monster->SetCookie(GURL("http://foo2"), "B=1"); | 706 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 634 monster->SetCookie(GURL("http://foo3"), "C=1"); | 707 monster->SetCookie(GURL("http://foo3"), "C=1"); |
| 635 monster->SetCookie(GURL("http://foo3"), "D=1"); | 708 monster->SetCookie(GURL("http://foo3"), "D=1"); |
| 636 CookiesTreeModel cookies_model(monster, | 709 CookiesTreeModel cookies_model(monster, |
| 637 mock_browsing_data_database_helper_, | 710 mock_browsing_data_database_helper_, |
| 638 mock_browsing_data_local_storage_helper_, | 711 mock_browsing_data_local_storage_helper_, |
| 639 mock_browsing_data_session_storage_helper_, | 712 mock_browsing_data_session_storage_helper_, |
| 640 mock_browsing_data_appcache_helper_, | 713 mock_browsing_data_appcache_helper_, |
| 641 mock_browsing_data_indexed_db_helper_, | 714 mock_browsing_data_indexed_db_helper_, |
| 642 mock_browsing_data_file_system_helper_, | 715 mock_browsing_data_file_system_helper_, |
| 716 mock_browsing_data_quota_helper_, |
| 643 false); | 717 false); |
| 644 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 718 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 645 mock_browsing_data_database_helper_->Notify(); | 719 mock_browsing_data_database_helper_->Notify(); |
| 646 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 720 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 647 mock_browsing_data_local_storage_helper_->Notify(); | 721 mock_browsing_data_local_storage_helper_->Notify(); |
| 648 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 722 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 649 mock_browsing_data_session_storage_helper_->Notify(); | 723 mock_browsing_data_session_storage_helper_->Notify(); |
| 650 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 724 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 651 mock_browsing_data_indexed_db_helper_->Notify(); | 725 mock_browsing_data_indexed_db_helper_->Notify(); |
| 652 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 726 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 653 mock_browsing_data_file_system_helper_->Notify(); | 727 mock_browsing_data_file_system_helper_->Notify(); |
| 728 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
| 729 mock_browsing_data_quota_helper_->Notify(); |
| 654 | 730 |
| 655 { | 731 { |
| 656 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " | 732 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " |
| 657 "2 session storages, 2 indexed DBs, 3 file systems"); | 733 "2 session storages, 2 indexed DBs, 3 file systems, " |
| 734 "2 quotas."); |
| 658 // 42 because there's the root, then foo1 -> cookies -> a, | 735 // 42 because there's the root, then foo1 -> cookies -> a, |
| 659 // foo2 -> cookies -> b, foo3 -> cookies -> c,d | 736 // foo2 -> cookies -> b, foo3 -> cookies -> c,d |
| 660 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 737 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 661 // fshost1 -> filesystem -> http://fshost1:1/, | 738 // fshost1 -> filesystem -> http://fshost1:1/, |
| 662 // fshost2 -> filesystem -> http://fshost2:1/, | 739 // fshost2 -> filesystem -> http://fshost2:1/, |
| 663 // fshost3 -> filesystem -> http://fshost3:1/, | 740 // fshost3 -> filesystem -> http://fshost3:1/, |
| 664 // host1 -> localstorage -> http://host1:1/, | 741 // host1 -> localstorage -> http://host1:1/, |
| 665 // host1 -> sessionstorage -> http://host1:1/, | 742 // host1 -> sessionstorage -> http://host1:1/, |
| 666 // host2 -> sessionstorage -> http://host2:2/, | 743 // host2 -> sessionstorage -> http://host2:2/, |
| 667 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 744 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 668 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 745 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
| 669 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); | 746 // quotahost1 -> quotahost1, |
| 747 // quotahost2 -> quotahost2. |
| 748 EXPECT_EQ(46, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 670 EXPECT_STREQ("A,B,C,D", GetMonsterCookies(monster).c_str()); | 749 EXPECT_STREQ("A,B,C,D", GetMonsterCookies(monster).c_str()); |
| 671 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); | 750 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); |
| 672 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 751 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 673 EXPECT_EQ("http://host1:1/,http://host2:2/", | 752 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 674 GetDisplayedLocalStorages(&cookies_model)); | 753 GetDisplayedLocalStorages(&cookies_model)); |
| 675 EXPECT_EQ("http://host1:1/,http://host2:2/", | 754 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 676 GetDisplayedSessionStorages(&cookies_model)); | 755 GetDisplayedSessionStorages(&cookies_model)); |
| 677 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 756 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 678 GetDisplayedIndexedDBs(&cookies_model)); | 757 GetDisplayedIndexedDBs(&cookies_model)); |
| 679 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 758 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 680 GetDisplayedFileSystems(&cookies_model)); | 759 GetDisplayedFileSystems(&cookies_model)); |
| 760 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
| 681 } | 761 } |
| 682 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); | 762 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); |
| 683 { | 763 { |
| 684 SCOPED_TRACE("Third origin removed"); | 764 SCOPED_TRACE("Third origin removed"); |
| 685 EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); | 765 EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); |
| 686 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); | 766 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); |
| 687 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 767 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 688 EXPECT_EQ("http://host1:1/,http://host2:2/", | 768 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 689 GetDisplayedLocalStorages(&cookies_model)); | 769 GetDisplayedLocalStorages(&cookies_model)); |
| 690 EXPECT_EQ("http://host1:1/,http://host2:2/", | 770 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 691 GetDisplayedSessionStorages(&cookies_model)); | 771 GetDisplayedSessionStorages(&cookies_model)); |
| 692 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 772 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 693 GetDisplayedIndexedDBs(&cookies_model)); | 773 GetDisplayedIndexedDBs(&cookies_model)); |
| 694 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 774 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 695 GetDisplayedFileSystems(&cookies_model)); | 775 GetDisplayedFileSystems(&cookies_model)); |
| 696 EXPECT_EQ(38, cookies_model.GetRoot()->GetTotalNodeCount()); | 776 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
| 777 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 697 } | 778 } |
| 698 } | 779 } |
| 699 | 780 |
| 700 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { | 781 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { |
| 701 net::CookieMonster* monster = profile_->GetCookieMonster(); | 782 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 702 monster->SetCookie(GURL("http://foo1"), "A=1"); | 783 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 703 monster->SetCookie(GURL("http://foo2"), "B=1"); | 784 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 704 monster->SetCookie(GURL("http://foo3"), "C=1"); | 785 monster->SetCookie(GURL("http://foo3"), "C=1"); |
| 705 monster->SetCookie(GURL("http://foo3"), "D=1"); | 786 monster->SetCookie(GURL("http://foo3"), "D=1"); |
| 706 monster->SetCookie(GURL("http://foo3"), "E=1"); | 787 monster->SetCookie(GURL("http://foo3"), "E=1"); |
| 707 CookiesTreeModel cookies_model(monster, | 788 CookiesTreeModel cookies_model(monster, |
| 708 mock_browsing_data_database_helper_, | 789 mock_browsing_data_database_helper_, |
| 709 mock_browsing_data_local_storage_helper_, | 790 mock_browsing_data_local_storage_helper_, |
| 710 mock_browsing_data_session_storage_helper_, | 791 mock_browsing_data_session_storage_helper_, |
| 711 mock_browsing_data_appcache_helper_, | 792 mock_browsing_data_appcache_helper_, |
| 712 mock_browsing_data_indexed_db_helper_, | 793 mock_browsing_data_indexed_db_helper_, |
| 713 mock_browsing_data_file_system_helper_, | 794 mock_browsing_data_file_system_helper_, |
| 795 mock_browsing_data_quota_helper_, |
| 714 false); | 796 false); |
| 715 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 797 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 716 mock_browsing_data_database_helper_->Notify(); | 798 mock_browsing_data_database_helper_->Notify(); |
| 717 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 799 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 718 mock_browsing_data_local_storage_helper_->Notify(); | 800 mock_browsing_data_local_storage_helper_->Notify(); |
| 719 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 801 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 720 mock_browsing_data_session_storage_helper_->Notify(); | 802 mock_browsing_data_session_storage_helper_->Notify(); |
| 721 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 803 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 722 mock_browsing_data_indexed_db_helper_->Notify(); | 804 mock_browsing_data_indexed_db_helper_->Notify(); |
| 723 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); | 805 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 724 mock_browsing_data_file_system_helper_->Notify(); | 806 mock_browsing_data_file_system_helper_->Notify(); |
| 807 mock_browsing_data_quota_helper_->AddQuotaSamples(); |
| 808 mock_browsing_data_quota_helper_->Notify(); |
| 725 | 809 |
| 726 { | 810 { |
| 727 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " | 811 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " |
| 728 "2 session storages, 2 indexed DBs"); | 812 "2 session storages, 2 indexed DBs, 3 filesystems, " |
| 813 "2 quotas."); |
| 729 // 43 because there's the root, then foo1 -> cookies -> a, | 814 // 43 because there's the root, then foo1 -> cookies -> a, |
| 730 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 815 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
| 731 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 816 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 732 // fshost1 -> filesystem -> http://fshost1:1/, | 817 // fshost1 -> filesystem -> http://fshost1:1/, |
| 733 // fshost2 -> filesystem -> http://fshost2:1/, | 818 // fshost2 -> filesystem -> http://fshost2:1/, |
| 734 // fshost3 -> filesystem -> http://fshost3:1/, | 819 // fshost3 -> filesystem -> http://fshost3:1/, |
| 735 // host1 -> localstorage -> http://host1:1/, | 820 // host1 -> localstorage -> http://host1:1/, |
| 736 // host2 -> localstorage -> http://host2:2/, | 821 // host2 -> localstorage -> http://host2:2/, |
| 737 // host1 -> sessionstorage -> http://host1:1/, | 822 // host1 -> sessionstorage -> http://host1:1/, |
| 738 // host2 -> sessionstorage -> http://host2:2/, | 823 // host2 -> sessionstorage -> http://host2:2/, |
| 739 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 824 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 740 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 825 // idbhost2 -> sessionstorage -> http://idbhost2:2/, |
| 741 EXPECT_EQ(43, cookies_model.GetRoot()->GetTotalNodeCount()); | 826 // quotahost1 -> quotahost1, |
| 827 // quotahost2 -> quotahost2. |
| 828 EXPECT_EQ(47, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 742 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); | 829 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); |
| 743 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 830 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 744 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 831 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 745 EXPECT_EQ("http://host1:1/,http://host2:2/", | 832 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 746 GetDisplayedLocalStorages(&cookies_model)); | 833 GetDisplayedLocalStorages(&cookies_model)); |
| 747 EXPECT_EQ("http://host1:1/,http://host2:2/", | 834 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 748 GetDisplayedSessionStorages(&cookies_model)); | 835 GetDisplayedSessionStorages(&cookies_model)); |
| 749 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 836 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 750 GetDisplayedIndexedDBs(&cookies_model)); | 837 GetDisplayedIndexedDBs(&cookies_model)); |
| 751 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 838 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 752 GetDisplayedFileSystems(&cookies_model)); | 839 GetDisplayedFileSystems(&cookies_model)); |
| 840 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
| 753 } | 841 } |
| 754 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> | 842 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> |
| 755 GetChild(1)); | 843 GetChild(1)); |
| 756 { | 844 { |
| 757 SCOPED_TRACE("Middle cookie in third origin removed"); | 845 SCOPED_TRACE("Middle cookie in third origin removed"); |
| 758 EXPECT_STREQ("A,B,C,E", GetMonsterCookies(monster).c_str()); | 846 EXPECT_STREQ("A,B,C,E", GetMonsterCookies(monster).c_str()); |
| 759 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); | 847 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 760 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); | 848 EXPECT_EQ(46, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 761 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 849 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 762 EXPECT_EQ("http://host1:1/,http://host2:2/", | 850 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 763 GetDisplayedLocalStorages(&cookies_model)); | 851 GetDisplayedLocalStorages(&cookies_model)); |
| 764 EXPECT_EQ("http://host1:1/,http://host2:2/", | 852 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 765 GetDisplayedSessionStorages(&cookies_model)); | 853 GetDisplayedSessionStorages(&cookies_model)); |
| 766 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 854 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 767 GetDisplayedIndexedDBs(&cookies_model)); | 855 GetDisplayedIndexedDBs(&cookies_model)); |
| 768 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 856 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 769 GetDisplayedFileSystems(&cookies_model)); | 857 GetDisplayedFileSystems(&cookies_model)); |
| 858 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model)); |
| 770 } | 859 } |
| 771 } | 860 } |
| 772 | 861 |
| 773 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { | 862 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { |
| 774 net::CookieMonster* monster = profile_->GetCookieMonster(); | 863 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 775 monster->SetCookie(GURL("http://foo1"), "A=1"); | 864 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 776 monster->SetCookie(GURL("http://foo2"), "B=1"); | 865 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 777 monster->SetCookie(GURL("http://foo3"), "C=1"); | 866 monster->SetCookie(GURL("http://foo3"), "C=1"); |
| 778 monster->SetCookie(GURL("http://foo3"), "D=1"); | 867 monster->SetCookie(GURL("http://foo3"), "D=1"); |
| 779 monster->SetCookie(GURL("http://foo3"), "E=1"); | 868 monster->SetCookie(GURL("http://foo3"), "E=1"); |
| 780 CookiesTreeModel cookies_model(monster, | 869 CookiesTreeModel cookies_model(monster, |
| 781 mock_browsing_data_database_helper_, | 870 mock_browsing_data_database_helper_, |
| 782 mock_browsing_data_local_storage_helper_, | 871 mock_browsing_data_local_storage_helper_, |
| 783 mock_browsing_data_session_storage_helper_, | 872 mock_browsing_data_session_storage_helper_, |
| 784 mock_browsing_data_appcache_helper_, | 873 mock_browsing_data_appcache_helper_, |
| 785 mock_browsing_data_indexed_db_helper_, | 874 mock_browsing_data_indexed_db_helper_, |
| 786 mock_browsing_data_file_system_helper_, | 875 mock_browsing_data_file_system_helper_, |
| 876 mock_browsing_data_quota_helper_, |
| 787 false); | 877 false); |
| 788 { | 878 { |
| 789 SCOPED_TRACE("Initial State 5 cookies"); | 879 SCOPED_TRACE("Initial State 5 cookies"); |
| 790 // 11 because there's the root, then foo1 -> cookies -> a, | 880 // 11 because there's the root, then foo1 -> cookies -> a, |
| 791 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 881 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
| 792 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); | 882 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 793 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); | 883 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); |
| 794 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 884 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 795 } | 885 } |
| 796 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); | 886 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 815 monster->SetCookie(GURL("http://foo3.com"), "G=1"); | 905 monster->SetCookie(GURL("http://foo3.com"), "G=1"); |
| 816 monster->SetCookie(GURL("http://foo4.com"), "H=1"); | 906 monster->SetCookie(GURL("http://foo4.com"), "H=1"); |
| 817 | 907 |
| 818 CookiesTreeModel cookies_model(monster, | 908 CookiesTreeModel cookies_model(monster, |
| 819 new MockBrowsingDataDatabaseHelper(profile_.get()), | 909 new MockBrowsingDataDatabaseHelper(profile_.get()), |
| 820 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 910 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
| 821 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 911 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
| 822 new MockBrowsingDataAppCacheHelper(profile_.get()), | 912 new MockBrowsingDataAppCacheHelper(profile_.get()), |
| 823 new MockBrowsingDataIndexedDBHelper(profile_.get()), | 913 new MockBrowsingDataIndexedDBHelper(profile_.get()), |
| 824 new MockBrowsingDataFileSystemHelper(profile_.get()), | 914 new MockBrowsingDataFileSystemHelper(profile_.get()), |
| 915 new MockBrowsingDataQuotaHelper(profile_.get()), |
| 825 false); | 916 false); |
| 826 | 917 |
| 827 { | 918 { |
| 828 SCOPED_TRACE("Initial State 8 cookies"); | 919 SCOPED_TRACE("Initial State 8 cookies"); |
| 829 // CookieMonster orders cookies by pathlength, then by creation time. | 920 // CookieMonster orders cookies by pathlength, then by creation time. |
| 830 // All paths are length 1. | 921 // All paths are length 1. |
| 831 EXPECT_STREQ("A,B,C,D,E,F,G,H", GetMonsterCookies(monster).c_str()); | 922 EXPECT_STREQ("A,B,C,D,E,F,G,H", GetMonsterCookies(monster).c_str()); |
| 832 EXPECT_STREQ("F,E,C,B,A,G,D,H", | 923 EXPECT_STREQ("F,E,C,B,A,G,D,H", |
| 833 GetDisplayedCookies(&cookies_model).c_str()); | 924 GetDisplayedCookies(&cookies_model).c_str()); |
| 834 } | 925 } |
| 835 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E" | 926 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E" |
| 836 { | 927 { |
| 837 EXPECT_STREQ("A,B,C,D,F,G,H", GetMonsterCookies(monster).c_str()); | 928 EXPECT_STREQ("A,B,C,D,F,G,H", GetMonsterCookies(monster).c_str()); |
| 838 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); | 929 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); |
| 839 } | 930 } |
| 840 } | 931 } |
| 841 | 932 |
| 842 TEST_F(CookiesTreeModelTest, ContentSettings) { | 933 TEST_F(CookiesTreeModelTest, ContentSettings) { |
| 843 GURL host("http://example.com/"); | 934 GURL host("http://example.com/"); |
| 844 net::CookieMonster* monster = profile_->GetCookieMonster(); | 935 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 845 monster->SetCookie(host, "A=1"); | 936 monster->SetCookie(host, "A=1"); |
| 846 | 937 |
| 847 CookiesTreeModel cookies_model(monster, | 938 CookiesTreeModel cookies_model(monster, |
| 848 new MockBrowsingDataDatabaseHelper(profile_.get()), | 939 new MockBrowsingDataDatabaseHelper(profile_.get()), |
| 849 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 940 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
| 850 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 941 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
| 851 new MockBrowsingDataAppCacheHelper(profile_.get()), | 942 new MockBrowsingDataAppCacheHelper(profile_.get()), |
| 852 new MockBrowsingDataIndexedDBHelper(profile_.get()), | 943 new MockBrowsingDataIndexedDBHelper(profile_.get()), |
| 853 new MockBrowsingDataFileSystemHelper(profile_.get()), | 944 new MockBrowsingDataFileSystemHelper(profile_.get()), |
| 945 new MockBrowsingDataQuotaHelper(profile_.get()), |
| 854 false); | 946 false); |
| 855 | 947 |
| 856 TestingProfile profile; | 948 TestingProfile profile; |
| 857 HostContentSettingsMap* content_settings = | 949 HostContentSettingsMap* content_settings = |
| 858 profile.GetHostContentSettingsMap(); | 950 profile.GetHostContentSettingsMap(); |
| 859 MockSettingsObserver observer; | 951 MockSettingsObserver observer; |
| 860 | 952 |
| 861 CookieTreeRootNode* root = | 953 CookieTreeRootNode* root = |
| 862 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); | 954 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); |
| 863 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); | 955 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 cookies_model->UpdateSearchResults(std::wstring(L"fshost3")); | 992 cookies_model->UpdateSearchResults(std::wstring(L"fshost3")); |
| 901 EXPECT_EQ("http://fshost3:3/", | 993 EXPECT_EQ("http://fshost3:3/", |
| 902 GetDisplayedFileSystems(cookies_model.get())); | 994 GetDisplayedFileSystems(cookies_model.get())); |
| 903 | 995 |
| 904 cookies_model->UpdateSearchResults(std::wstring()); | 996 cookies_model->UpdateSearchResults(std::wstring()); |
| 905 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", | 997 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 906 GetDisplayedFileSystems(cookies_model.get())); | 998 GetDisplayedFileSystems(cookies_model.get())); |
| 907 } | 999 } |
| 908 | 1000 |
| 909 } // namespace | 1001 } // namespace |
| OLD | NEW |