summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cookies_tree_model_unittest.cc
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 04:18:52 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-05 04:18:52 +0000
commite7ff519084d384ed51d11e66c1b029329f14eba9 (patch)
treea4492c4f277c59304aa251ab023529e4436a2812 /chrome/browser/cookies_tree_model_unittest.cc
parent575a95d355333194e2f2e4981c6a18b0adc8226c (diff)
downloadchromium_src-e7ff519084d384ed51d11e66c1b029329f14eba9.zip
chromium_src-e7ff519084d384ed51d11e66c1b029329f14eba9.tar.gz
chromium_src-e7ff519084d384ed51d11e66c1b029329f14eba9.tar.bz2
Revert 95534 - Creat BrowsingDataCookieHelper and CannedBrowsingDataCookieHelper for logging cookies at UI thread.
BUG=XXX TEST=XXX Review URL: http://codereview.chromium.org/7355025 TBR=ycxiao@chromium.org Review URL: http://codereview.chromium.org/7491049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95575 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cookies_tree_model_unittest.cc')
-rw-r--r--chrome/browser/cookies_tree_model_unittest.cc196
1 files changed, 105 insertions, 91 deletions
diff --git a/chrome/browser/cookies_tree_model_unittest.cc b/chrome/browser/cookies_tree_model_unittest.cc
index dc6bbbc..20f7080 100644
--- a/chrome/browser/cookies_tree_model_unittest.cc
+++ b/chrome/browser/cookies_tree_model_unittest.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/content_settings/mock_settings_observer.h"
#include "chrome/browser/mock_browsing_data_appcache_helper.h"
-#include "chrome/browser/mock_browsing_data_cookie_helper.h"
#include "chrome/browser/mock_browsing_data_database_helper.h"
#include "chrome/browser/mock_browsing_data_file_system_helper.h"
#include "chrome/browser/mock_browsing_data_indexed_db_helper.h"
@@ -40,8 +39,6 @@ class CookiesTreeModelTest : public TestingBrowserProcessTest {
virtual void SetUp() {
profile_.reset(new TestingProfile());
profile_->CreateRequestContext();
- mock_browsing_data_cookie_helper_ =
- new MockBrowsingDataCookieHelper(profile_.get());
mock_browsing_data_database_helper_ =
new MockBrowsingDataDatabaseHelper(profile_.get());
mock_browsing_data_local_storage_helper_ =
@@ -57,22 +54,18 @@ class CookiesTreeModelTest : public TestingBrowserProcessTest {
}
CookiesTreeModel* CreateCookiesTreeModelWithInitialSample() {
+ net::CookieMonster* monster = profile_->GetCookieMonster();
+ monster->SetCookie(GURL("http://foo1"), "A=1");
+ monster->SetCookie(GURL("http://foo2"), "B=1");
+ monster->SetCookie(GURL("http://foo3"), "C=1");
CookiesTreeModel* cookies_model = new CookiesTreeModel(
- mock_browsing_data_cookie_helper_,
- mock_browsing_data_database_helper_,
+ monster, 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_,
false);
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo1"), "A=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo2"), "B=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3"), "C=1");
- mock_browsing_data_cookie_helper_->Notify();
mock_browsing_data_database_helper_->AddDatabaseSamples();
mock_browsing_data_database_helper_->Notify();
mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
@@ -99,7 +92,6 @@ class CookiesTreeModelTest : public TestingBrowserProcessTest {
// idbhost1 -> indexeddb -> http://idbhost1:1/,
// idbhost2 -> indexeddb -> http://idbhost2:2/.
EXPECT_EQ(41, cookies_model->GetRoot()->GetTotalNodeCount());
- EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model));
EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model));
EXPECT_EQ("http://host1:1/,http://host2:2/",
GetDisplayedLocalStorages(cookies_model));
@@ -113,6 +105,20 @@ class CookiesTreeModelTest : public TestingBrowserProcessTest {
return cookies_model;
}
+ // Get the cookie names in the cookie list, as a comma seperated string.
+ // (Note that the CookieMonster cookie list is sorted by domain.)
+ // Ex:
+ // monster->SetCookie(GURL("http://b"), "X=1")
+ // monster->SetCookie(GURL("http://a"), "Y=1")
+ // EXPECT_STREQ("Y,X", GetMonsterCookies(monster).c_str());
+ std::string GetMonsterCookies(net::CookieMonster* monster) {
+ std::vector<std::string> parts;
+ net::CookieList cookie_list = monster->GetAllCookies();
+ for (size_t i = 0; i < cookie_list.size(); ++i)
+ parts.push_back(cookie_list[i].Name());
+ return JoinString(parts, ',');
+ }
+
std::string GetNodesOfChildren(
const CookieTreeNode* node,
CookieTreeNode::DetailedInfo::NodeType node_type) {
@@ -241,8 +247,6 @@ class CookiesTreeModelTest : public TestingBrowserProcessTest {
BrowserThread io_thread_;
scoped_ptr<TestingProfile> profile_;
- scoped_refptr<MockBrowsingDataCookieHelper>
- mock_browsing_data_cookie_helper_;
scoped_refptr<MockBrowsingDataDatabaseHelper>
mock_browsing_data_database_helper_;
scoped_refptr<MockBrowsingDataLocalStorageHelper>
@@ -260,11 +264,12 @@ class CookiesTreeModelTest : public TestingBrowserProcessTest {
TEST_F(CookiesTreeModelTest, RemoveAll) {
scoped_ptr<CookiesTreeModel> cookies_model(
CreateCookiesTreeModelWithInitialSample());
+ net::CookieMonster* monster = profile_->GetCookieMonster();
// Reset the selection of the first row.
{
SCOPED_TRACE("Before removing");
- EXPECT_EQ("A,B,C",
+ EXPECT_EQ(GetMonsterCookies(monster),
GetDisplayedCookies(cookies_model.get()));
EXPECT_EQ("db1,db2",
GetDisplayedDatabases(cookies_model.get()));
@@ -278,7 +283,6 @@ TEST_F(CookiesTreeModelTest, RemoveAll) {
GetDisplayedFileSystems(cookies_model.get()));
}
- mock_browsing_data_cookie_helper_->Reset();
mock_browsing_data_database_helper_->Reset();
mock_browsing_data_local_storage_helper_->Reset();
mock_browsing_data_session_storage_helper_->Reset();
@@ -291,8 +295,9 @@ TEST_F(CookiesTreeModelTest, RemoveAll) {
SCOPED_TRACE("After removing");
EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount());
EXPECT_EQ(0, cookies_model->GetRoot()->child_count());
- EXPECT_EQ(std::string(""), GetDisplayedCookies(cookies_model.get()));
- EXPECT_TRUE(mock_browsing_data_cookie_helper_->AllDeleted());
+ EXPECT_EQ(std::string(""), GetMonsterCookies(monster));
+ EXPECT_EQ(GetMonsterCookies(monster),
+ GetDisplayedCookies(cookies_model.get()));
EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted());
EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted());
EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted());
@@ -304,6 +309,7 @@ TEST_F(CookiesTreeModelTest, RemoveAll) {
TEST_F(CookiesTreeModelTest, Remove) {
scoped_ptr<CookiesTreeModel> cookies_model(
CreateCookiesTreeModelWithInitialSample());
+ net::CookieMonster* monster = profile_->GetCookieMonster();
// Children start out arranged as follows:
//
@@ -326,6 +332,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(11));
{
SCOPED_TRACE("`idbhost2` removed.");
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("http://host1:1/,http://host2:2/",
@@ -341,6 +348,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(10));
{
SCOPED_TRACE("`idbhost1` removed.");
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("http://host1:1/,http://host2:2/",
@@ -355,6 +363,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(9));
{
SCOPED_TRACE("`host2` removed.");
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("http://host1:1/",
@@ -369,6 +378,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8));
{
SCOPED_TRACE("`host1` removed.");
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get()));
@@ -381,6 +391,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(7));
{
SCOPED_TRACE("`gdbhost2` removed.");
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db1", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get()));
@@ -393,6 +404,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6));
{
SCOPED_TRACE("`gdbhost1` removed.");
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get()));
@@ -405,6 +417,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(5));
{
SCOPED_TRACE("`fshost3` removed.");
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get()));
@@ -417,6 +430,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(4));
{
SCOPED_TRACE("`fshost2` removed.");
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get()));
@@ -429,6 +443,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(3));
{
SCOPED_TRACE("`fshost1` removed.");
+ EXPECT_STREQ("A,B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get()));
@@ -440,6 +455,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(2));
{
SCOPED_TRACE("`foo3` removed.");
+ EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get()));
@@ -451,6 +467,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1));
{
SCOPED_TRACE("`foo2` removed.");
+ EXPECT_STREQ("A", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get()));
@@ -462,6 +479,7 @@ TEST_F(CookiesTreeModelTest, Remove) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0));
{
SCOPED_TRACE("`foo1` removed.");
+ EXPECT_STREQ("", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model.get()));
@@ -475,10 +493,12 @@ TEST_F(CookiesTreeModelTest, Remove) {
TEST_F(CookiesTreeModelTest, RemoveCookiesNode) {
scoped_ptr<CookiesTreeModel> cookies_model(
CreateCookiesTreeModelWithInitialSample());
+ net::CookieMonster* monster = profile_->GetCookieMonster();
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(0)->GetChild(0));
{
SCOPED_TRACE("First origin removed");
+ EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
// 39 because in this case, the origin remains, although the COOKIES
// node beneath it has been deleted. So, we have
@@ -506,6 +526,7 @@ TEST_F(CookiesTreeModelTest, RemoveCookiesNode) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0));
{
SCOPED_TRACE("First database removed");
+ EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("http://host1:1/,http://host2:2/",
@@ -522,6 +543,7 @@ TEST_F(CookiesTreeModelTest, RemoveCookiesNode) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0));
{
SCOPED_TRACE("First origin removed");
+ EXPECT_STREQ("B,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("http://host2:2/",
@@ -539,10 +561,12 @@ TEST_F(CookiesTreeModelTest, RemoveCookiesNode) {
TEST_F(CookiesTreeModelTest, RemoveCookieNode) {
scoped_ptr<CookiesTreeModel> cookies_model(
CreateCookiesTreeModelWithInitialSample());
+ net::CookieMonster* monster = profile_->GetCookieMonster();
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(1)->GetChild(0));
{
SCOPED_TRACE("Second origin COOKIES node removed");
+ EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("http://host1:1/,http://host2:2/",
@@ -572,6 +596,7 @@ TEST_F(CookiesTreeModelTest, RemoveCookieNode) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(6)->GetChild(0));
{
SCOPED_TRACE("First database removed");
+ EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("http://host1:1/,http://host2:2/",
@@ -588,6 +613,7 @@ TEST_F(CookiesTreeModelTest, RemoveCookieNode) {
DeleteStoredObjects(cookies_model->GetRoot()->GetChild(8)->GetChild(0));
{
SCOPED_TRACE("First origin removed");
+ EXPECT_STREQ("A,C", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str());
EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get()));
EXPECT_EQ("http://host2:2/",
@@ -603,7 +629,12 @@ TEST_F(CookiesTreeModelTest, RemoveCookieNode) {
}
TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) {
- CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_,
+ net::CookieMonster* monster = profile_->GetCookieMonster();
+ monster->SetCookie(GURL("http://foo1"), "A=1");
+ monster->SetCookie(GURL("http://foo2"), "B=1");
+ monster->SetCookie(GURL("http://foo3"), "C=1");
+ monster->SetCookie(GURL("http://foo3"), "D=1");
+ CookiesTreeModel cookies_model(monster,
mock_browsing_data_database_helper_,
mock_browsing_data_local_storage_helper_,
mock_browsing_data_session_storage_helper_,
@@ -611,15 +642,6 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) {
mock_browsing_data_indexed_db_helper_,
mock_browsing_data_file_system_helper_,
false);
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo1"), "A=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo2"), "B=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3"), "C=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3"), "D=1");
- mock_browsing_data_cookie_helper_->Notify();
mock_browsing_data_database_helper_->AddDatabaseSamples();
mock_browsing_data_database_helper_->Notify();
mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
@@ -646,6 +668,7 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) {
// idbhost1 -> sessionstorage -> http://idbhost1:1/,
// idbhost2 -> sessionstorage -> http://idbhost2:2/.
EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount());
+ EXPECT_STREQ("A,B,C,D", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model).c_str());
EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model));
EXPECT_EQ("http://host1:1/,http://host2:2/",
@@ -660,6 +683,7 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) {
DeleteStoredObjects(cookies_model.GetRoot()->GetChild(2));
{
SCOPED_TRACE("Third origin removed");
+ EXPECT_STREQ("A,B", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model).c_str());
EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model));
EXPECT_EQ("http://host1:1/,http://host2:2/",
@@ -675,7 +699,13 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) {
}
TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) {
- CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_,
+ net::CookieMonster* monster = profile_->GetCookieMonster();
+ monster->SetCookie(GURL("http://foo1"), "A=1");
+ monster->SetCookie(GURL("http://foo2"), "B=1");
+ monster->SetCookie(GURL("http://foo3"), "C=1");
+ monster->SetCookie(GURL("http://foo3"), "D=1");
+ monster->SetCookie(GURL("http://foo3"), "E=1");
+ CookiesTreeModel cookies_model(monster,
mock_browsing_data_database_helper_,
mock_browsing_data_local_storage_helper_,
mock_browsing_data_session_storage_helper_,
@@ -683,17 +713,6 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) {
mock_browsing_data_indexed_db_helper_,
mock_browsing_data_file_system_helper_,
false);
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo1"), "A=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo2"), "B=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3"), "C=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3"), "D=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3"), "E=1");
- mock_browsing_data_cookie_helper_->Notify();
mock_browsing_data_database_helper_->AddDatabaseSamples();
mock_browsing_data_database_helper_->Notify();
mock_browsing_data_local_storage_helper_->AddLocalStorageSamples();
@@ -721,6 +740,7 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) {
// idbhost1 -> sessionstorage -> http://idbhost1:1/,
// idbhost2 -> sessionstorage -> http://idbhost2:2/.
EXPECT_EQ(43, cookies_model.GetRoot()->GetTotalNodeCount());
+ EXPECT_STREQ("A,B,C,D,E", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str());
EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model));
EXPECT_EQ("http://host1:1/,http://host2:2/",
@@ -736,6 +756,7 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) {
GetChild(1));
{
SCOPED_TRACE("Middle cookie in third origin removed");
+ EXPECT_STREQ("A,B,C,E", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model).c_str());
EXPECT_EQ(42, cookies_model.GetRoot()->GetTotalNodeCount());
EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model));
@@ -751,7 +772,13 @@ TEST_F(CookiesTreeModelTest, RemoveSingleCookieNodeOf3) {
}
TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) {
- CookiesTreeModel cookies_model(mock_browsing_data_cookie_helper_,
+ net::CookieMonster* monster = profile_->GetCookieMonster();
+ monster->SetCookie(GURL("http://foo1"), "A=1");
+ monster->SetCookie(GURL("http://foo2"), "B=1");
+ monster->SetCookie(GURL("http://foo3"), "C=1");
+ monster->SetCookie(GURL("http://foo3"), "D=1");
+ monster->SetCookie(GURL("http://foo3"), "E=1");
+ CookiesTreeModel cookies_model(monster,
mock_browsing_data_database_helper_,
mock_browsing_data_local_storage_helper_,
mock_browsing_data_session_storage_helper_,
@@ -759,28 +786,18 @@ TEST_F(CookiesTreeModelTest, RemoveSecondOrigin) {
mock_browsing_data_indexed_db_helper_,
mock_browsing_data_file_system_helper_,
false);
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo1"), "A=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo2"), "B=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3"), "C=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3"), "D=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3"), "E=1");
- mock_browsing_data_cookie_helper_->Notify();
-
{
SCOPED_TRACE("Initial State 5 cookies");
// 11 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", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model).c_str());
}
DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1));
{
SCOPED_TRACE("Second origin removed");
+ EXPECT_STREQ("A,C,D,E", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("A,C,D,E", GetDisplayedCookies(&cookies_model).c_str());
// Left with root -> foo1 -> cookies -> a, foo3 -> cookies -> c,d,e
EXPECT_EQ(9, cookies_model.GetRoot()->GetTotalNodeCount());
@@ -788,57 +805,54 @@ 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_,
- false);
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://a.foo2.com"), "A=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo2.com"), "B=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://b.foo1.com"), "C=1");
- // Leading dot on the foo4
- mock_browsing_data_cookie_helper_->AddCookieSamples(
- GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://a.foo1.com"), "E=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo1.com"), "F=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo3.com"), "G=1");
- mock_browsing_data_cookie_helper_->
- AddCookieSamples(GURL("http://foo4.com"), "H=1");
- mock_browsing_data_cookie_helper_->Notify();
+ net::CookieMonster* monster = profile_->GetCookieMonster();
+ monster->SetCookie(GURL("http://a.foo2.com"), "A=1");
+ monster->SetCookie(GURL("http://foo2.com"), "B=1");
+ monster->SetCookie(GURL("http://b.foo1.com"), "C=1");
+ monster->SetCookie(GURL("http://foo4.com"), "D=1; domain=.foo4.com;"
+ " path=/;"); // Leading dot on the foo4
+ monster->SetCookie(GURL("http://a.foo1.com"), "E=1");
+ monster->SetCookie(GURL("http://foo1.com"), "F=1");
+ monster->SetCookie(GURL("http://foo3.com"), "G=1");
+ monster->SetCookie(GURL("http://foo4.com"), "H=1");
+
+ CookiesTreeModel cookies_model(monster,
+ new MockBrowsingDataDatabaseHelper(profile_.get()),
+ new MockBrowsingDataLocalStorageHelper(profile_.get()),
+ new MockBrowsingDataLocalStorageHelper(profile_.get()),
+ new MockBrowsingDataAppCacheHelper(profile_.get()),
+ new MockBrowsingDataIndexedDBHelper(profile_.get()),
+ new MockBrowsingDataFileSystemHelper(profile_.get()),
+ false);
{
SCOPED_TRACE("Initial State 8 cookies");
- EXPECT_EQ(23, cookies_model.GetRoot()->GetTotalNodeCount());
+ // CookieMonster orders cookies by pathlength, then by creation time.
+ // All paths are length 1.
+ EXPECT_STREQ("A,B,C,D,E,F,G,H", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("F,E,C,B,A,G,D,H",
GetDisplayedCookies(&cookies_model).c_str());
}
DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); // Delete "E"
{
+ EXPECT_STREQ("A,B,C,D,F,G,H", GetMonsterCookies(monster).c_str());
EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str());
}
}
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_,
- false);
- mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1");
- mock_browsing_data_cookie_helper_->Notify();
+ net::CookieMonster* monster = profile_->GetCookieMonster();
+ monster->SetCookie(host, "A=1");
+
+ CookiesTreeModel cookies_model(monster,
+ new MockBrowsingDataDatabaseHelper(profile_.get()),
+ new MockBrowsingDataLocalStorageHelper(profile_.get()),
+ new MockBrowsingDataLocalStorageHelper(profile_.get()),
+ new MockBrowsingDataAppCacheHelper(profile_.get()),
+ new MockBrowsingDataIndexedDBHelper(profile_.get()),
+ new MockBrowsingDataFileSystemHelper(profile_.get()),
+ false);
TestingProfile profile;
HostContentSettingsMap* content_settings =