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

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

Issue 10701087: chromeos: Fix pixelated icons in app list and launcher (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for comments in #3, add an ImageSource and makes ImageLoadingTracker auto load image for additional… Created 8 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
Index: chrome/browser/extensions/image_loading_tracker_unittest.cc
diff --git a/chrome/browser/extensions/image_loading_tracker_unittest.cc b/chrome/browser/extensions/image_loading_tracker_unittest.cc
index 54d1958ec2f4e69cce927653e45a256b299c7c6c..b174c1bc4682ced6a8d94a2c1d92ed7102647fa6 100644
--- a/chrome/browser/extensions/image_loading_tracker_unittest.cc
+++ b/chrome/browser/extensions/image_loading_tracker_unittest.cc
@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/extensions/image_loading_tracker.h"
+
+#include <algorithm>
+
#include "base/json/json_file_value_serializer.h"
#include "base/message_loop.h"
#include "base/path_service.h"
-#include "chrome/browser/extensions/image_loading_tracker.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension.h"
@@ -204,7 +207,7 @@ TEST_F(ImageLoadingTrackerTest, MultipleImages) {
ExtensionResource resource =
extension->GetIconResource(sizes[i], ExtensionIconSet::MATCH_EXACTLY);
info_list.push_back(ImageLoadingTracker::ImageInfo(
- resource, gfx::Size(sizes[i], sizes[i])));
+ resource, gfx::Size(sizes[i], sizes[i]), ui::SCALE_FACTOR_NONE));
}
ImageLoadingTracker loader(this);
@@ -253,3 +256,44 @@ TEST_F(ImageLoadingTrackerTest, IsComponentExtensionResource) {
ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id);
#endif
}
+
+// Tests loading image that supports DIP.
+TEST_F(ImageLoadingTrackerTest, LoadImageInDIP) {
+ scoped_refptr<Extension> extension(CreateExtension(
+ "image_loading_tracker", Extension::INVALID));
+ ASSERT_TRUE(extension.get() != NULL);
+
+ ImageLoadingTracker loader(this);
+ loader.LoadImageInDIP(extension,
+ ExtensionIconSet::EXTENSION_ICON_BITTY,
+ ExtensionIconSet::MATCH_SMALLER,
+ gfx::Size(ExtensionIconSet::EXTENSION_ICON_BITTY,
+ ExtensionIconSet::EXTENSION_ICON_BITTY),
+ ImageLoadingTracker::DONT_CACHE);
+
+ EXPECT_EQ(0, image_loaded_count());
+ WaitForImageLoad();
+ EXPECT_EQ(1, image_loaded_count());
+
+ std::vector<gfx::ImageSkiaRep> image_reps =
+ image_.ToImageSkia()->image_reps();
+ ASSERT_EQ(1u, image_reps.size());
+ EXPECT_EQ(ui::SCALE_FACTOR_200P, image_reps[0].scale_factor());
+ EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_SMALLISH,
+ image_reps[0].pixel_width());
+
+ // Nows, asks image for a different scale factor.
+ image_.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P);
+ WaitForImageLoad();
+ EXPECT_EQ(1, image_loaded_count());
+
+ image_reps = image_.ToImageSkia()->image_reps();
+ // TODO(xiyaun): Uncomment the following after peter's CL that keeps
+ // only one representation for one scale factor change is in.
+ // ASSERT_EQ(2u, image_reps.size());
+ gfx::ImageSkiaRep image_rep =
+ image_.ToImageSkia()->GetRepresentation(ui::SCALE_FACTOR_100P);
+ EXPECT_EQ(ExtensionIconSet::EXTENSION_ICON_BITTY,
+ image_rep.pixel_width());
+}
+

Powered by Google App Engine
This is Rietveld 408576698