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

Unified Diff: chrome/browser/manifest/manifest_icon_downloader_unittest.cc

Issue 2933743002: Move chrome/browser/manifest to content/browser. (Closed)
Patch Set: rebased Created 3 years, 6 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
Index: chrome/browser/manifest/manifest_icon_downloader_unittest.cc
diff --git a/chrome/browser/manifest/manifest_icon_downloader_unittest.cc b/chrome/browser/manifest/manifest_icon_downloader_unittest.cc
deleted file mode 100644
index 88350957b4ca95ac73fee21473a3d7a989b6bceb..0000000000000000000000000000000000000000
--- a/chrome/browser/manifest/manifest_icon_downloader_unittest.cc
+++ /dev/null
@@ -1,142 +0,0 @@
-// Copyright 2015 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/manifest/manifest_icon_downloader.h"
-
-#include <string>
-#include <vector>
-
-#include "base/macros.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-class ManifestIconDownloaderTest : public testing::Test {
- protected:
- ManifestIconDownloaderTest() = default;
- ~ManifestIconDownloaderTest() override = default;
-
- int FindBitmap(const int ideal_icon_size_in_px,
- const int minimum_icon_size_in_px,
- const std::vector<SkBitmap>& bitmaps) {
- return ManifestIconDownloader::FindClosestBitmapIndex(
- ideal_icon_size_in_px, minimum_icon_size_in_px, bitmaps);
- }
-
- SkBitmap CreateDummyBitmap(int width, int height) {
- SkBitmap bitmap;
- bitmap.allocN32Pixels(width, height);
- bitmap.setImmutable();
- return bitmap;
- }
-
- DISALLOW_COPY_AND_ASSIGN(ManifestIconDownloaderTest);
-};
-
-TEST_F(ManifestIconDownloaderTest, NoIcons) {
- ASSERT_EQ(-1, FindBitmap(0, 0, std::vector<SkBitmap>()));
-}
-
-TEST_F(ManifestIconDownloaderTest, ExactIsChosen) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(10, 10));
-
- ASSERT_EQ(0, FindBitmap(10, 0, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, BiggerIsChosen) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(20, 20));
-
- ASSERT_EQ(0, FindBitmap(10, 0, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, SmallerBelowMinimumIsIgnored) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(10, 10));
-
- ASSERT_EQ(-1, FindBitmap(20, 15, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, SmallerAboveMinimumIsChosen) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(15, 15));
-
- ASSERT_EQ(0, FindBitmap(20, 15, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, ExactIsPreferredOverBigger) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(20, 20));
- bitmaps.push_back(CreateDummyBitmap(10, 10));
-
- ASSERT_EQ(1, FindBitmap(10, 0, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, ExactIsPreferredOverSmaller) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(20, 20));
- bitmaps.push_back(CreateDummyBitmap(10, 10));
-
- ASSERT_EQ(0, FindBitmap(20, 0, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, BiggerIsPreferredOverCloserSmaller) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(20, 20));
- bitmaps.push_back(CreateDummyBitmap(10, 10));
-
- ASSERT_EQ(0, FindBitmap(11, 0, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, ClosestToExactIsChosen) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(25, 25));
- bitmaps.push_back(CreateDummyBitmap(20, 20));
-
- ASSERT_EQ(1, FindBitmap(10, 0, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, MixedReturnsBiggestClosest) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(10, 10));
- bitmaps.push_back(CreateDummyBitmap(8, 8));
- bitmaps.push_back(CreateDummyBitmap(6, 6));
-
- ASSERT_EQ(0, FindBitmap(9, 0, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, MixedCanReturnMiddle) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(10, 10));
- bitmaps.push_back(CreateDummyBitmap(8, 8));
- bitmaps.push_back(CreateDummyBitmap(6, 6));
-
- ASSERT_EQ(1, FindBitmap(7, 0, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, SquareIsPickedOverNonSquare) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(5, 5));
- bitmaps.push_back(CreateDummyBitmap(10, 15));
-
- ASSERT_EQ(0, FindBitmap(15, 5, bitmaps));
- ASSERT_EQ(0, FindBitmap(10, 5, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, MostSquareNonSquareIsPicked) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(25, 35));
- bitmaps.push_back(CreateDummyBitmap(10, 11));
-
- ASSERT_EQ(1, FindBitmap(25, 0, bitmaps));
- ASSERT_EQ(1, FindBitmap(35, 0, bitmaps));
-}
-
-TEST_F(ManifestIconDownloaderTest, NonSquareBelowMinimumIsNotPicked) {
- std::vector<SkBitmap> bitmaps;
- bitmaps.push_back(CreateDummyBitmap(10, 15));
- bitmaps.push_back(CreateDummyBitmap(15, 10));
-
- ASSERT_EQ(-1, FindBitmap(15, 11, bitmaps));
-}
« no previous file with comments | « chrome/browser/manifest/manifest_icon_downloader.cc ('k') | chrome/browser/manifest/manifest_icon_selector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698