| Index: chrome/browser/cookies_tree_model_unittest.cc
|
| diff --git a/chrome/browser/cookies_tree_model_unittest.cc b/chrome/browser/cookies_tree_model_unittest.cc
|
| index f1c47d5f90fe478b98a03084b6a6119b034d109d..9d0cdd7ff0aea4fc0dcaced7e6c69b226131d0a0 100644
|
| --- a/chrome/browser/cookies_tree_model_unittest.cc
|
| +++ b/chrome/browser/cookies_tree_model_unittest.cc
|
| @@ -51,23 +51,29 @@ class CookiesTreeModelTest : public testing::Test {
|
| profile_.reset(new TestingProfile());
|
| profile_->CreateRequestContext();
|
| mock_browsing_data_cookie_helper_ =
|
| - new MockBrowsingDataCookieHelper(profile_->GetRequestContext());
|
| + new MockBrowsingDataCookieHelper(profile_->GetRequestContext());
|
| mock_browsing_data_database_helper_ =
|
| - new MockBrowsingDataDatabaseHelper(profile_.get());
|
| + new MockBrowsingDataDatabaseHelper(profile_.get());
|
| mock_browsing_data_local_storage_helper_ =
|
| - new MockBrowsingDataLocalStorageHelper(profile_.get());
|
| + new MockBrowsingDataLocalStorageHelper(profile_.get());
|
| mock_browsing_data_session_storage_helper_ =
|
| - new MockBrowsingDataLocalStorageHelper(profile_.get());
|
| + new MockBrowsingDataLocalStorageHelper(profile_.get());
|
| mock_browsing_data_appcache_helper_ =
|
| - new MockBrowsingDataAppCacheHelper(profile_.get());
|
| + new MockBrowsingDataAppCacheHelper(profile_.get());
|
| mock_browsing_data_indexed_db_helper_ =
|
| - new MockBrowsingDataIndexedDBHelper();
|
| + new MockBrowsingDataIndexedDBHelper();
|
| mock_browsing_data_file_system_helper_ =
|
| - new MockBrowsingDataFileSystemHelper(profile_.get());
|
| + new MockBrowsingDataFileSystemHelper(profile_.get());
|
| mock_browsing_data_quota_helper_ =
|
| - new MockBrowsingDataQuotaHelper(profile_.get());
|
| + new MockBrowsingDataQuotaHelper(profile_.get());
|
| mock_browsing_data_server_bound_cert_helper_ =
|
| - new MockBrowsingDataServerBoundCertHelper();
|
| + new MockBrowsingDataServerBoundCertHelper();
|
| +
|
| + // It is fine to reuse the profile request context for the app, since
|
| + // the mock cookie helper maintains its own list internally and doesn't
|
| + // really use the request context. Same is true for the rest.
|
| + mock_browsing_data_cookie_helper_app_ =
|
| + new MockBrowsingDataCookieHelper(profile_->GetRequestContext());
|
| }
|
|
|
| virtual void TearDown() OVERRIDE {
|
| @@ -82,8 +88,11 @@ class CookiesTreeModelTest : public testing::Test {
|
| message_loop_.RunAllPending();
|
| }
|
|
|
| - CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() {
|
| - CookiesTreeModel* cookies_model = new CookiesTreeModel(
|
| + CookiesTreeModel* CreateCookiesTreeModelWithInitialSample(bool add_app) {
|
| + ContainerMap containers_map;
|
| +
|
| + containers_map[std::string()] = new LocalDataContainer(
|
| + "Drive-By-Web", std::string(),
|
| mock_browsing_data_cookie_helper_,
|
| mock_browsing_data_database_helper_,
|
| mock_browsing_data_local_storage_helper_,
|
| @@ -92,8 +101,19 @@ class CookiesTreeModelTest : public testing::Test {
|
| mock_browsing_data_indexed_db_helper_,
|
| mock_browsing_data_file_system_helper_,
|
| mock_browsing_data_quota_helper_,
|
| - mock_browsing_data_server_bound_cert_helper_,
|
| - false);
|
| + mock_browsing_data_server_bound_cert_helper_);
|
| +
|
| + if (add_app) {
|
| + std::string app_id = "some-random-id";
|
| + // The cookie helper is mandatory, the rest can be NULL.
|
| + containers_map[app_id] = new LocalDataContainer(
|
| + "Isolated App", app_id,
|
| + mock_browsing_data_cookie_helper_app_,
|
| + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
| + }
|
| +
|
| + CookiesTreeModel* cookies_model = new CookiesTreeModel(containers_map,
|
| + false);
|
| mock_browsing_data_cookie_helper_->
|
| AddCookieSamples(GURL("http://foo1"), "A=1");
|
| mock_browsing_data_cookie_helper_->
|
| @@ -118,28 +138,51 @@ class CookiesTreeModelTest : public testing::Test {
|
| mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample(
|
| "sbc2");
|
| mock_browsing_data_server_bound_cert_helper_->Notify();
|
| +
|
| + if (add_app) {
|
| + mock_browsing_data_cookie_helper_app_->
|
| + AddCookieSamples(GURL("http://app-origin1"), "Z=1");
|
| + mock_browsing_data_cookie_helper_app_->
|
| + AddCookieSamples(GURL("http://app-origin2"), "Y=1");
|
| + mock_browsing_data_cookie_helper_app_->
|
| + AddCookieSamples(GURL("http://app-origin3"), "X=1");
|
| + mock_browsing_data_cookie_helper_app_->Notify();
|
| + }
|
| +
|
| {
|
| SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, "
|
| "2 session storages, 2 indexed DBs, 3 filesystems, "
|
| - "2 quotas");
|
| - // 45 because there's the root, then foo1 -> cookies -> a,
|
| - // foo2 -> cookies -> b, foo3 -> cookies -> c,
|
| - // dbhost1 -> database -> db1, dbhost2 -> database -> db2,
|
| - // fshost1 -> filesystem -> http://fshost1:1/,
|
| - // fshost2 -> filesystem -> http://fshost2:1/,
|
| - // fshost3 -> filesystem -> http://fshost3:1/,
|
| + "2 quotas, 2 server bound certs");
|
| + // 51 because there's the root, then
|
| + // foo1 -> cookies -> a,
|
| + // foo2 -> cookies -> b,
|
| + // foo3 -> cookies -> c,
|
| + // dbhost1 -> database -> db1,
|
| + // dbhost2 -> database -> db2,
|
| // host1 -> localstorage -> http://host1:1/,
|
| + // -> sessionstorage -> http://host1:1/,
|
| // host2 -> localstorage -> http://host2:2/.
|
| - // host1 -> sessionstorage -> http://host1:1/,
|
| - // host2 -> sessionstorage -> http://host2:2/,
|
| + // -> sessionstorage -> http://host2:2/,
|
| // idbhost1 -> indexeddb -> http://idbhost1:1/,
|
| // idbhost2 -> indexeddb -> http://idbhost2:2/,
|
| + // fshost1 -> filesystem -> http://fshost1:1/,
|
| + // fshost2 -> filesystem -> http://fshost2:1/,
|
| + // fshost3 -> filesystem -> http://fshost3:1/,
|
| // quotahost1 -> quotahost1,
|
| // quotahost2 -> quotahost2,
|
| // sbc1 -> sbcerts -> sbc1,
|
| // sbc2 -> sbcerts -> sbc2.
|
| - EXPECT_EQ(51, cookies_model->GetRoot()->GetTotalNodeCount());
|
| - EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model));
|
| + if (!add_app) {
|
| + EXPECT_EQ(51, cookies_model->GetRoot()->GetTotalNodeCount());
|
| + EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model));
|
| + } else {
|
| + // Once we add the app, we have 9 more nodes:
|
| + // app-origin1 -> cookies -> z,
|
| + // app-origin2 -> cookies -> y,
|
| + // app-origin3 -> cookies -> x,
|
| + EXPECT_EQ(60, cookies_model->GetRoot()->GetTotalNodeCount());
|
| + EXPECT_EQ("A,B,C,Z,Y,X", GetDisplayedCookies(cookies_model));
|
| + }
|
| EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model));
|
| EXPECT_EQ("http://host1:1/,http://host2:2/",
|
| GetDisplayedLocalStorages(cookies_model));
|
| @@ -327,11 +370,15 @@ class CookiesTreeModelTest : public testing::Test {
|
| mock_browsing_data_quota_helper_;
|
| scoped_refptr<MockBrowsingDataServerBoundCertHelper>
|
| mock_browsing_data_server_bound_cert_helper_;
|
| +
|
| + // App helpers.
|
| + scoped_refptr<MockBrowsingDataCookieHelper>
|
| + mock_browsing_data_cookie_helper_app_;
|
| };
|
|
|
| TEST_F(CookiesTreeModelTest, RemoveAll) {
|
| scoped_ptr<CookiesTreeModel> cookies_model(
|
| - CreateCookiesTreeModelWithInitialSample());
|
| + CreateCookiesTreeModelWithInitialSample(false));
|
|
|
| // Reset the selection of the first row.
|
| {
|
| @@ -365,9 +412,10 @@ TEST_F(CookiesTreeModelTest, RemoveAll) {
|
|
|
| // Make sure the nodes are also deleted from the model's cache.
|
| // http://crbug.com/43249
|
| - cookies_model->UpdateSearchResults(std::wstring());
|
| + cookies_model->UpdateSearchResults(string16());
|
|
|
| {
|
| + // 2 nodes - root and app
|
| SCOPED_TRACE("After removing");
|
| EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount());
|
| EXPECT_EQ(0, cookies_model->GetRoot()->child_count());
|
| @@ -384,7 +432,7 @@ TEST_F(CookiesTreeModelTest, RemoveAll) {
|
|
|
| TEST_F(CookiesTreeModelTest, Remove) {
|
| scoped_ptr<CookiesTreeModel> cookies_model(
|
| - CreateCookiesTreeModelWithInitialSample());
|
| + CreateCookiesTreeModelWithInitialSample(false));
|
|
|
| // Children start out arranged as follows:
|
| //
|
| @@ -627,27 +675,15 @@ TEST_F(CookiesTreeModelTest, Remove) {
|
|
|
| TEST_F(CookiesTreeModelTest, RemoveCookiesNode) {
|
| scoped_ptr<CookiesTreeModel> cookies_model(
|
| - CreateCookiesTreeModelWithInitialSample());
|
| + CreateCookiesTreeModelWithInitialSample(false));
|
|
|
| - DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0));
|
| + DeleteStoredObjects(
|
| + cookies_model->GetRoot()->GetChild(0)->GetChild(0));
|
| {
|
| SCOPED_TRACE("First origin removed");
|
| EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
|
| - // 43 because in this case, the origin remains, although the COOKIES
|
| - // node beneath it has been deleted. So, we have
|
| - // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c
|
| - // dbhost1 -> database -> db1, dbhost2 -> database -> db2,
|
| - // fshost1 -> filesystem -> http://fshost1:1/,
|
| - // fshost2 -> filesystem -> http://fshost2:1/,
|
| - // fshost3 -> filesystem -> http://fshost3:1/,
|
| - // host1 -> localstorage -> http://host1:1/,
|
| - // host2 -> localstorage -> http://host2:2/,
|
| - // idbhost1 -> sessionstorage -> http://idbhost1:1/,
|
| - // idbhost2 -> sessionstorage -> http://idbhost2:2/,
|
| - // quotahost1 -> quotahost1,
|
| - // quotahost2 -> quotahost1,
|
| - // sbc1 -> sbcerts -> sbc1,
|
| - // sbc2 -> sbcerts -> sbc2.
|
| + // 49 because in this case, the origin remains, although the COOKIES
|
| + // node beneath it has been deleted.
|
| EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount());
|
| EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
|
| EXPECT_EQ("http://host1:1/,http://host2:2/",
|
| @@ -662,7 +698,8 @@ TEST_F(CookiesTreeModelTest, RemoveCookiesNode) {
|
| EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get()));
|
| }
|
|
|
| - DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0));
|
| + DeleteStoredObjects(
|
| + cookies_model->GetRoot()->GetChild(6)->GetChild(0));
|
| {
|
| SCOPED_TRACE("First database removed");
|
| EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
|
| @@ -680,7 +717,8 @@ TEST_F(CookiesTreeModelTest, RemoveCookiesNode) {
|
| EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount());
|
| }
|
|
|
| - DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0));
|
| + DeleteStoredObjects(
|
| + cookies_model->GetRoot()->GetChild(8)->GetChild(0));
|
| {
|
| SCOPED_TRACE("First origin removed");
|
| EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
|
| @@ -701,9 +739,10 @@ TEST_F(CookiesTreeModelTest, RemoveCookiesNode) {
|
|
|
| TEST_F(CookiesTreeModelTest, RemoveCookieNode) {
|
| scoped_ptr<CookiesTreeModel> cookies_model(
|
| - CreateCookiesTreeModelWithInitialSample());
|
| + CreateCookiesTreeModelWithInitialSample(false));
|
|
|
| - DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0));
|
| + DeleteStoredObjects(
|
| + cookies_model->GetRoot()->GetChild(1)->GetChild(0));
|
| {
|
| SCOPED_TRACE("Second origin COOKIES node removed");
|
| EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str());
|
| @@ -718,25 +757,13 @@ TEST_F(CookiesTreeModelTest, RemoveCookieNode) {
|
| GetDisplayedFileSystems(cookies_model.get()));
|
| EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get()));
|
| EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get()));
|
| - // 43 because in this case, the origin remains, although the COOKIES
|
| - // node beneath it has been deleted. So, we have
|
| - // root -> foo1 -> cookies -> a, foo2, foo3 -> cookies -> c
|
| - // dbhost1 -> database -> db1, dbhost2 -> database -> db2,
|
| - // fshost1 -> filesystem -> http://fshost1:1/,
|
| - // fshost2 -> filesystem -> http://fshost2:1/,
|
| - // fshost3 -> filesystem -> http://fshost3:1/,
|
| - // host1 -> localstorage -> http://host1:1/,
|
| - // host2 -> localstorage -> http://host2:2/,
|
| - // host1 -> sessionstorage -> http://host1:1/,
|
| - // host2 -> sessionstorage -> http://host2:2/,
|
| - // idbhost1 -> sessionstorage -> http://idbhost1:1/,
|
| - // idbhost2 -> sessionstorage -> http://idbhost2:2/,
|
| - // quotahost1 -> quotahost1,
|
| - // quotahost2 -> quotahost2.
|
| + // 49 because in this case, the origin remains, although the COOKIES
|
| + // node beneath it has been deleted.
|
| EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount());
|
| }
|
|
|
| - DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0));
|
| + DeleteStoredObjects(
|
| + cookies_model->GetRoot()->GetChild(6)->GetChild(0));
|
| {
|
| SCOPED_TRACE("First database removed");
|
| EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str());
|
| @@ -754,7 +781,8 @@ TEST_F(CookiesTreeModelTest, RemoveCookieNode) {
|
| EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount());
|
| }
|
|
|
| - DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0));
|
| + DeleteStoredObjects(
|
| + cookies_model->GetRoot()->GetChild(8)->GetChild(0));
|
| {
|
| SCOPED_TRACE("First origin removed");
|
| EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str());
|
| @@ -774,16 +802,21 @@ TEST_F(CookiesTreeModelTest, RemoveCookieNode) {
|
| }
|
|
|
| TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) {
|
| - CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_,
|
| - mock_browsing_data_database_helper_,
|
| - mock_browsing_data_local_storage_helper_,
|
| - mock_browsing_data_session_storage_helper_,
|
| - mock_browsing_data_appcache_helper_,
|
| - mock_browsing_data_indexed_db_helper_,
|
| - mock_browsing_data_file_system_helper_,
|
| - mock_browsing_data_quota_helper_,
|
| - mock_browsing_data_server_bound_cert_helper_,
|
| - false);
|
| + ContainerMap container_map;
|
| +
|
| + container_map[std::string()] = new LocalDataContainer(
|
| + "Drive-By-Web", std::string(),
|
| + mock_browsing_data_cookie_helper_,
|
| + mock_browsing_data_database_helper_,
|
| + mock_browsing_data_local_storage_helper_,
|
| + mock_browsing_data_session_storage_helper_,
|
| + mock_browsing_data_appcache_helper_,
|
| + mock_browsing_data_indexed_db_helper_,
|
| + mock_browsing_data_file_system_helper_,
|
| + mock_browsing_data_quota_helper_,
|
| + mock_browsing_data_server_bound_cert_helper_);
|
| + CookiesTreeModel cookies_model(container_map, false);
|
| +
|
| mock_browsing_data_cookie_helper_->
|
| AddCookieSamples(GURL("http://foo1"), "A=1");
|
| mock_browsing_data_cookie_helper_->
|
| @@ -810,17 +843,21 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) {
|
| SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, "
|
| "2 session storages, 2 indexed DBs, 3 file systems, "
|
| "2 quotas.");
|
| - // 42 because there's the root, then foo1 -> cookies -> a,
|
| - // foo2 -> cookies -> b, foo3 -> cookies -> c,d
|
| - // dbhost1 -> database -> db1, dbhost2 -> database -> db2,
|
| - // fshost1 -> filesystem -> http://fshost1:1/,
|
| - // fshost2 -> filesystem -> http://fshost2:1/,
|
| - // fshost3 -> filesystem -> http://fshost3:1/,
|
| + // 46 because there's the root, then
|
| + // foo1 -> cookies -> a,
|
| + // foo2 -> cookies -> b,
|
| + // foo3 -> cookies -> c,d
|
| + // dbhost1 -> database -> db1,
|
| + // dbhost2 -> database -> db2,
|
| // host1 -> localstorage -> http://host1:1/,
|
| - // host1 -> sessionstorage -> http://host1:1/,
|
| - // host2 -> sessionstorage -> http://host2:2/,
|
| + // -> sessionstorage -> http://host1:1/,
|
| + // host2 -> localstorage -> http://host2:2/,
|
| + // -> sessionstorage -> http://host2:2/,
|
| // idbhost1 -> sessionstorage -> http://idbhost1:1/,
|
| // idbhost2 -> sessionstorage -> http://idbhost2:2/,
|
| + // fshost1 -> filesystem -> http://fshost1:1/,
|
| + // fshost2 -> filesystem -> http://fshost2:1/,
|
| + // fshost3 -> filesystem -> http://fshost3:1/,
|
| // quotahost1 -> quotahost1,
|
| // quotahost2 -> quotahost2.
|
| EXPECT_EQ(46, cookies_model.GetRoot()->GetTotalNodeCount());
|
| @@ -855,16 +892,21 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) {
|
| }
|
|
|
| TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) {
|
| - CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_,
|
| - mock_browsing_data_database_helper_,
|
| - mock_browsing_data_local_storage_helper_,
|
| - mock_browsing_data_session_storage_helper_,
|
| - mock_browsing_data_appcache_helper_,
|
| - mock_browsing_data_indexed_db_helper_,
|
| - mock_browsing_data_file_system_helper_,
|
| - mock_browsing_data_quota_helper_,
|
| - mock_browsing_data_server_bound_cert_helper_,
|
| - false);
|
| + ContainerMap container_map;
|
| +
|
| + container_map[std::string()] = new LocalDataContainer(
|
| + "Drive-By-Web", std::string(),
|
| + mock_browsing_data_cookie_helper_,
|
| + mock_browsing_data_database_helper_,
|
| + mock_browsing_data_local_storage_helper_,
|
| + mock_browsing_data_session_storage_helper_,
|
| + mock_browsing_data_appcache_helper_,
|
| + mock_browsing_data_indexed_db_helper_,
|
| + mock_browsing_data_file_system_helper_,
|
| + mock_browsing_data_quota_helper_,
|
| + mock_browsing_data_server_bound_cert_helper_);
|
| + CookiesTreeModel cookies_model(container_map, false);
|
| +
|
| mock_browsing_data_cookie_helper_->
|
| AddCookieSamples(GURL("http://foo1"), "A=1");
|
| mock_browsing_data_cookie_helper_->
|
| @@ -893,18 +935,21 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) {
|
| SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, "
|
| "2 session storages, 2 indexed DBs, 3 filesystems, "
|
| "2 quotas.");
|
| - // 43 because there's the root, then foo1 -> cookies -> a,
|
| - // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e
|
| - // dbhost1 -> database -> db1, dbhost2 -> database -> db2,
|
| - // fshost1 -> filesystem -> http://fshost1:1/,
|
| - // fshost2 -> filesystem -> http://fshost2:1/,
|
| - // fshost3 -> filesystem -> http://fshost3:1/,
|
| + // 47 because there's the root, then
|
| + // foo1 -> cookies -> a,
|
| + // foo2 -> cookies -> b,
|
| + // foo3 -> cookies -> c,d,e
|
| + // dbhost1 -> database -> db1,
|
| + // dbhost2 -> database -> db2,
|
| // host1 -> localstorage -> http://host1:1/,
|
| + // -> sessionstorage -> http://host1:1/,
|
| // host2 -> localstorage -> http://host2:2/,
|
| - // host1 -> sessionstorage -> http://host1:1/,
|
| - // host2 -> sessionstorage -> http://host2:2/,
|
| + // -> sessionstorage -> http://host2:2/,
|
| // idbhost1 -> sessionstorage -> http://idbhost1:1/,
|
| // idbhost2 -> sessionstorage -> http://idbhost2:2/,
|
| + // fshost1 -> filesystem -> http://fshost1:1/,
|
| + // fshost2 -> filesystem -> http://fshost2:1/,
|
| + // fshost3 -> filesystem -> http://fshost3:1/,
|
| // quotahost1 -> quotahost1,
|
| // quotahost2 -> quotahost2.
|
| EXPECT_EQ(47, cookies_model.GetRoot()->GetTotalNodeCount());
|
| @@ -940,16 +985,21 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) {
|
| }
|
|
|
| TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) {
|
| - CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_,
|
| - mock_browsing_data_database_helper_,
|
| - mock_browsing_data_local_storage_helper_,
|
| - mock_browsing_data_session_storage_helper_,
|
| - mock_browsing_data_appcache_helper_,
|
| - mock_browsing_data_indexed_db_helper_,
|
| - mock_browsing_data_file_system_helper_,
|
| - mock_browsing_data_quota_helper_,
|
| - mock_browsing_data_server_bound_cert_helper_,
|
| - false);
|
| + ContainerMap container_map;
|
| +
|
| + container_map[std::string()] = new LocalDataContainer(
|
| + "Drive-By-Web", std::string(),
|
| + mock_browsing_data_cookie_helper_,
|
| + mock_browsing_data_database_helper_,
|
| + mock_browsing_data_local_storage_helper_,
|
| + mock_browsing_data_session_storage_helper_,
|
| + mock_browsing_data_appcache_helper_,
|
| + mock_browsing_data_indexed_db_helper_,
|
| + mock_browsing_data_file_system_helper_,
|
| + mock_browsing_data_quota_helper_,
|
| + mock_browsing_data_server_bound_cert_helper_);
|
| + CookiesTreeModel cookies_model(container_map, false);
|
| +
|
| mock_browsing_data_cookie_helper_->
|
| AddCookieSamples(GURL("http://foo1"), "A=1");
|
| mock_browsing_data_cookie_helper_->
|
| @@ -964,7 +1014,7 @@ TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) {
|
|
|
| {
|
| SCOPED_TRACE("Initial State 5 cookies");
|
| - // 11 because there's the root, then foo1 -> cookies -> a,
|
| + // 12 because there's the root, then foo1 -> cookies -> a,
|
| // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e
|
| EXPECT_EQ(12, cookies_model.GetRoot()->GetTotalNodeCount());
|
| EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str());
|
| @@ -979,16 +1029,21 @@ TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) {
|
| }
|
|
|
| TEST_F(CookiesTreeModelTest, OriginOrdering) {
|
| - CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_,
|
| - mock_browsing_data_database_helper_,
|
| - mock_browsing_data_local_storage_helper_,
|
| - mock_browsing_data_session_storage_helper_,
|
| - mock_browsing_data_appcache_helper_,
|
| - mock_browsing_data_indexed_db_helper_,
|
| - mock_browsing_data_file_system_helper_,
|
| - mock_browsing_data_quota_helper_,
|
| - mock_browsing_data_server_bound_cert_helper_,
|
| - false);
|
| + ContainerMap container_map;
|
| +
|
| + container_map[std::string()] = new LocalDataContainer(
|
| + "Drive-By-Web", std::string(),
|
| + mock_browsing_data_cookie_helper_,
|
| + mock_browsing_data_database_helper_,
|
| + mock_browsing_data_local_storage_helper_,
|
| + mock_browsing_data_session_storage_helper_,
|
| + mock_browsing_data_appcache_helper_,
|
| + mock_browsing_data_indexed_db_helper_,
|
| + mock_browsing_data_file_system_helper_,
|
| + mock_browsing_data_quota_helper_,
|
| + mock_browsing_data_server_bound_cert_helper_);
|
| + CookiesTreeModel cookies_model(container_map, false);
|
| +
|
| mock_browsing_data_cookie_helper_->
|
| AddCookieSamples(GURL("http://a.foo2.com"), "A=1");
|
| mock_browsing_data_cookie_helper_->
|
| @@ -1014,7 +1069,8 @@ TEST_F(CookiesTreeModelTest, OriginOrdering) {
|
| EXPECT_STREQ("F,E,C,B,A,G,D,H",
|
| GetDisplayedCookies(&cookies_model).c_str());
|
| }
|
| - DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E"
|
| + // Delete "E"
|
| + DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1));
|
| {
|
| EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str());
|
| }
|
| @@ -1022,16 +1078,23 @@ TEST_F(CookiesTreeModelTest, OriginOrdering) {
|
|
|
| TEST_F(CookiesTreeModelTest, ContentSettings) {
|
| GURL host("http://example.com/");
|
| - CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_,
|
| - mock_browsing_data_database_helper_,
|
| - mock_browsing_data_local_storage_helper_,
|
| - mock_browsing_data_session_storage_helper_,
|
| - mock_browsing_data_appcache_helper_,
|
| - mock_browsing_data_indexed_db_helper_,
|
| - mock_browsing_data_file_system_helper_,
|
| - mock_browsing_data_quota_helper_,
|
| - mock_browsing_data_server_bound_cert_helper_,
|
| - false);
|
| + std::string name = "Drive-By-Web";
|
| + std::string browser_id;
|
| + ContainerMap container_map;
|
| +
|
| + container_map[browser_id] = new LocalDataContainer(
|
| + name, browser_id,
|
| + mock_browsing_data_cookie_helper_,
|
| + mock_browsing_data_database_helper_,
|
| + mock_browsing_data_local_storage_helper_,
|
| + mock_browsing_data_session_storage_helper_,
|
| + mock_browsing_data_appcache_helper_,
|
| + mock_browsing_data_indexed_db_helper_,
|
| + mock_browsing_data_file_system_helper_,
|
| + mock_browsing_data_quota_helper_,
|
| + mock_browsing_data_server_bound_cert_helper_);
|
| + CookiesTreeModel cookies_model(container_map, false);
|
| +
|
| mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1");
|
| mock_browsing_data_cookie_helper_->Notify();
|
|
|
| @@ -1044,7 +1107,9 @@ TEST_F(CookiesTreeModelTest, ContentSettings) {
|
|
|
| CookieTreeRootNode* root =
|
| static_cast<CookieTreeRootNode*>(cookies_model.GetRoot());
|
| - CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host);
|
| + CookieTreeOriginNode* origin = root->GetOrCreateOriginNode(host,
|
| + browser_id,
|
| + name);
|
|
|
| EXPECT_EQ(1, origin->child_count());
|
| EXPECT_TRUE(origin->CanCreateContentException());
|
| @@ -1069,25 +1134,75 @@ TEST_F(CookiesTreeModelTest, ContentSettings) {
|
| EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(host));
|
| }
|
|
|
| +TEST_F(CookiesTreeModelTest, AppOriginTitle) {
|
| + scoped_ptr<CookiesTreeModel> cookies_model(
|
| + CreateCookiesTreeModelWithInitialSample(true));
|
| +
|
| + EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin1"),
|
| + cookies_model->GetRoot()->GetChild(16)->GetTitle());
|
| + EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin2"),
|
| + cookies_model->GetRoot()->GetChild(17)->GetTitle());
|
| +}
|
| +
|
| TEST_F(CookiesTreeModelTest, FileSystemFilter) {
|
| scoped_ptr<CookiesTreeModel> cookies_model(
|
| - CreateCookiesTreeModelWithInitialSample());
|
| + CreateCookiesTreeModelWithInitialSample(false));
|
|
|
| - cookies_model->UpdateSearchResults(std::wstring(L"fshost1"));
|
| + cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost1")));
|
| EXPECT_EQ("http://fshost1:1/",
|
| GetDisplayedFileSystems(cookies_model.get()));
|
|
|
| - cookies_model->UpdateSearchResults(std::wstring(L"fshost2"));
|
| + cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost2")));
|
| EXPECT_EQ("http://fshost2:2/",
|
| GetDisplayedFileSystems(cookies_model.get()));
|
|
|
| - cookies_model->UpdateSearchResults(std::wstring(L"fshost3"));
|
| + cookies_model->UpdateSearchResults(string16(ASCIIToUTF16("fshost3")));
|
| EXPECT_EQ("http://fshost3:3/",
|
| GetDisplayedFileSystems(cookies_model.get()));
|
|
|
| - cookies_model->UpdateSearchResults(std::wstring());
|
| + cookies_model->UpdateSearchResults(string16());
|
| EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
|
| GetDisplayedFileSystems(cookies_model.get()));
|
| }
|
|
|
| +TEST_F(CookiesTreeModelTest, CookiesFilter) {
|
| + ContainerMap container_map;
|
| +
|
| + container_map[std::string()] = new LocalDataContainer(
|
| + "Drive-By-Web", std::string(),
|
| + mock_browsing_data_cookie_helper_,
|
| + mock_browsing_data_database_helper_,
|
| + mock_browsing_data_local_storage_helper_,
|
| + mock_browsing_data_session_storage_helper_,
|
| + mock_browsing_data_appcache_helper_,
|
| + mock_browsing_data_indexed_db_helper_,
|
| + mock_browsing_data_file_system_helper_,
|
| + mock_browsing_data_quota_helper_,
|
| + mock_browsing_data_server_bound_cert_helper_);
|
| + CookiesTreeModel cookies_model(container_map, false);
|
| +
|
| + mock_browsing_data_cookie_helper_->
|
| + AddCookieSamples(GURL("http://123.com"), "A=1");
|
| + mock_browsing_data_cookie_helper_->
|
| + AddCookieSamples(GURL("http://foo1.com"), "B=1");
|
| + mock_browsing_data_cookie_helper_->
|
| + AddCookieSamples(GURL("http://foo2.com"), "C=1");
|
| + mock_browsing_data_cookie_helper_->
|
| + AddCookieSamples(GURL("http://foo3.com"), "D=1");
|
| + mock_browsing_data_cookie_helper_->Notify();
|
| + EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model));
|
| +
|
| + cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo")));
|
| + EXPECT_EQ("B,C,D", GetDisplayedCookies(&cookies_model));
|
| +
|
| + cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("2")));
|
| + EXPECT_EQ("A,C", GetDisplayedCookies(&cookies_model));
|
| +
|
| + cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo3")));
|
| + EXPECT_EQ("D", GetDisplayedCookies(&cookies_model));
|
| +
|
| + cookies_model.UpdateSearchResults(string16());
|
| + EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model));
|
| +}
|
| +
|
| } // namespace
|
|
|