OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/manifest/manifest_icon_downloader.h" | 5 #include "chrome/browser/manifest/manifest_icon_downloader.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 TEST_F(ManifestIconDownloaderTest, MixedCanReturnMiddle) { | 107 TEST_F(ManifestIconDownloaderTest, MixedCanReturnMiddle) { |
108 std::vector<SkBitmap> bitmaps; | 108 std::vector<SkBitmap> bitmaps; |
109 bitmaps.push_back(CreateDummyBitmap(10, 10)); | 109 bitmaps.push_back(CreateDummyBitmap(10, 10)); |
110 bitmaps.push_back(CreateDummyBitmap(8, 8)); | 110 bitmaps.push_back(CreateDummyBitmap(8, 8)); |
111 bitmaps.push_back(CreateDummyBitmap(6, 6)); | 111 bitmaps.push_back(CreateDummyBitmap(6, 6)); |
112 | 112 |
113 ASSERT_EQ(1, FindBitmap(7, 0, bitmaps)); | 113 ASSERT_EQ(1, FindBitmap(7, 0, bitmaps)); |
114 } | 114 } |
115 | 115 |
116 TEST_F(ManifestIconDownloaderTest, NonSquareIsIgnored) { | 116 TEST_F(ManifestIconDownloaderTest, SquareIsPickedOverNonSquare) { |
117 std::vector<SkBitmap> bitmaps; | 117 std::vector<SkBitmap> bitmaps; |
118 bitmaps.push_back(CreateDummyBitmap(15, 10)); | 118 bitmaps.push_back(CreateDummyBitmap(5, 5)); |
119 bitmaps.push_back(CreateDummyBitmap(10, 15)); | 119 bitmaps.push_back(CreateDummyBitmap(10, 15)); |
120 | 120 |
121 ASSERT_EQ(-1, FindBitmap(15, 0, bitmaps)); | 121 ASSERT_EQ(0, FindBitmap(15, 5, bitmaps)); |
122 ASSERT_EQ(-1, FindBitmap(10, 0, bitmaps)); | 122 ASSERT_EQ(0, FindBitmap(10, 5, bitmaps)); |
123 } | 123 } |
| 124 |
| 125 TEST_F(ManifestIconDownloaderTest, MostSquareNonSquareIsPicked) { |
| 126 std::vector<SkBitmap> bitmaps; |
| 127 bitmaps.push_back(CreateDummyBitmap(25, 35)); |
| 128 bitmaps.push_back(CreateDummyBitmap(10, 15)); |
| 129 |
| 130 ASSERT_EQ(1, FindBitmap(25, 0, bitmaps)); |
| 131 ASSERT_EQ(1, FindBitmap(35, 0, bitmaps)); |
| 132 } |
| 133 |
| 134 TEST_F(ManifestIconDownloaderTest, NonSquareBelowMinimumIsNotPicked) { |
| 135 std::vector<SkBitmap> bitmaps; |
| 136 bitmaps.push_back(CreateDummyBitmap(10, 15)); |
| 137 bitmaps.push_back(CreateDummyBitmap(15, 10)); |
| 138 |
| 139 ASSERT_EQ(-1, FindBitmap(15, 11, bitmaps)); |
| 140 } |
OLD | NEW |