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"); |
} |