Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8428)

Unified Diff: chrome/browser/webdata/token_service_table_unittest.cc

Issue 12543034: Move creation of the various WebDatabaseTable types out of WebDatabase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows release builds (COMDAT folding combined static functions being used for keys. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/webdata/token_service_table.cc ('k') | chrome/browser/webdata/web_apps_table.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/token_service_table_unittest.cc
diff --git a/chrome/browser/webdata/token_service_table_unittest.cc b/chrome/browser/webdata/token_service_table_unittest.cc
index d7fec29ed0210c4a23ddd19b7f8882306e1305fb..3676b9b849a49e45ad642ba9f93031fae783393f 100644
--- a/chrome/browser/webdata/token_service_table_unittest.cc
+++ b/chrome/browser/webdata/token_service_table_unittest.cc
@@ -23,73 +23,71 @@ class TokenServiceTableTest : public testing::Test {
virtual void SetUp() {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
+
+ table_.reset(new TokenServiceTable);
+ db_.reset(new WebDatabase);
+ db_->AddTable(table_.get());
+ ASSERT_EQ(sql::INIT_OK, db_->Init(file_, std::string()));
}
base::FilePath file_;
base::ScopedTempDir temp_dir_;
-
+ scoped_ptr<TokenServiceTable> table_;
+ scoped_ptr<WebDatabase> db_;
private:
DISALLOW_COPY_AND_ASSIGN(TokenServiceTableTest);
};
TEST_F(TokenServiceTableTest, TokenServiceGetAllRemoveAll) {
- WebDatabase db;
- ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string()));
-
std::map<std::string, std::string> out_map;
std::string service;
std::string service2;
service = "testservice";
service2 = "othertestservice";
- EXPECT_TRUE(db.GetTokenServiceTable()->GetAllTokens(&out_map));
+ EXPECT_TRUE(table_->GetAllTokens(&out_map));
EXPECT_TRUE(out_map.empty());
// Check that get all tokens works
- EXPECT_TRUE(db.GetTokenServiceTable()->SetTokenForService(service,
- "pepperoni"));
- EXPECT_TRUE(db.GetTokenServiceTable()->SetTokenForService(service2, "steak"));
- EXPECT_TRUE(db.GetTokenServiceTable()->GetAllTokens(&out_map));
+ EXPECT_TRUE(table_->SetTokenForService(service, "pepperoni"));
+ EXPECT_TRUE(table_->SetTokenForService(service2, "steak"));
+ EXPECT_TRUE(table_->GetAllTokens(&out_map));
EXPECT_EQ(out_map.find(service)->second, "pepperoni");
EXPECT_EQ(out_map.find(service2)->second, "steak");
out_map.clear();
// Purge
- EXPECT_TRUE(db.GetTokenServiceTable()->RemoveAllTokens());
- EXPECT_TRUE(db.GetTokenServiceTable()->GetAllTokens(&out_map));
+ EXPECT_TRUE(table_->RemoveAllTokens());
+ EXPECT_TRUE(table_->GetAllTokens(&out_map));
EXPECT_TRUE(out_map.empty());
// Check that you can still add it back in
- EXPECT_TRUE(db.GetTokenServiceTable()->SetTokenForService(service, "cheese"));
- EXPECT_TRUE(db.GetTokenServiceTable()->GetAllTokens(&out_map));
+ EXPECT_TRUE(table_->SetTokenForService(service, "cheese"));
+ EXPECT_TRUE(table_->GetAllTokens(&out_map));
EXPECT_EQ(out_map.find(service)->second, "cheese");
}
TEST_F(TokenServiceTableTest, TokenServiceGetSet) {
- WebDatabase db;
- ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string()));
-
std::map<std::string, std::string> out_map;
std::string service;
service = "testservice";
- EXPECT_TRUE(db.GetTokenServiceTable()->GetAllTokens(&out_map));
+ EXPECT_TRUE(table_->GetAllTokens(&out_map));
EXPECT_TRUE(out_map.empty());
- EXPECT_TRUE(db.GetTokenServiceTable()->SetTokenForService(service,
- "pepperoni"));
- EXPECT_TRUE(db.GetTokenServiceTable()->GetAllTokens(&out_map));
+ EXPECT_TRUE(table_->SetTokenForService(service, "pepperoni"));
+ EXPECT_TRUE(table_->GetAllTokens(&out_map));
EXPECT_EQ(out_map.find(service)->second, "pepperoni");
out_map.clear();
// try blanking it - won't remove it from the db though!
- EXPECT_TRUE(db.GetTokenServiceTable()->SetTokenForService(service, ""));
- EXPECT_TRUE(db.GetTokenServiceTable()->GetAllTokens(&out_map));
+ EXPECT_TRUE(table_->SetTokenForService(service, ""));
+ EXPECT_TRUE(table_->GetAllTokens(&out_map));
EXPECT_EQ(out_map.find(service)->second, "");
out_map.clear();
// try mutating it
- EXPECT_TRUE(db.GetTokenServiceTable()->SetTokenForService(service, "ham"));
- EXPECT_TRUE(db.GetTokenServiceTable()->GetAllTokens(&out_map));
+ EXPECT_TRUE(table_->SetTokenForService(service, "ham"));
+ EXPECT_TRUE(table_->GetAllTokens(&out_map));
EXPECT_EQ(out_map.find(service)->second, "ham");
}
« no previous file with comments | « chrome/browser/webdata/token_service_table.cc ('k') | chrome/browser/webdata/web_apps_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698