| 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/stub_settings_observer.h" | 10 #include "chrome/browser/content_settings/stub_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_indexed_db_helper.h" | 14 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" |
| 14 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" | 15 #include "chrome/browser/mock_browsing_data_local_storage_helper.h" |
| 15 #include "chrome/test/testing_profile.h" | 16 #include "chrome/test/testing_profile.h" |
| 16 #include "content/common/notification_details.h" | 17 #include "content/common/notification_details.h" |
| 17 #include "content/common/notification_type.h" | 18 #include "content/common/notification_type.h" |
| 18 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 23 #include "base/utf_string_conversions.h" |
| 24 |
| 22 | 25 |
| 23 namespace { | 26 namespace { |
| 24 | 27 |
| 25 class CookiesTreeModelTest : public testing::Test { | 28 class CookiesTreeModelTest : public testing::Test { |
| 26 public: | 29 public: |
| 27 CookiesTreeModelTest() : ui_thread_(BrowserThread::UI, &message_loop_), | 30 CookiesTreeModelTest() : ui_thread_(BrowserThread::UI, &message_loop_), |
| 28 io_thread_(BrowserThread::IO, &message_loop_) { | 31 io_thread_(BrowserThread::IO, &message_loop_) { |
| 29 } | 32 } |
| 30 | 33 |
| 31 virtual ~CookiesTreeModelTest() { | 34 virtual ~CookiesTreeModelTest() { |
| 32 } | 35 } |
| 33 | 36 |
| 34 virtual void SetUp() { | 37 virtual void SetUp() { |
| 35 profile_.reset(new TestingProfile()); | 38 profile_.reset(new TestingProfile()); |
| 36 profile_->CreateRequestContext(); | 39 profile_->CreateRequestContext(); |
| 37 mock_browsing_data_database_helper_ = | 40 mock_browsing_data_database_helper_ = |
| 38 new MockBrowsingDataDatabaseHelper(profile_.get()); | 41 new MockBrowsingDataDatabaseHelper(profile_.get()); |
| 39 mock_browsing_data_local_storage_helper_ = | 42 mock_browsing_data_local_storage_helper_ = |
| 40 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 43 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
| 41 mock_browsing_data_session_storage_helper_ = | 44 mock_browsing_data_session_storage_helper_ = |
| 42 new MockBrowsingDataLocalStorageHelper(profile_.get()); | 45 new MockBrowsingDataLocalStorageHelper(profile_.get()); |
| 43 mock_browsing_data_appcache_helper_ = | 46 mock_browsing_data_appcache_helper_ = |
| 44 new MockBrowsingDataAppCacheHelper(profile_.get()); | 47 new MockBrowsingDataAppCacheHelper(profile_.get()); |
| 45 mock_browsing_data_indexed_db_helper_ = | 48 mock_browsing_data_indexed_db_helper_ = |
| 46 new MockBrowsingDataIndexedDBHelper(profile_.get()); | 49 new MockBrowsingDataIndexedDBHelper(profile_.get()); |
| 50 mock_browsing_data_file_system_helper_ = |
| 51 new MockBrowsingDataFileSystemHelper(profile_.get()); |
| 47 } | 52 } |
| 48 | 53 |
| 49 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { | 54 CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() { |
| 50 net::CookieMonster* monster = profile_->GetCookieMonster(); | 55 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 51 monster->SetCookie(GURL("http://foo1"), "A=1"); | 56 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 52 monster->SetCookie(GURL("http://foo2"), "B=1"); | 57 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 53 monster->SetCookie(GURL("http://foo3"), "C=1"); | 58 monster->SetCookie(GURL("http://foo3"), "C=1"); |
| 54 CookiesTreeModel* cookies_model = new CookiesTreeModel( | 59 CookiesTreeModel* cookies_model = new CookiesTreeModel( |
| 55 monster, mock_browsing_data_database_helper_, | 60 monster, mock_browsing_data_database_helper_, |
| 56 mock_browsing_data_local_storage_helper_, | 61 mock_browsing_data_local_storage_helper_, |
| 57 mock_browsing_data_session_storage_helper_, | 62 mock_browsing_data_session_storage_helper_, |
| 58 mock_browsing_data_appcache_helper_, | 63 mock_browsing_data_appcache_helper_, |
| 59 mock_browsing_data_indexed_db_helper_, | 64 mock_browsing_data_indexed_db_helper_, |
| 65 mock_browsing_data_file_system_helper_, |
| 60 false); | 66 false); |
| 61 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 67 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 62 mock_browsing_data_database_helper_->Notify(); | 68 mock_browsing_data_database_helper_->Notify(); |
| 63 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 69 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 64 mock_browsing_data_local_storage_helper_->Notify(); | 70 mock_browsing_data_local_storage_helper_->Notify(); |
| 65 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 71 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 66 mock_browsing_data_session_storage_helper_->Notify(); | 72 mock_browsing_data_session_storage_helper_->Notify(); |
| 67 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 73 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 68 mock_browsing_data_indexed_db_helper_->Notify(); | 74 mock_browsing_data_indexed_db_helper_->Notify(); |
| 75 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 76 mock_browsing_data_file_system_helper_->Notify(); |
| 69 { | 77 { |
| 70 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " | 78 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " |
| 71 "2 session storages, 2 indexed DBs"); | 79 "2 session storages, 2 indexed DBs, 3 filesystems"); |
| 72 // 32 because there's the root, then foo1 -> cookies -> a, | 80 // 41 because there's the root, then foo1 -> cookies -> a, |
| 73 // foo2 -> cookies -> b, foo3 -> cookies -> c, | 81 // foo2 -> cookies -> b, foo3 -> cookies -> c, |
| 74 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 82 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 83 // fshost1 -> filesystem -> http://fshost1:1/, |
| 84 // fshost2 -> filesystem -> http://fshost2:1/, |
| 85 // fshost3 -> filesystem -> http://fshost3:1/, |
| 75 // host1 -> localstorage -> http://host1:1/, | 86 // host1 -> localstorage -> http://host1:1/, |
| 76 // host2 -> localstorage -> http://host2:2/. | 87 // host2 -> localstorage -> http://host2:2/. |
| 77 // host1 -> sessionstorage -> http://host1:1/, | 88 // host1 -> sessionstorage -> http://host1:1/, |
| 78 // host2 -> sessionstorage -> http://host2:2/, | 89 // host2 -> sessionstorage -> http://host2:2/, |
| 79 // idbhost1 -> indexeddb -> http://idbhost1:1/, | 90 // idbhost1 -> indexeddb -> http://idbhost1:1/, |
| 80 // idbhost2 -> indexeddb -> http://idbhost2:2/. | 91 // idbhost2 -> indexeddb -> http://idbhost2:2/. |
| 81 EXPECT_EQ(32, cookies_model->GetRoot()->GetTotalNodeCount()); | 92 EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 82 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); | 93 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); |
| 83 EXPECT_EQ("http://host1:1/,http://host2:2/", | 94 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 84 GetDisplayedLocalStorages(cookies_model)); | 95 GetDisplayedLocalStorages(cookies_model)); |
| 85 EXPECT_EQ("http://host1:1/,http://host2:2/", | 96 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 86 GetDisplayedSessionStorages(cookies_model)); | 97 GetDisplayedSessionStorages(cookies_model)); |
| 87 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 98 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 88 GetDisplayedIndexedDBs(cookies_model)); | 99 GetDisplayedIndexedDBs(cookies_model)); |
| 100 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 101 GetDisplayedFileSystems(cookies_model)); |
| 89 } | 102 } |
| 90 return cookies_model; | 103 return cookies_model; |
| 91 } | 104 } |
| 92 | 105 |
| 93 // Get the cookie names in the cookie list, as a comma seperated string. | 106 // Get the cookie names in the cookie list, as a comma seperated string. |
| 94 // (Note that the CookieMonster cookie list is sorted by domain.) | 107 // (Note that the CookieMonster cookie list is sorted by domain.) |
| 95 // Ex: | 108 // Ex: |
| 96 // monster->SetCookie(GURL("http://b"), "X=1") | 109 // monster->SetCookie(GURL("http://b"), "X=1") |
| 97 // monster->SetCookie(GURL("http://a"), "Y=1") | 110 // monster->SetCookie(GURL("http://a"), "Y=1") |
| 98 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); | 111 // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 122 return node->GetDetailedInfo().local_storage_info->origin + ","; | 135 return node->GetDetailedInfo().local_storage_info->origin + ","; |
| 123 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: | 136 case CookieTreeNode::DetailedInfo::TYPE_DATABASE: |
| 124 return node->GetDetailedInfo().database_info->database_name + ","; | 137 return node->GetDetailedInfo().database_info->database_name + ","; |
| 125 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: | 138 case CookieTreeNode::DetailedInfo::TYPE_COOKIE: |
| 126 return node->GetDetailedInfo().cookie->Name() + ","; | 139 return node->GetDetailedInfo().cookie->Name() + ","; |
| 127 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: | 140 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: |
| 128 return node->GetDetailedInfo().appcache_info->manifest_url.spec() + | 141 return node->GetDetailedInfo().appcache_info->manifest_url.spec() + |
| 129 ","; | 142 ","; |
| 130 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: | 143 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: |
| 131 return node->GetDetailedInfo().indexed_db_info->origin + ","; | 144 return node->GetDetailedInfo().indexed_db_info->origin + ","; |
| 145 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: |
| 146 return node->GetDetailedInfo().file_system_info->origin.spec() + |
| 147 ","; |
| 132 default: | 148 default: |
| 133 return ""; | 149 return ""; |
| 134 } | 150 } |
| 135 } else { | 151 } else { |
| 136 return ""; | 152 return ""; |
| 137 } | 153 } |
| 138 } | 154 } |
| 139 } | 155 } |
| 140 | 156 |
| 141 std::string GetCookiesOfChildren(const CookieTreeNode* node) { | 157 std::string GetCookiesOfChildren(const CookieTreeNode* node) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 155 std::string GetSessionStoragesOfChildren(const CookieTreeNode* node) { | 171 std::string GetSessionStoragesOfChildren(const CookieTreeNode* node) { |
| 156 return GetNodesOfChildren( | 172 return GetNodesOfChildren( |
| 157 node, CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE); | 173 node, CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE); |
| 158 } | 174 } |
| 159 | 175 |
| 160 std::string GetIndexedDBsOfChildren(const CookieTreeNode* node) { | 176 std::string GetIndexedDBsOfChildren(const CookieTreeNode* node) { |
| 161 return GetNodesOfChildren( | 177 return GetNodesOfChildren( |
| 162 node, CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); | 178 node, CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); |
| 163 } | 179 } |
| 164 | 180 |
| 181 std::string GetFileSystemsOfChildren(const CookieTreeNode* node) { |
| 182 return GetNodesOfChildren( |
| 183 node, CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); |
| 184 } |
| 185 |
| 165 // Get the nodes names displayed in the view (if we had one) in the order | 186 // Get the nodes names displayed in the view (if we had one) in the order |
| 166 // they are displayed, as a comma seperated string. | 187 // they are displayed, as a comma seperated string. |
| 167 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str()); | 188 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str()); |
| 168 std::string GetDisplayedNodes(CookiesTreeModel* cookies_model, | 189 std::string GetDisplayedNodes(CookiesTreeModel* cookies_model, |
| 169 CookieTreeNode::DetailedInfo::NodeType type) { | 190 CookieTreeNode::DetailedInfo::NodeType type) { |
| 170 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>( | 191 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>( |
| 171 cookies_model->GetRoot()); | 192 cookies_model->GetRoot()); |
| 172 std::string retval = GetNodesOfChildren(root, type); | 193 std::string retval = GetNodesOfChildren(root, type); |
| 173 if (retval.length() && retval[retval.length() - 1] == ',') | 194 if (retval.length() && retval[retval.length() - 1] == ',') |
| 174 retval.erase(retval.length() - 1); | 195 retval.erase(retval.length() - 1); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 198 std::string GetDisplayedAppCaches(CookiesTreeModel* cookies_model) { | 219 std::string GetDisplayedAppCaches(CookiesTreeModel* cookies_model) { |
| 199 return GetDisplayedNodes(cookies_model, | 220 return GetDisplayedNodes(cookies_model, |
| 200 CookieTreeNode::DetailedInfo::TYPE_APPCACHE); | 221 CookieTreeNode::DetailedInfo::TYPE_APPCACHE); |
| 201 } | 222 } |
| 202 | 223 |
| 203 std::string GetDisplayedIndexedDBs(CookiesTreeModel* cookies_model) { | 224 std::string GetDisplayedIndexedDBs(CookiesTreeModel* cookies_model) { |
| 204 return GetDisplayedNodes(cookies_model, | 225 return GetDisplayedNodes(cookies_model, |
| 205 CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); | 226 CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB); |
| 206 } | 227 } |
| 207 | 228 |
| 229 std::string GetDisplayedFileSystems(CookiesTreeModel* cookies_model) { |
| 230 return GetDisplayedNodes(cookies_model, |
| 231 CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); |
| 232 } |
| 233 |
| 208 // Do not call on the root. | 234 // Do not call on the root. |
| 209 void DeleteStoredObjects(CookieTreeNode* node) { | 235 void DeleteStoredObjects(CookieTreeNode* node) { |
| 210 node->DeleteStoredObjects(); | 236 node->DeleteStoredObjects(); |
| 211 CookieTreeNode* parent_node = node->parent(); | 237 CookieTreeNode* parent_node = node->parent(); |
| 212 DCHECK(parent_node); | 238 DCHECK(parent_node); |
| 213 delete parent_node->GetModel()->Remove(parent_node, node); | 239 delete parent_node->GetModel()->Remove(parent_node, node); |
| 214 } | 240 } |
| 215 | 241 |
| 216 protected: | 242 protected: |
| 217 MessageLoop message_loop_; | 243 MessageLoop message_loop_; |
| 218 BrowserThread ui_thread_; | 244 BrowserThread ui_thread_; |
| 219 BrowserThread io_thread_; | 245 BrowserThread io_thread_; |
| 220 | 246 |
| 221 scoped_ptr<TestingProfile> profile_; | 247 scoped_ptr<TestingProfile> profile_; |
| 222 scoped_refptr<MockBrowsingDataDatabaseHelper> | 248 scoped_refptr<MockBrowsingDataDatabaseHelper> |
| 223 mock_browsing_data_database_helper_; | 249 mock_browsing_data_database_helper_; |
| 224 scoped_refptr<MockBrowsingDataLocalStorageHelper> | 250 scoped_refptr<MockBrowsingDataLocalStorageHelper> |
| 225 mock_browsing_data_local_storage_helper_; | 251 mock_browsing_data_local_storage_helper_; |
| 226 scoped_refptr<MockBrowsingDataLocalStorageHelper> | 252 scoped_refptr<MockBrowsingDataLocalStorageHelper> |
| 227 mock_browsing_data_session_storage_helper_; | 253 mock_browsing_data_session_storage_helper_; |
| 228 scoped_refptr<MockBrowsingDataAppCacheHelper> | 254 scoped_refptr<MockBrowsingDataAppCacheHelper> |
| 229 mock_browsing_data_appcache_helper_; | 255 mock_browsing_data_appcache_helper_; |
| 230 scoped_refptr<MockBrowsingDataIndexedDBHelper> | 256 scoped_refptr<MockBrowsingDataIndexedDBHelper> |
| 231 mock_browsing_data_indexed_db_helper_; | 257 mock_browsing_data_indexed_db_helper_; |
| 258 scoped_refptr<MockBrowsingDataFileSystemHelper> |
| 259 mock_browsing_data_file_system_helper_; |
| 232 }; | 260 }; |
| 233 | 261 |
| 234 TEST_F(CookiesTreeModelTest, RemoveAll) { | 262 TEST_F(CookiesTreeModelTest, RemoveAll) { |
| 235 scoped_ptr<CookiesTreeModel> cookies_model( | 263 scoped_ptr<CookiesTreeModel> cookies_model( |
| 236 CreateCookiesTreeModelWithInitialSample()); | 264 CreateCookiesTreeModelWithInitialSample()); |
| 237 net::CookieMonster* monster = profile_->GetCookieMonster(); | 265 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 238 | 266 |
| 239 // Reset the selection of the first row. | 267 // Reset the selection of the first row. |
| 240 { | 268 { |
| 241 SCOPED_TRACE("Before removing"); | 269 SCOPED_TRACE("Before removing"); |
| 242 EXPECT_EQ(GetMonsterCookies(monster), | 270 EXPECT_EQ(GetMonsterCookies(monster), |
| 243 GetDisplayedCookies(cookies_model.get())); | 271 GetDisplayedCookies(cookies_model.get())); |
| 244 EXPECT_EQ("db1,db2", | 272 EXPECT_EQ("db1,db2", |
| 245 GetDisplayedDatabases(cookies_model.get())); | 273 GetDisplayedDatabases(cookies_model.get())); |
| 246 EXPECT_EQ("http://host1:1/,http://host2:2/", | 274 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 247 GetDisplayedLocalStorages(cookies_model.get())); | 275 GetDisplayedLocalStorages(cookies_model.get())); |
| 248 EXPECT_EQ("http://host1:1/,http://host2:2/", | 276 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 249 GetDisplayedSessionStorages(cookies_model.get())); | 277 GetDisplayedSessionStorages(cookies_model.get())); |
| 250 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 278 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 251 GetDisplayedIndexedDBs(cookies_model.get())); | 279 GetDisplayedIndexedDBs(cookies_model.get())); |
| 280 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 281 GetDisplayedFileSystems(cookies_model.get())); |
| 252 } | 282 } |
| 253 | 283 |
| 254 mock_browsing_data_database_helper_->Reset(); | 284 mock_browsing_data_database_helper_->Reset(); |
| 255 mock_browsing_data_local_storage_helper_->Reset(); | 285 mock_browsing_data_local_storage_helper_->Reset(); |
| 256 mock_browsing_data_session_storage_helper_->Reset(); | 286 mock_browsing_data_session_storage_helper_->Reset(); |
| 257 mock_browsing_data_indexed_db_helper_->Reset(); | 287 mock_browsing_data_indexed_db_helper_->Reset(); |
| 288 mock_browsing_data_file_system_helper_->Reset(); |
| 258 | 289 |
| 259 cookies_model->DeleteAllStoredObjects(); | 290 cookies_model->DeleteAllStoredObjects(); |
| 260 | 291 |
| 261 { | 292 { |
| 262 SCOPED_TRACE("After removing"); | 293 SCOPED_TRACE("After removing"); |
| 263 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); | 294 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 264 EXPECT_EQ(0, cookies_model->GetRoot()->child_count()); | 295 EXPECT_EQ(0, cookies_model->GetRoot()->child_count()); |
| 265 EXPECT_EQ(std::string(""), GetMonsterCookies(monster)); | 296 EXPECT_EQ(std::string(""), GetMonsterCookies(monster)); |
| 266 EXPECT_EQ(GetMonsterCookies(monster), | 297 EXPECT_EQ(GetMonsterCookies(monster), |
| 267 GetDisplayedCookies(cookies_model.get())); | 298 GetDisplayedCookies(cookies_model.get())); |
| 268 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); | 299 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); |
| 269 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); | 300 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); |
| 270 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted()); | 301 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted()); |
| 271 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted()); | 302 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted()); |
| 303 EXPECT_TRUE(mock_browsing_data_file_system_helper_->AllDeleted()); |
| 272 } | 304 } |
| 273 } | 305 } |
| 274 | 306 |
| 275 TEST_F(CookiesTreeModelTest, Remove) { | 307 TEST_F(CookiesTreeModelTest, Remove) { |
| 276 scoped_ptr<CookiesTreeModel> cookies_model( | 308 scoped_ptr<CookiesTreeModel> cookies_model( |
| 277 CreateCookiesTreeModelWithInitialSample()); | 309 CreateCookiesTreeModelWithInitialSample()); |
| 278 net::CookieMonster* monster = profile_->GetCookieMonster(); | 310 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 279 | 311 |
| 280 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)); | 312 // Children start out arranged as follows: |
| 313 // |
| 314 // 0. `foo1` |
| 315 // 1. `foo2` |
| 316 // 2. `foo3` |
| 317 // 3. `fshost1` |
| 318 // 4. `fshost2` |
| 319 // 5. `fshost3` |
| 320 // 6. `gdbhost1` |
| 321 // 7. `gdbhost2` |
| 322 // 8. `host1` |
| 323 // 9. `host2` |
| 324 // 10. `idbhost1` |
| 325 // 11. `idbhost2` |
| 326 // |
| 327 // Here, we'll remove them one by one, starting from the end, and |
| 328 // check that the state makes sense. |
| 329 |
| 330 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(11)); |
| 281 { | 331 { |
| 282 SCOPED_TRACE("First cookie origin removed"); | 332 SCOPED_TRACE("`idbhost2` removed."); |
| 283 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 333 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 284 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 334 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 285 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 335 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 286 EXPECT_EQ("http://host1:1/,http://host2:2/", | 336 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 287 GetDisplayedLocalStorages(cookies_model.get())); | 337 GetDisplayedLocalStorages(cookies_model.get())); |
| 288 EXPECT_EQ("http://host1:1/,http://host2:2/", | 338 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 289 GetDisplayedSessionStorages(cookies_model.get())); | 339 GetDisplayedSessionStorages(cookies_model.get())); |
| 290 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 340 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 341 GetDisplayedFileSystems(cookies_model.get())); |
| 342 EXPECT_EQ("http://idbhost1:1/", |
| 291 GetDisplayedIndexedDBs(cookies_model.get())); | 343 GetDisplayedIndexedDBs(cookies_model.get())); |
| 292 EXPECT_EQ(29, cookies_model->GetRoot()->GetTotalNodeCount()); | 344 EXPECT_EQ(38, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 293 } | 345 } |
| 294 | 346 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(10)); |
| 295 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(2)); | |
| 296 { | 347 { |
| 297 SCOPED_TRACE("First database origin removed"); | 348 SCOPED_TRACE("`idbhost1` removed."); |
| 298 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 349 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 299 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 350 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 300 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 351 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 301 EXPECT_EQ("http://host1:1/,http://host2:2/", | 352 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 302 GetDisplayedLocalStorages(cookies_model.get())); | 353 GetDisplayedLocalStorages(cookies_model.get())); |
| 303 EXPECT_EQ("http://host1:1/,http://host2:2/", | 354 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 304 GetDisplayedSessionStorages(cookies_model.get())); | 355 GetDisplayedSessionStorages(cookies_model.get())); |
| 305 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 356 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 306 GetDisplayedIndexedDBs(cookies_model.get())); | 357 GetDisplayedFileSystems(cookies_model.get())); |
| 307 EXPECT_EQ(26, cookies_model->GetRoot()->GetTotalNodeCount()); | 358 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 359 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 308 } | 360 } |
| 309 | 361 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(9)); |
| 362 { |
| 363 SCOPED_TRACE("`host2` removed."); |
| 364 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 365 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 366 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 367 EXPECT_EQ("http://host1:1/", |
| 368 GetDisplayedLocalStorages(cookies_model.get())); |
| 369 EXPECT_EQ("http://host1:1/", |
| 370 GetDisplayedSessionStorages(cookies_model.get())); |
| 371 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 372 GetDisplayedFileSystems(cookies_model.get())); |
| 373 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 374 EXPECT_EQ(30, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 375 } |
| 376 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)); |
| 377 { |
| 378 SCOPED_TRACE("`host1` removed."); |
| 379 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 380 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 381 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 382 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 383 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 384 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 385 GetDisplayedFileSystems(cookies_model.get())); |
| 386 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 387 EXPECT_EQ(25, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 388 } |
| 389 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(7)); |
| 390 { |
| 391 SCOPED_TRACE("`gdbhost2` removed."); |
| 392 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 393 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 394 EXPECT_EQ("db1", GetDisplayedDatabases(cookies_model.get())); |
| 395 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 396 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 397 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 398 GetDisplayedFileSystems(cookies_model.get())); |
| 399 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 400 EXPECT_EQ(22, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 401 } |
| 402 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)); |
| 403 { |
| 404 SCOPED_TRACE("`gdbhost1` removed."); |
| 405 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 406 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 407 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 408 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 409 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 410 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 411 GetDisplayedFileSystems(cookies_model.get())); |
| 412 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 413 EXPECT_EQ(19, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 414 } |
| 415 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(5)); |
| 416 { |
| 417 SCOPED_TRACE("`fshost3` removed."); |
| 418 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 419 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 420 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 421 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 422 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 423 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/", |
| 424 GetDisplayedFileSystems(cookies_model.get())); |
| 425 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 426 EXPECT_EQ(16, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 427 } |
| 428 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(4)); |
| 429 { |
| 430 SCOPED_TRACE("`fshost2` removed."); |
| 431 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 432 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 433 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 434 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 435 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 436 EXPECT_EQ("http://fshost1:1/", |
| 437 GetDisplayedFileSystems(cookies_model.get())); |
| 438 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 439 EXPECT_EQ(13, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 440 } |
| 310 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(3)); | 441 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(3)); |
| 311 { | 442 { |
| 312 SCOPED_TRACE("First local storage origin removed"); | 443 SCOPED_TRACE("`fshost1` removed."); |
| 313 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 444 EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str()); |
| 314 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 445 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 315 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 446 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 316 EXPECT_EQ("http://host2:2/", | 447 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 317 GetDisplayedLocalStorages(cookies_model.get())); | 448 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 318 EXPECT_EQ("http://host2:2/", | 449 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 319 GetDisplayedSessionStorages(cookies_model.get())); | 450 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 320 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 451 EXPECT_EQ(10, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 321 GetDisplayedIndexedDBs(cookies_model.get())); | |
| 322 EXPECT_EQ(21, cookies_model->GetRoot()->GetTotalNodeCount()); | |
| 323 } | 452 } |
| 324 | 453 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(2)); |
| 325 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(4)); | |
| 326 { | 454 { |
| 327 SCOPED_TRACE("First IndexedDB origin removed"); | 455 SCOPED_TRACE("`foo3` removed."); |
| 328 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 456 EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); |
| 329 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 457 EXPECT_STREQ("A,B", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 330 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 458 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 331 EXPECT_EQ("http://host2:2/", | 459 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 332 GetDisplayedLocalStorages(cookies_model.get())); | 460 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 333 EXPECT_EQ("http://host2:2/", | 461 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 334 GetDisplayedSessionStorages(cookies_model.get())); | 462 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 335 EXPECT_EQ("http://idbhost2:2/", | 463 EXPECT_EQ(7, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 336 GetDisplayedIndexedDBs(cookies_model.get())); | 464 } |
| 337 EXPECT_EQ(18, cookies_model->GetRoot()->GetTotalNodeCount()); | 465 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)); |
| 466 { |
| 467 SCOPED_TRACE("`foo2` removed."); |
| 468 EXPECT_STREQ("A", GetMonsterCookies(monster).c_str()); |
| 469 EXPECT_STREQ("A", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 470 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 471 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 472 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 473 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 474 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 475 EXPECT_EQ(4, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 476 } |
| 477 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)); |
| 478 { |
| 479 SCOPED_TRACE("`foo1` removed."); |
| 480 EXPECT_STREQ("", GetMonsterCookies(monster).c_str()); |
| 481 EXPECT_STREQ("", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 482 EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get())); |
| 483 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get())); |
| 484 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model.get())); |
| 485 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model.get())); |
| 486 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model.get())); |
| 487 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 338 } | 488 } |
| 339 } | 489 } |
| 340 | 490 |
| 341 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { | 491 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { |
| 342 scoped_ptr<CookiesTreeModel> cookies_model( | 492 scoped_ptr<CookiesTreeModel> cookies_model( |
| 343 CreateCookiesTreeModelWithInitialSample()); | 493 CreateCookiesTreeModelWithInitialSample()); |
| 344 net::CookieMonster* monster = profile_->GetCookieMonster(); | 494 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 345 | 495 |
| 346 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); | 496 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0)); |
| 347 { | 497 { |
| 348 SCOPED_TRACE("First origin removed"); | 498 SCOPED_TRACE("First origin removed"); |
| 349 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 499 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); |
| 350 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 500 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 351 // 28 because in this case, the origin remains, although the COOKIES | 501 // 39 because in this case, the origin remains, although the COOKIES |
| 352 // node beneath it has been deleted. So, we have | 502 // node beneath it has been deleted. So, we have |
| 353 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 503 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c |
| 354 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 504 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 505 // fshost1 -> filesystem -> http://fshost1:1/, |
| 506 // fshost2 -> filesystem -> http://fshost2:1/, |
| 507 // fshost3 -> filesystem -> http://fshost3:1/, |
| 355 // host1 -> localstorage -> http://host1:1/, | 508 // host1 -> localstorage -> http://host1:1/, |
| 356 // host2 -> localstorage -> http://host2:2/, | 509 // host2 -> localstorage -> http://host2:2/, |
| 357 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 510 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 358 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 511 // idbhost2 -> sessionstorage -> http://idbhost2:2/. |
| 359 EXPECT_EQ(30, cookies_model->GetRoot()->GetTotalNodeCount()); | 512 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 360 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 513 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 361 EXPECT_EQ("http://host1:1/,http://host2:2/", | 514 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 362 GetDisplayedLocalStorages(cookies_model.get())); | 515 GetDisplayedLocalStorages(cookies_model.get())); |
| 363 EXPECT_EQ("http://host1:1/,http://host2:2/", | 516 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 364 GetDisplayedSessionStorages(cookies_model.get())); | 517 GetDisplayedSessionStorages(cookies_model.get())); |
| 365 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 518 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 366 GetDisplayedIndexedDBs(cookies_model.get())); | 519 GetDisplayedIndexedDBs(cookies_model.get())); |
| 520 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 521 GetDisplayedFileSystems(cookies_model.get())); |
| 367 } | 522 } |
| 368 | 523 |
| 369 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(3)->GetChild(0)); | 524 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
| 370 { | 525 { |
| 371 SCOPED_TRACE("First database removed"); | 526 SCOPED_TRACE("First database removed"); |
| 372 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 527 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); |
| 373 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 528 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 374 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 529 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 375 EXPECT_EQ("http://host1:1/,http://host2:2/", | 530 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 376 GetDisplayedLocalStorages(cookies_model.get())); | 531 GetDisplayedLocalStorages(cookies_model.get())); |
| 377 EXPECT_EQ("http://host1:1/,http://host2:2/", | 532 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 378 GetDisplayedSessionStorages(cookies_model.get())); | 533 GetDisplayedSessionStorages(cookies_model.get())); |
| 379 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 534 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 380 GetDisplayedIndexedDBs(cookies_model.get())); | 535 GetDisplayedIndexedDBs(cookies_model.get())); |
| 381 EXPECT_EQ(28, cookies_model->GetRoot()->GetTotalNodeCount()); | 536 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 537 GetDisplayedFileSystems(cookies_model.get())); |
| 538 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 382 } | 539 } |
| 383 | 540 |
| 384 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(5)->GetChild(0)); | 541 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
| 385 { | 542 { |
| 386 SCOPED_TRACE("First origin removed"); | 543 SCOPED_TRACE("First origin removed"); |
| 387 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); | 544 EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str()); |
| 388 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 545 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 389 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 546 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 390 EXPECT_EQ("http://host2:2/", | 547 EXPECT_EQ("http://host2:2/", |
| 391 GetDisplayedLocalStorages(cookies_model.get())); | 548 GetDisplayedLocalStorages(cookies_model.get())); |
| 392 EXPECT_EQ("http://host1:1/,http://host2:2/", | 549 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 393 GetDisplayedSessionStorages(cookies_model.get())); | 550 GetDisplayedSessionStorages(cookies_model.get())); |
| 394 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 551 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 395 GetDisplayedIndexedDBs(cookies_model.get())); | 552 GetDisplayedIndexedDBs(cookies_model.get())); |
| 396 EXPECT_EQ(26, cookies_model->GetRoot()->GetTotalNodeCount()); | 553 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 554 GetDisplayedFileSystems(cookies_model.get())); |
| 555 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 397 } | 556 } |
| 398 } | 557 } |
| 399 | 558 |
| 400 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { | 559 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { |
| 401 scoped_ptr<CookiesTreeModel> cookies_model( | 560 scoped_ptr<CookiesTreeModel> cookies_model( |
| 402 CreateCookiesTreeModelWithInitialSample()); | 561 CreateCookiesTreeModelWithInitialSample()); |
| 403 net::CookieMonster* monster = profile_->GetCookieMonster(); | 562 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 404 | 563 |
| 405 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); | 564 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0)); |
| 406 { | 565 { |
| 407 SCOPED_TRACE("Second origin COOKIES node removed"); | 566 SCOPED_TRACE("Second origin COOKIES node removed"); |
| 408 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 567 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
| 409 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 568 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 410 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); | 569 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); |
| 411 EXPECT_EQ("http://host1:1/,http://host2:2/", | 570 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 412 GetDisplayedLocalStorages(cookies_model.get())); | 571 GetDisplayedLocalStorages(cookies_model.get())); |
| 413 EXPECT_EQ("http://host1:1/,http://host2:2/", | 572 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 414 GetDisplayedSessionStorages(cookies_model.get())); | 573 GetDisplayedSessionStorages(cookies_model.get())); |
| 415 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 574 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 416 GetDisplayedIndexedDBs(cookies_model.get())); | 575 GetDisplayedIndexedDBs(cookies_model.get())); |
| 417 // 28 because in this case, the origin remains, although the COOKIES | 576 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 577 GetDisplayedFileSystems(cookies_model.get())); |
| 578 // 39 because in this case, the origin remains, although the COOKIES |
| 418 // node beneath it has been deleted. So, we have | 579 // node beneath it has been deleted. So, we have |
| 419 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c | 580 // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c |
| 420 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 581 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 582 // fshost1 -> filesystem -> http://fshost1:1/, |
| 583 // fshost2 -> filesystem -> http://fshost2:1/, |
| 584 // fshost3 -> filesystem -> http://fshost3:1/, |
| 421 // host1 -> localstorage -> http://host1:1/, | 585 // host1 -> localstorage -> http://host1:1/, |
| 422 // host2 -> localstorage -> http://host2:2/. | 586 // host2 -> localstorage -> http://host2:2/, |
| 423 // host1 -> sessionstorage -> http://host1:1/, | 587 // host1 -> sessionstorage -> http://host1:1/, |
| 424 // host2 -> sessionstorage -> http://host2:2/, | 588 // host2 -> sessionstorage -> http://host2:2/, |
| 425 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 589 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 426 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 590 // idbhost2 -> sessionstorage -> http://idbhost2:2/. |
| 427 EXPECT_EQ(30, cookies_model->GetRoot()->GetTotalNodeCount()); | 591 EXPECT_EQ(39, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 428 } | 592 } |
| 429 | 593 |
| 430 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(3)->GetChild(0)); | 594 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0)); |
| 431 { | 595 { |
| 432 SCOPED_TRACE("First database removed"); | 596 SCOPED_TRACE("First database removed"); |
| 433 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 597 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
| 434 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 598 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 435 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 599 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 436 EXPECT_EQ("http://host1:1/,http://host2:2/", | 600 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 437 GetDisplayedLocalStorages(cookies_model.get())); | 601 GetDisplayedLocalStorages(cookies_model.get())); |
| 438 EXPECT_EQ("http://host1:1/,http://host2:2/", | 602 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 439 GetDisplayedSessionStorages(cookies_model.get())); | 603 GetDisplayedSessionStorages(cookies_model.get())); |
| 440 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 604 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 441 GetDisplayedIndexedDBs(cookies_model.get())); | 605 GetDisplayedIndexedDBs(cookies_model.get())); |
| 442 EXPECT_EQ(28, cookies_model->GetRoot()->GetTotalNodeCount()); | 606 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 607 GetDisplayedFileSystems(cookies_model.get())); |
| 608 EXPECT_EQ(37, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 443 } | 609 } |
| 444 | 610 |
| 445 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(5)->GetChild(0)); | 611 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0)); |
| 446 { | 612 { |
| 447 SCOPED_TRACE("First origin removed"); | 613 SCOPED_TRACE("First origin removed"); |
| 448 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); | 614 EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str()); |
| 449 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); | 615 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); |
| 450 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); | 616 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); |
| 451 EXPECT_EQ("http://host2:2/", | 617 EXPECT_EQ("http://host2:2/", |
| 452 GetDisplayedLocalStorages(cookies_model.get())); | 618 GetDisplayedLocalStorages(cookies_model.get())); |
| 453 EXPECT_EQ("http://host1:1/,http://host2:2/", | 619 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 454 GetDisplayedSessionStorages(cookies_model.get())); | 620 GetDisplayedSessionStorages(cookies_model.get())); |
| 455 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 621 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 456 GetDisplayedIndexedDBs(cookies_model.get())); | 622 GetDisplayedIndexedDBs(cookies_model.get())); |
| 457 EXPECT_EQ(26, cookies_model->GetRoot()->GetTotalNodeCount()); | 623 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 624 GetDisplayedFileSystems(cookies_model.get())); |
| 625 EXPECT_EQ(35, cookies_model->GetRoot()->GetTotalNodeCount()); |
| 458 } | 626 } |
| 459 } | 627 } |
| 460 | 628 |
| 461 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { | 629 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { |
| 462 net::CookieMonster* monster = profile_->GetCookieMonster(); | 630 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 463 monster->SetCookie(GURL("http://foo1"), "A=1"); | 631 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 464 monster->SetCookie(GURL("http://foo2"), "B=1"); | 632 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 465 monster->SetCookie(GURL("http://foo3"), "C=1"); | 633 monster->SetCookie(GURL("http://foo3"), "C=1"); |
| 466 monster->SetCookie(GURL("http://foo3"), "D=1"); | 634 monster->SetCookie(GURL("http://foo3"), "D=1"); |
| 467 CookiesTreeModel cookies_model(monster, | 635 CookiesTreeModel cookies_model(monster, |
| 468 mock_browsing_data_database_helper_, | 636 mock_browsing_data_database_helper_, |
| 469 mock_browsing_data_local_storage_helper_, | 637 mock_browsing_data_local_storage_helper_, |
| 470 mock_browsing_data_session_storage_helper_, | 638 mock_browsing_data_session_storage_helper_, |
| 471 mock_browsing_data_appcache_helper_, | 639 mock_browsing_data_appcache_helper_, |
| 472 mock_browsing_data_indexed_db_helper_, | 640 mock_browsing_data_indexed_db_helper_, |
| 641 mock_browsing_data_file_system_helper_, |
| 473 false); | 642 false); |
| 474 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 643 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 475 mock_browsing_data_database_helper_->Notify(); | 644 mock_browsing_data_database_helper_->Notify(); |
| 476 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 645 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 477 mock_browsing_data_local_storage_helper_->Notify(); | 646 mock_browsing_data_local_storage_helper_->Notify(); |
| 478 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 647 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 479 mock_browsing_data_session_storage_helper_->Notify(); | 648 mock_browsing_data_session_storage_helper_->Notify(); |
| 480 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 649 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 481 mock_browsing_data_indexed_db_helper_->Notify(); | 650 mock_browsing_data_indexed_db_helper_->Notify(); |
| 651 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 652 mock_browsing_data_file_system_helper_->Notify(); |
| 482 | 653 |
| 483 { | 654 { |
| 484 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " | 655 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, " |
| 485 "2 session storages, 2 indexed DBs"); | 656 "2 session storages, 2 indexed DBs, 3 file systems"); |
| 486 // 33 because there's the root, then foo1 -> cookies -> a, | 657 // 42 because there's the root, then foo1 -> cookies -> a, |
| 487 // foo2 -> cookies -> b, foo3 -> cookies -> c,d | 658 // foo2 -> cookies -> b, foo3 -> cookies -> c,d |
| 488 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 659 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 660 // fshost1 -> filesystem -> http://fshost1:1/, |
| 661 // fshost2 -> filesystem -> http://fshost2:1/, |
| 662 // fshost3 -> filesystem -> http://fshost3:1/, |
| 489 // host1 -> localstorage -> http://host1:1/, | 663 // host1 -> localstorage -> http://host1:1/, |
| 490 // host2 -> localstorage -> http://host2:2/. | |
| 491 // host1 -> sessionstorage -> http://host1:1/, | 664 // host1 -> sessionstorage -> http://host1:1/, |
| 492 // host2 -> sessionstorage -> http://host2:2/, | 665 // host2 -> sessionstorage -> http://host2:2/, |
| 493 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 666 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 494 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 667 // idbhost2 -> sessionstorage -> http://idbhost2:2/. |
| 495 EXPECT_EQ(33, cookies_model.GetRoot()->GetTotalNodeCount()); | 668 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 496 EXPECT_STREQ("A,B,C,D", GetMonsterCookies(monster).c_str()); | 669 EXPECT_STREQ("A,B,C,D", GetMonsterCookies(monster).c_str()); |
| 497 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); | 670 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str()); |
| 498 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 671 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 499 EXPECT_EQ("http://host1:1/,http://host2:2/", | 672 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 500 GetDisplayedLocalStorages(&cookies_model)); | 673 GetDisplayedLocalStorages(&cookies_model)); |
| 501 EXPECT_EQ("http://host1:1/,http://host2:2/", | 674 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 502 GetDisplayedSessionStorages(&cookies_model)); | 675 GetDisplayedSessionStorages(&cookies_model)); |
| 503 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 676 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 504 GetDisplayedIndexedDBs(&cookies_model)); | 677 GetDisplayedIndexedDBs(&cookies_model)); |
| 678 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 679 GetDisplayedFileSystems(&cookies_model)); |
| 505 } | 680 } |
| 506 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); | 681 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)); |
| 507 { | 682 { |
| 508 SCOPED_TRACE("Third origin removed"); | 683 SCOPED_TRACE("Third origin removed"); |
| 509 EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); | 684 EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str()); |
| 510 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); | 685 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str()); |
| 511 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 686 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 512 EXPECT_EQ("http://host1:1/,http://host2:2/", | 687 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 513 GetDisplayedLocalStorages(&cookies_model)); | 688 GetDisplayedLocalStorages(&cookies_model)); |
| 514 EXPECT_EQ("http://host1:1/,http://host2:2/", | 689 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 515 GetDisplayedSessionStorages(&cookies_model)); | 690 GetDisplayedSessionStorages(&cookies_model)); |
| 516 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 691 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 517 GetDisplayedIndexedDBs(&cookies_model)); | 692 GetDisplayedIndexedDBs(&cookies_model)); |
| 518 EXPECT_EQ(29, cookies_model.GetRoot()->GetTotalNodeCount()); | 693 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 694 GetDisplayedFileSystems(&cookies_model)); |
| 695 EXPECT_EQ(38, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 519 } | 696 } |
| 520 } | 697 } |
| 521 | 698 |
| 522 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { | 699 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) { |
| 523 net::CookieMonster* monster = profile_->GetCookieMonster(); | 700 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 524 monster->SetCookie(GURL("http://foo1"), "A=1"); | 701 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 525 monster->SetCookie(GURL("http://foo2"), "B=1"); | 702 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 526 monster->SetCookie(GURL("http://foo3"), "C=1"); | 703 monster->SetCookie(GURL("http://foo3"), "C=1"); |
| 527 monster->SetCookie(GURL("http://foo3"), "D=1"); | 704 monster->SetCookie(GURL("http://foo3"), "D=1"); |
| 528 monster->SetCookie(GURL("http://foo3"), "E=1"); | 705 monster->SetCookie(GURL("http://foo3"), "E=1"); |
| 529 CookiesTreeModel cookies_model(monster, | 706 CookiesTreeModel cookies_model(monster, |
| 530 mock_browsing_data_database_helper_, | 707 mock_browsing_data_database_helper_, |
| 531 mock_browsing_data_local_storage_helper_, | 708 mock_browsing_data_local_storage_helper_, |
| 532 mock_browsing_data_session_storage_helper_, | 709 mock_browsing_data_session_storage_helper_, |
| 533 mock_browsing_data_appcache_helper_, | 710 mock_browsing_data_appcache_helper_, |
| 534 mock_browsing_data_indexed_db_helper_, | 711 mock_browsing_data_indexed_db_helper_, |
| 712 mock_browsing_data_file_system_helper_, |
| 535 false); | 713 false); |
| 536 mock_browsing_data_database_helper_->AddDatabaseSamples(); | 714 mock_browsing_data_database_helper_->AddDatabaseSamples(); |
| 537 mock_browsing_data_database_helper_->Notify(); | 715 mock_browsing_data_database_helper_->Notify(); |
| 538 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); | 716 mock_browsing_data_local_storage_helper_->AddLocalStorageSamples(); |
| 539 mock_browsing_data_local_storage_helper_->Notify(); | 717 mock_browsing_data_local_storage_helper_->Notify(); |
| 540 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); | 718 mock_browsing_data_session_storage_helper_->AddLocalStorageSamples(); |
| 541 mock_browsing_data_session_storage_helper_->Notify(); | 719 mock_browsing_data_session_storage_helper_->Notify(); |
| 542 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); | 720 mock_browsing_data_indexed_db_helper_->AddIndexedDBSamples(); |
| 543 mock_browsing_data_indexed_db_helper_->Notify(); | 721 mock_browsing_data_indexed_db_helper_->Notify(); |
| 722 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); |
| 723 mock_browsing_data_file_system_helper_->Notify(); |
| 544 | 724 |
| 545 { | 725 { |
| 546 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " | 726 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, " |
| 547 "2 session storages, 2 indexed DBs"); | 727 "2 session storages, 2 indexed DBs"); |
| 548 // 34 because there's the root, then foo1 -> cookies -> a, | 728 // 43 because there's the root, then foo1 -> cookies -> a, |
| 549 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 729 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
| 550 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, | 730 // dbhost1 -> database -> db1, dbhost2 -> database -> db2, |
| 731 // fshost1 -> filesystem -> http://fshost1:1/, |
| 732 // fshost2 -> filesystem -> http://fshost2:1/, |
| 733 // fshost3 -> filesystem -> http://fshost3:1/, |
| 551 // host1 -> localstorage -> http://host1:1/, | 734 // host1 -> localstorage -> http://host1:1/, |
| 552 // host2 -> localstorage -> http://host2:2/. | 735 // host2 -> localstorage -> http://host2:2/, |
| 553 // host1 -> sessionstorage -> http://host1:1/, | 736 // host1 -> sessionstorage -> http://host1:1/, |
| 554 // host2 -> sessionstorage -> http://host2:2/, | 737 // host2 -> sessionstorage -> http://host2:2/, |
| 555 // idbhost1 -> sessionstorage -> http://idbhost1:1/, | 738 // idbhost1 -> sessionstorage -> http://idbhost1:1/, |
| 556 // idbhost2 -> sessionstorage -> http://idbhost2:2/. | 739 // idbhost2 -> sessionstorage -> http://idbhost2:2/. |
| 557 EXPECT_EQ(34, cookies_model.GetRoot()->GetTotalNodeCount()); | 740 EXPECT_EQ(43, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 558 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); | 741 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); |
| 559 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 742 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 560 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 743 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 561 EXPECT_EQ("http://host1:1/,http://host2:2/", | 744 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 562 GetDisplayedLocalStorages(&cookies_model)); | 745 GetDisplayedLocalStorages(&cookies_model)); |
| 563 EXPECT_EQ("http://host1:1/,http://host2:2/", | 746 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 564 GetDisplayedSessionStorages(&cookies_model)); | 747 GetDisplayedSessionStorages(&cookies_model)); |
| 565 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 748 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 566 GetDisplayedIndexedDBs(&cookies_model)); | 749 GetDisplayedIndexedDBs(&cookies_model)); |
| 750 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 751 GetDisplayedFileSystems(&cookies_model)); |
| 567 } | 752 } |
| 568 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> | 753 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2)->GetChild(0)-> |
| 569 GetChild(1)); | 754 GetChild(1)); |
| 570 { | 755 { |
| 571 SCOPED_TRACE("Middle cookie in third origin removed"); | 756 SCOPED_TRACE("Middle cookie in third origin removed"); |
| 572 EXPECT_STREQ("A,B,C,E", GetMonsterCookies(monster).c_str()); | 757 EXPECT_STREQ("A,B,C,E", GetMonsterCookies(monster).c_str()); |
| 573 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); | 758 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 574 EXPECT_EQ(33, cookies_model.GetRoot()->GetTotalNodeCount()); | 759 EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 575 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); | 760 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model)); |
| 576 EXPECT_EQ("http://host1:1/,http://host2:2/", | 761 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 577 GetDisplayedLocalStorages(&cookies_model)); | 762 GetDisplayedLocalStorages(&cookies_model)); |
| 578 EXPECT_EQ("http://host1:1/,http://host2:2/", | 763 EXPECT_EQ("http://host1:1/,http://host2:2/", |
| 579 GetDisplayedSessionStorages(&cookies_model)); | 764 GetDisplayedSessionStorages(&cookies_model)); |
| 580 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", | 765 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", |
| 581 GetDisplayedIndexedDBs(&cookies_model)); | 766 GetDisplayedIndexedDBs(&cookies_model)); |
| 767 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", |
| 768 GetDisplayedFileSystems(&cookies_model)); |
| 582 } | 769 } |
| 583 } | 770 } |
| 584 | 771 |
| 585 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { | 772 TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) { |
| 586 net::CookieMonster* monster = profile_->GetCookieMonster(); | 773 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 587 monster->SetCookie(GURL("http://foo1"), "A=1"); | 774 monster->SetCookie(GURL("http://foo1"), "A=1"); |
| 588 monster->SetCookie(GURL("http://foo2"), "B=1"); | 775 monster->SetCookie(GURL("http://foo2"), "B=1"); |
| 589 monster->SetCookie(GURL("http://foo3"), "C=1"); | 776 monster->SetCookie(GURL("http://foo3"), "C=1"); |
| 590 monster->SetCookie(GURL("http://foo3"), "D=1"); | 777 monster->SetCookie(GURL("http://foo3"), "D=1"); |
| 591 monster->SetCookie(GURL("http://foo3"), "E=1"); | 778 monster->SetCookie(GURL("http://foo3"), "E=1"); |
| 592 CookiesTreeModel cookies_model(monster, | 779 CookiesTreeModel cookies_model(monster, |
| 593 mock_browsing_data_database_helper_, | 780 mock_browsing_data_database_helper_, |
| 594 mock_browsing_data_local_storage_helper_, | 781 mock_browsing_data_local_storage_helper_, |
| 595 mock_browsing_data_session_storage_helper_, | 782 mock_browsing_data_session_storage_helper_, |
| 596 mock_browsing_data_appcache_helper_, | 783 mock_browsing_data_appcache_helper_, |
| 597 mock_browsing_data_indexed_db_helper_, | 784 mock_browsing_data_indexed_db_helper_, |
| 785 mock_browsing_data_file_system_helper_, |
| 598 false); | 786 false); |
| 599 { | 787 { |
| 600 SCOPED_TRACE("Initial State 5 cookies"); | 788 SCOPED_TRACE("Initial State 5 cookies"); |
| 601 // 11 because there's the root, then foo1 -> cookies -> a, | 789 // 11 because there's the root, then foo1 -> cookies -> a, |
| 602 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e | 790 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e |
| 603 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); | 791 EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount()); |
| 604 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); | 792 EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str()); |
| 605 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); | 793 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str()); |
| 606 } | 794 } |
| 607 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); | 795 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 625 monster->SetCookie(GURL("http://foo1.com"), "F=1"); | 813 monster->SetCookie(GURL("http://foo1.com"), "F=1"); |
| 626 monster->SetCookie(GURL("http://foo3.com"), "G=1"); | 814 monster->SetCookie(GURL("http://foo3.com"), "G=1"); |
| 627 monster->SetCookie(GURL("http://foo4.com"), "H=1"); | 815 monster->SetCookie(GURL("http://foo4.com"), "H=1"); |
| 628 | 816 |
| 629 CookiesTreeModel cookies_model(monster, | 817 CookiesTreeModel cookies_model(monster, |
| 630 new MockBrowsingDataDatabaseHelper(profile_.get()), | 818 new MockBrowsingDataDatabaseHelper(profile_.get()), |
| 631 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 819 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
| 632 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 820 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
| 633 new MockBrowsingDataAppCacheHelper(profile_.get()), | 821 new MockBrowsingDataAppCacheHelper(profile_.get()), |
| 634 new MockBrowsingDataIndexedDBHelper(profile_.get()), | 822 new MockBrowsingDataIndexedDBHelper(profile_.get()), |
| 823 new MockBrowsingDataFileSystemHelper(profile_.get()), |
| 635 false); | 824 false); |
| 636 | 825 |
| 637 { | 826 { |
| 638 SCOPED_TRACE("Initial State 8 cookies"); | 827 SCOPED_TRACE("Initial State 8 cookies"); |
| 639 // CookieMonster orders cookies by pathlength, then by creation time. | 828 // CookieMonster orders cookies by pathlength, then by creation time. |
| 640 // All paths are length 1. | 829 // All paths are length 1. |
| 641 EXPECT_STREQ("A,B,C,D,E,F,G,H", GetMonsterCookies(monster).c_str()); | 830 EXPECT_STREQ("A,B,C,D,E,F,G,H", GetMonsterCookies(monster).c_str()); |
| 642 EXPECT_STREQ("F,E,C,B,A,G,D,H", | 831 EXPECT_STREQ("F,E,C,B,A,G,D,H", |
| 643 GetDisplayedCookies(&cookies_model).c_str()); | 832 GetDisplayedCookies(&cookies_model).c_str()); |
| 644 } | 833 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 655 ContentSettingsPattern::FromString("[*.]example.com"); | 844 ContentSettingsPattern::FromString("[*.]example.com"); |
| 656 net::CookieMonster* monster = profile_->GetCookieMonster(); | 845 net::CookieMonster* monster = profile_->GetCookieMonster(); |
| 657 monster->SetCookie(host, "A=1"); | 846 monster->SetCookie(host, "A=1"); |
| 658 | 847 |
| 659 CookiesTreeModel cookies_model(monster, | 848 CookiesTreeModel cookies_model(monster, |
| 660 new MockBrowsingDataDatabaseHelper(profile_.get()), | 849 new MockBrowsingDataDatabaseHelper(profile_.get()), |
| 661 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 850 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
| 662 new MockBrowsingDataLocalStorageHelper(profile_.get()), | 851 new MockBrowsingDataLocalStorageHelper(profile_.get()), |
| 663 new MockBrowsingDataAppCacheHelper(profile_.get()), | 852 new MockBrowsingDataAppCacheHelper(profile_.get()), |
| 664 new MockBrowsingDataIndexedDBHelper(profile_.get()), | 853 new MockBrowsingDataIndexedDBHelper(profile_.get()), |
| 854 new MockBrowsingDataFileSystemHelper(profile_.get()), |
| 665 false); | 855 false); |
| 666 | 856 |
| 667 TestingProfile profile; | 857 TestingProfile profile; |
| 668 HostContentSettingsMap* content_settings = | 858 HostContentSettingsMap* content_settings = |
| 669 profile.GetHostContentSettingsMap(); | 859 profile.GetHostContentSettingsMap(); |
| 670 StubSettingsObserver observer; | 860 StubSettingsObserver observer; |
| 671 | 861 |
| 672 CookieTreeRootNode* root = | 862 CookieTreeRootNode* root = |
| 673 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); | 863 static_cast<CookieTreeRootNode*>(cookies_model.GetRoot()); |
| 674 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); | 864 CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host); |
| 675 | 865 |
| 676 EXPECT_EQ(1, origin->child_count()); | 866 EXPECT_EQ(1, origin->child_count()); |
| 677 EXPECT_TRUE(origin->CanCreateContentException()); | 867 EXPECT_TRUE(origin->CanCreateContentException()); |
| 678 origin->CreateContentException( | 868 origin->CreateContentException( |
| 679 content_settings, CONTENT_SETTING_SESSION_ONLY); | 869 content_settings, CONTENT_SETTING_SESSION_ONLY); |
| 680 | 870 |
| 681 EXPECT_EQ(2, observer.counter); | 871 EXPECT_EQ(2, observer.counter); |
| 682 EXPECT_EQ(pattern, observer.last_pattern); | 872 EXPECT_EQ(pattern, observer.last_pattern); |
| 683 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, | 873 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, |
| 684 content_settings->GetCookieContentSetting(host, host, true)); | 874 content_settings->GetCookieContentSetting(host, host, true)); |
| 685 } | 875 } |
| 686 | 876 |
| 687 } // namespace | 877 } // namespace |
| OLD | NEW |