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

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

Issue 382703002: Remove unused SQLLite tables from WebData (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 2 Created 6 years, 5 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_factory.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
deleted file mode 100644
index e8cf67246408fe657949c4500863041c07a6b4e4..0000000000000000000000000000000000000000
--- a/chrome/browser/webdata/web_apps_table_unittest.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/files/scoped_temp_dir.h"
-#include "base/path_service.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/time/time.h"
-#include "chrome/browser/webdata/web_apps_table.h"
-#include "components/webdata/common/web_database.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "url/gurl.h"
-
-using base::Time;
-
-class WebAppsTableTest : public testing::Test {
- public:
- WebAppsTableTest() {}
- virtual ~WebAppsTableTest() {}
-
- protected:
- 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_));
- }
-
- base::FilePath file_;
- base::ScopedTempDir temp_dir_;
- scoped_ptr<WebAppsTable> table_;
- scoped_ptr<WebDatabase> db_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WebAppsTableTest);
-};
-
-
-TEST_F(WebAppsTableTest, WebAppHasAllImages) {
- GURL url("http://google.com/");
-
- // Initial value for unknown web app should be false.
- EXPECT_FALSE(table_->GetWebAppHasAllImages(url));
-
- // Set the value and make sure it took.
- EXPECT_TRUE(table_->SetWebAppHasAllImages(url, true));
- EXPECT_TRUE(table_->GetWebAppHasAllImages(url));
-
- // Remove the app and make sure value reverts to default.
- EXPECT_TRUE(table_->RemoveWebApp(url));
- EXPECT_FALSE(table_->GetWebAppHasAllImages(url));
-}
-
-TEST_F(WebAppsTableTest, WebAppImages) {
- GURL url("http://google.com/");
-
- // Web app should initially have no images.
- std::vector<SkBitmap> images;
- ASSERT_TRUE(table_->GetWebAppImages(url, &images));
- ASSERT_EQ(0U, images.size());
-
- // Add an image.
- SkBitmap image;
- image.allocN32Pixels(16, 16);
- image.eraseColor(SK_ColorBLACK);
- ASSERT_TRUE(table_->SetWebAppImage(url, image));
-
- // Make sure we get the image back.
- ASSERT_TRUE(table_->GetWebAppImages(url, &images));
- ASSERT_EQ(1U, images.size());
- ASSERT_EQ(16, images[0].width());
- ASSERT_EQ(16, images[0].height());
-
- // Add another 16x16 image and make sure it replaces the original.
- image.allocN32Pixels(16, 16);
- image.eraseColor(SK_ColorBLACK);
-
- // Set some random pixels so that we can identify the image. We don't use
- // transparent images because of pre-multiplication rounding errors.
- SkColor test_pixel_1 = 0xffccbbaa;
- SkColor test_pixel_2 = 0xffaabbaa;
- SkColor test_pixel_3 = 0xff339966;
- image.getAddr32(0, 1)[0] = test_pixel_1;
- image.getAddr32(0, 1)[1] = test_pixel_2;
- image.getAddr32(0, 1)[2] = test_pixel_3;
-
- ASSERT_TRUE(table_->SetWebAppImage(url, image));
- images.clear();
- ASSERT_TRUE(table_->GetWebAppImages(url, &images));
- ASSERT_EQ(1U, images.size());
- ASSERT_EQ(16, images[0].width());
- ASSERT_EQ(16, images[0].height());
- images[0].lockPixels();
- ASSERT_TRUE(images[0].getPixels() != NULL);
- ASSERT_EQ(test_pixel_1, images[0].getAddr32(0, 1)[0]);
- ASSERT_EQ(test_pixel_2, images[0].getAddr32(0, 1)[1]);
- ASSERT_EQ(test_pixel_3, images[0].getAddr32(0, 1)[2]);
- images[0].unlockPixels();
-
- // Add another image at a bigger size.
- image.allocN32Pixels(32, 32);
- image.eraseColor(SK_ColorBLACK);
- ASSERT_TRUE(table_->SetWebAppImage(url, image));
-
- // Make sure we get both images back.
- images.clear();
- ASSERT_TRUE(table_->GetWebAppImages(url, &images));
- ASSERT_EQ(2U, images.size());
- if (images[0].width() == 16) {
- ASSERT_EQ(16, images[0].width());
- ASSERT_EQ(16, images[0].height());
- ASSERT_EQ(32, images[1].width());
- ASSERT_EQ(32, images[1].height());
- } else {
- ASSERT_EQ(32, images[0].width());
- ASSERT_EQ(32, images[0].height());
- ASSERT_EQ(16, images[1].width());
- ASSERT_EQ(16, images[1].height());
- }
-}
« no previous file with comments | « chrome/browser/webdata/web_apps_table.cc ('k') | chrome/browser/webdata/web_data_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698