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

Unified Diff: chrome/browser/extensions/tab_helper_unittest.cc

Issue 105873009: Use apple-touch-icons for streamlined hosted apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nit Created 6 years, 11 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/extensions/tab_helper.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/tab_helper_unittest.cc
diff --git a/chrome/browser/extensions/tab_helper_unittest.cc b/chrome/browser/extensions/tab_helper_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..86778e04e4dade26c67f579a63d1be210b2c475d
--- /dev/null
+++ b/chrome/browser/extensions/tab_helper_unittest.cc
@@ -0,0 +1,79 @@
+// Copyright 2013 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 "chrome/browser/extensions/tab_helper.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+namespace {
+
+SkBitmap CreateSquareBitmapWithColor(int size, SkColor color) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, size, size);
+ bitmap.allocPixels();
+ bitmap.eraseColor(color);
+ return bitmap;
+}
+
+void ValidateBitmapSizeAndColor(SkBitmap bitmap, int size, SkColor color) {
+ // Obtain pixel lock to access pixels.
+ SkAutoLockPixels lock(bitmap);
+ EXPECT_EQ(color, bitmap.getColor(0, 0));
+ EXPECT_EQ(size, bitmap.width());
+ EXPECT_EQ(size, bitmap.height());
+}
+
+class TabHelperTest : public testing::Test {
+ protected:
+ TabHelperTest() {
+ }
+
+ virtual ~TabHelperTest() {
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TabHelperTest);
+};
+
+} // namespace
+
+TEST_F(TabHelperTest, ConstrainBitmapsToSizes) {
+ std::set<int> desired_sizes;
+ desired_sizes.insert(16);
+ desired_sizes.insert(32);
+ desired_sizes.insert(128);
+ desired_sizes.insert(256);
+
+ {
+ std::vector<SkBitmap> bitmaps;
+ bitmaps.push_back(CreateSquareBitmapWithColor(16, SK_ColorRED));
+ bitmaps.push_back(CreateSquareBitmapWithColor(32, SK_ColorGREEN));
+ bitmaps.push_back(CreateSquareBitmapWithColor(48, SK_ColorBLUE));
+ bitmaps.push_back(CreateSquareBitmapWithColor(144, SK_ColorYELLOW));
+
+ std::vector<SkBitmap> results(
+ extensions::TabHelper::ConstrainBitmapsToSizes(bitmaps, desired_sizes));
+
+ EXPECT_EQ(3u, results.size());
+ ValidateBitmapSizeAndColor(results[0], 16, SK_ColorRED);
+ ValidateBitmapSizeAndColor(results[1], 32, SK_ColorGREEN);
+ ValidateBitmapSizeAndColor(results[2], 128, SK_ColorYELLOW);
+ }
+ {
+ std::vector<SkBitmap> bitmaps;
+ bitmaps.push_back(CreateSquareBitmapWithColor(512, SK_ColorRED));
+ bitmaps.push_back(CreateSquareBitmapWithColor(18, SK_ColorGREEN));
+ bitmaps.push_back(CreateSquareBitmapWithColor(33, SK_ColorBLUE));
+ bitmaps.push_back(CreateSquareBitmapWithColor(17, SK_ColorYELLOW));
+
+ std::vector<SkBitmap> results(
+ extensions::TabHelper::ConstrainBitmapsToSizes(bitmaps, desired_sizes));
+
+ EXPECT_EQ(3u, results.size());
+ ValidateBitmapSizeAndColor(results[0], 16, SK_ColorYELLOW);
+ ValidateBitmapSizeAndColor(results[1], 32, SK_ColorBLUE);
+ ValidateBitmapSizeAndColor(results[2], 256, SK_ColorRED);
+ }
+}
« no previous file with comments | « chrome/browser/extensions/tab_helper.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698