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

Unified Diff: chrome/browser/webdata/web_apps_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/web_apps_table.cc ('k') | chrome/browser/webdata/web_data_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/webdata/web_apps_table_unittest.cc
diff --git a/chrome/browser/webdata/web_apps_table_unittest.cc b/chrome/browser/webdata/web_apps_table_unittest.cc
index 8d288bc5692413d7c3af7b7e12db7110da566170..6434f82e329a90a40e80ab30b14611bc47b1085f 100644
--- a/chrome/browser/webdata/web_apps_table_unittest.cc
+++ b/chrome/browser/webdata/web_apps_table_unittest.cc
@@ -25,10 +25,17 @@ class WebAppsTableTest : public testing::Test {
virtual void SetUp() {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
+
+ table_.reset(new WebAppsTable);
+ 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<WebAppsTable> table_;
+ scoped_ptr<WebDatabase> db_;
private:
DISALLOW_COPY_AND_ASSIGN(WebAppsTableTest);
@@ -36,32 +43,26 @@ class WebAppsTableTest : public testing::Test {
TEST_F(WebAppsTableTest, WebAppHasAllImages) {
- WebDatabase db;
-
- ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string()));
GURL url("http://google.com/");
// Initial value for unknown web app should be false.
- EXPECT_FALSE(db.GetWebAppsTable()->GetWebAppHasAllImages(url));
+ EXPECT_FALSE(table_->GetWebAppHasAllImages(url));
// Set the value and make sure it took.
- EXPECT_TRUE(db.GetWebAppsTable()->SetWebAppHasAllImages(url, true));
- EXPECT_TRUE(db.GetWebAppsTable()->GetWebAppHasAllImages(url));
+ EXPECT_TRUE(table_->SetWebAppHasAllImages(url, true));
+ EXPECT_TRUE(table_->GetWebAppHasAllImages(url));
// Remove the app and make sure value reverts to default.
- EXPECT_TRUE(db.GetWebAppsTable()->RemoveWebApp(url));
- EXPECT_FALSE(db.GetWebAppsTable()->GetWebAppHasAllImages(url));
+ EXPECT_TRUE(table_->RemoveWebApp(url));
+ EXPECT_FALSE(table_->GetWebAppHasAllImages(url));
}
TEST_F(WebAppsTableTest, WebAppImages) {
- WebDatabase db;
-
- ASSERT_EQ(sql::INIT_OK, db.Init(file_, std::string()));
GURL url("http://google.com/");
// Web app should initially have no images.
std::vector<SkBitmap> images;
- ASSERT_TRUE(db.GetWebAppsTable()->GetWebAppImages(url, &images));
+ ASSERT_TRUE(table_->GetWebAppImages(url, &images));
ASSERT_EQ(0U, images.size());
// Add an image.
@@ -69,10 +70,10 @@ TEST_F(WebAppsTableTest, WebAppImages) {
image.setConfig(SkBitmap::kARGB_8888_Config, 16, 16);
image.allocPixels();
image.eraseColor(SK_ColorBLACK);
- ASSERT_TRUE(db.GetWebAppsTable()->SetWebAppImage(url, image));
+ ASSERT_TRUE(table_->SetWebAppImage(url, image));
// Make sure we get the image back.
- ASSERT_TRUE(db.GetWebAppsTable()->GetWebAppImages(url, &images));
+ ASSERT_TRUE(table_->GetWebAppImages(url, &images));
ASSERT_EQ(1U, images.size());
ASSERT_EQ(16, images[0].width());
ASSERT_EQ(16, images[0].height());
@@ -91,9 +92,9 @@ TEST_F(WebAppsTableTest, WebAppImages) {
image.getAddr32(0, 1)[1] = test_pixel_2;
image.getAddr32(0, 1)[2] = test_pixel_3;
- ASSERT_TRUE(db.GetWebAppsTable()->SetWebAppImage(url, image));
+ ASSERT_TRUE(table_->SetWebAppImage(url, image));
images.clear();
- ASSERT_TRUE(db.GetWebAppsTable()->GetWebAppImages(url, &images));
+ ASSERT_TRUE(table_->GetWebAppImages(url, &images));
ASSERT_EQ(1U, images.size());
ASSERT_EQ(16, images[0].width());
ASSERT_EQ(16, images[0].height());
@@ -108,11 +109,11 @@ TEST_F(WebAppsTableTest, WebAppImages) {
image.setConfig(SkBitmap::kARGB_8888_Config, 32, 32);
image.allocPixels();
image.eraseColor(SK_ColorBLACK);
- ASSERT_TRUE(db.GetWebAppsTable()->SetWebAppImage(url, image));
+ ASSERT_TRUE(table_->SetWebAppImage(url, image));
// Make sure we get both images back.
images.clear();
- ASSERT_TRUE(db.GetWebAppsTable()->GetWebAppImages(url, &images));
+ ASSERT_TRUE(table_->GetWebAppImages(url, &images));
ASSERT_EQ(2U, images.size());
if (images[0].width() == 16) {
ASSERT_EQ(16, images[0].width());
« no previous file with comments | « chrome/browser/webdata/web_apps_table.cc ('k') | chrome/browser/webdata/web_data_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698