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

Unified Diff: chrome/common/extensions/extension_action_unittest.cc

Issue 10905005: Change browser/page action default icon defined in manifest to support hidpi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing test for icon factory; need to update comments in browser/ui/ Created 8 years, 3 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/common/extensions/extension_action.cc ('k') | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_action_unittest.cc
diff --git a/chrome/common/extensions/extension_action_unittest.cc b/chrome/common/extensions/extension_action_unittest.cc
index f34ab88a0ca604864090493067ee193d68a96d84..248a443169b95e5bedef2d4fb30979b82b4c3f6d 100644
--- a/chrome/common/extensions/extension_action_unittest.cc
+++ b/chrome/common/extensions/extension_action_unittest.cc
@@ -10,6 +10,7 @@
#include "chrome/common/extensions/extension_action.h"
#include "googleurl/src/gurl.h"
#include "grit/theme_resources.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/resource/resource_bundle.h"
@@ -17,28 +18,9 @@
#include "ui/gfx/skia_util.h"
#include "webkit/glue/image_decoder.h"
-namespace {
-
-bool ImagesAreEqual(const gfx::Image& i1, const gfx::Image& i2) {
- return gfx::BitmapsAreEqual(*i1.ToSkBitmap(), *i2.ToSkBitmap());
-}
-
-gfx::Image LoadIcon(const std::string& filename) {
- FilePath path;
- PathService::Get(chrome::DIR_TEST_DATA, &path);
- path = path.AppendASCII("extensions").AppendASCII(filename);
-
- std::string file_contents;
- file_util::ReadFileToString(path, &file_contents);
- const unsigned char* data =
- reinterpret_cast<const unsigned char*>(file_contents.data());
+using ::testing::Return;
- SkBitmap bitmap;
- webkit_glue::ImageDecoder decoder;
- bitmap = decoder.Decode(data, file_contents.length());
-
- return gfx::Image(bitmap);
-}
+namespace {
class ExtensionActionTest : public testing::Test {
public:
@@ -63,29 +45,6 @@ TEST_F(ExtensionActionTest, Title) {
ASSERT_EQ("baz", action.GetTitle(100));
}
-TEST_F(ExtensionActionTest, Icon) {
- gfx::Image puzzle_piece =
- ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- IDR_EXTENSIONS_FAVICON);
- gfx::Image icon1 = LoadIcon("icon1.png");
- gfx::Image icon2 = LoadIcon("icon2.png");
tbarzic 2012/09/14 22:24:17 this will be covered in extension_action_icon_fact
- ASSERT_TRUE(ImagesAreEqual(puzzle_piece, action.GetIcon(1)));
-
- action.set_default_icon_path("the_default.png");
- ASSERT_TRUE(ImagesAreEqual(puzzle_piece, action.GetIcon(1)))
- << "Still returns the puzzle piece because the image isn't loaded yet.";
- action.CacheIcon(icon2);
- ASSERT_TRUE(ImagesAreEqual(icon2, action.GetIcon(1)));
-
- action.SetIcon(ExtensionAction::kDefaultTabId, icon1);
- ASSERT_TRUE(ImagesAreEqual(icon1, action.GetIcon(100)))
- << "SetIcon(kDefaultTabId) overrides the default_icon_path.";
-
- action.SetIcon(100, icon2);
- ASSERT_TRUE(ImagesAreEqual(icon1, action.GetIcon(1)));
- ASSERT_TRUE(ImagesAreEqual(icon2, action.GetIcon(100)));
-}
-
TEST_F(ExtensionActionTest, Visibility) {
// Supports the icon animation.
MessageLoop message_loop;
« no previous file with comments | « chrome/common/extensions/extension_action.cc ('k') | chrome/common/extensions/extension_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698