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

Side by Side Diff: chrome/browser/extensions/extension_icon_manager_unittest.cc

Issue 12578008: Move CrxFile, FileReader, ExtensionResource to src/extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/json/json_file_value_serializer.h" 5 #include "base/json/json_file_value_serializer.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/extension_icon_manager.h" 9 #include "chrome/browser/extensions/extension_icon_manager.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
11 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_resource.h"
13 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h" 13 #include "content/public/test/test_browser_thread.h"
14 #include "extensions/common/id_util.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gfx/skia_util.h" 16 #include "ui/gfx/skia_util.h"
17 17
18 using content::BrowserThread; 18 using content::BrowserThread;
19 using extensions::Extension; 19 using extensions::Extension;
20 using extensions::Manifest; 20 using extensions::Manifest;
21 21
22 // Our test class that takes care of managing the necessary threads for loading 22 // Our test class that takes care of managing the necessary threads for loading
23 // extension icons, and waiting for those loads to happen. 23 // extension icons, and waiting for those loads to happen.
24 class ExtensionIconManagerTest : public testing::Test { 24 class ExtensionIconManagerTest : public testing::Test {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 private: 87 private:
88 ExtensionIconManagerTest* test_; 88 ExtensionIconManagerTest* test_;
89 89
90 DISALLOW_COPY_AND_ASSIGN(TestIconManager); 90 DISALLOW_COPY_AND_ASSIGN(TestIconManager);
91 }; 91 };
92 92
93 // Returns the default icon that ExtensionIconManager gives when an extension 93 // Returns the default icon that ExtensionIconManager gives when an extension
94 // doesn't have an icon. 94 // doesn't have an icon.
95 SkBitmap GetDefaultIcon() { 95 SkBitmap GetDefaultIcon() {
96 std::string dummy_id; 96 std::string dummy_id = extensions::id_util::GenerateId("whatever");
97 EXPECT_TRUE(Extension::GenerateId(std::string("whatever"), &dummy_id));
98 ExtensionIconManager manager; 97 ExtensionIconManager manager;
99 return manager.GetIcon(dummy_id); 98 return manager.GetIcon(dummy_id);
100 } 99 }
101 100
102 // Tests loading an icon for an extension, removing it, then re-loading it. 101 // Tests loading an icon for an extension, removing it, then re-loading it.
103 TEST_F(ExtensionIconManagerTest, LoadRemoveLoad) { 102 TEST_F(ExtensionIconManagerTest, LoadRemoveLoad) {
104 scoped_ptr<Profile> profile(new TestingProfile()); 103 scoped_ptr<Profile> profile(new TestingProfile());
105 SkBitmap default_icon = GetDefaultIcon(); 104 SkBitmap default_icon = GetDefaultIcon();
106 105
107 base::FilePath test_dir; 106 base::FilePath test_dir;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // Now re-load the icon - we should get the same result bitmap (and not the 174 // Now re-load the icon - we should get the same result bitmap (and not the
176 // default icon). 175 // default icon).
177 icon_manager.LoadIcon(profile.get(), extension.get()); 176 icon_manager.LoadIcon(profile.get(), extension.get());
178 WaitForImageLoad(); 177 WaitForImageLoad();
179 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); 178 SkBitmap second_icon = icon_manager.GetIcon(extension->id());
180 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); 179 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon));
181 180
182 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); 181 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon));
183 } 182 }
184 #endif 183 #endif
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_icon_manager.cc ('k') | chrome/browser/extensions/extension_install_prompt.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698