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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/tab_helper.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/skia/include/core/SkBitmap.h"
9
10 namespace {
11
12 SkBitmap CreateSquareBitmapWithColor(int size, SkColor color) {
13 SkBitmap bitmap;
14 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size, size);
15 bitmap.allocPixels();
16 bitmap.eraseColor(color);
17 return bitmap;
18 }
19
20 void ValidateBitmapSizeAndColor(SkBitmap bitmap, int size, SkColor color) {
21 // Obtain pixel lock to access pixels.
22 SkAutoLockPixels lock(bitmap);
23 EXPECT_EQ(color, bitmap.getColor(0, 0));
24 EXPECT_EQ(size, bitmap.width());
25 EXPECT_EQ(size, bitmap.height());
26 }
27
28 class TabHelperTest : public testing::Test {
29 protected:
30 TabHelperTest() {
31 }
32
33 virtual ~TabHelperTest() {
34 }
35
36 private:
37 DISALLOW_COPY_AND_ASSIGN(TabHelperTest);
38 };
39
40 } // namespace
41
42 TEST_F(TabHelperTest, ConstrainBitmapsToSizes) {
43 std::set<int> desired_sizes;
44 desired_sizes.insert(16);
45 desired_sizes.insert(32);
46 desired_sizes.insert(128);
47 desired_sizes.insert(256);
48
49 {
50 std::vector<SkBitmap> bitmaps;
51 bitmaps.push_back(CreateSquareBitmapWithColor(16, SK_ColorRED));
52 bitmaps.push_back(CreateSquareBitmapWithColor(32, SK_ColorGREEN));
53 bitmaps.push_back(CreateSquareBitmapWithColor(48, SK_ColorBLUE));
54 bitmaps.push_back(CreateSquareBitmapWithColor(144, SK_ColorYELLOW));
55
56 std::vector<SkBitmap> results(
57 extensions::TabHelper::ConstrainBitmapsToSizes(bitmaps, desired_sizes));
58
59 EXPECT_EQ(3u, results.size());
60 ValidateBitmapSizeAndColor(results[0], 16, SK_ColorRED);
61 ValidateBitmapSizeAndColor(results[1], 32, SK_ColorGREEN);
62 ValidateBitmapSizeAndColor(results[2], 128, SK_ColorYELLOW);
63 }
64 {
65 std::vector<SkBitmap> bitmaps;
66 bitmaps.push_back(CreateSquareBitmapWithColor(512, SK_ColorRED));
67 bitmaps.push_back(CreateSquareBitmapWithColor(18, SK_ColorGREEN));
68 bitmaps.push_back(CreateSquareBitmapWithColor(33, SK_ColorBLUE));
69 bitmaps.push_back(CreateSquareBitmapWithColor(17, SK_ColorYELLOW));
70
71 std::vector<SkBitmap> results(
72 extensions::TabHelper::ConstrainBitmapsToSizes(bitmaps, desired_sizes));
73
74 EXPECT_EQ(3u, results.size());
75 ValidateBitmapSizeAndColor(results[0], 16, SK_ColorYELLOW);
76 ValidateBitmapSizeAndColor(results[1], 32, SK_ColorBLUE);
77 ValidateBitmapSizeAndColor(results[2], 256, SK_ColorRED);
78 }
79 }
OLDNEW
« 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