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

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

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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" 12 #include "chrome/common/extensions/extension_resource.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.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 21
21 // 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
22 // extension icons, and waiting for those loads to happen. 23 // extension icons, and waiting for those loads to happen.
23 class ExtensionIconManagerTest : public testing::Test { 24 class ExtensionIconManagerTest : public testing::Test {
24 public: 25 public:
25 ExtensionIconManagerTest() : 26 ExtensionIconManagerTest() :
26 unwaited_image_loads_(0), 27 unwaited_image_loads_(0),
27 waiting_(false), 28 waiting_(false),
28 ui_thread_(BrowserThread::UI, &ui_loop_), 29 ui_thread_(BrowserThread::UI, &ui_loop_),
29 file_thread_(BrowserThread::FILE), 30 file_thread_(BrowserThread::FILE),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 FilePath manifest_path = test_dir.AppendASCII( 110 FilePath manifest_path = test_dir.AppendASCII(
110 "extensions/image_loading_tracker/app.json"); 111 "extensions/image_loading_tracker/app.json");
111 112
112 JSONFileValueSerializer serializer(manifest_path); 113 JSONFileValueSerializer serializer(manifest_path);
113 scoped_ptr<DictionaryValue> manifest( 114 scoped_ptr<DictionaryValue> manifest(
114 static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL))); 115 static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL)));
115 ASSERT_TRUE(manifest.get() != NULL); 116 ASSERT_TRUE(manifest.get() != NULL);
116 117
117 std::string error; 118 std::string error;
118 scoped_refptr<Extension> extension(Extension::Create( 119 scoped_refptr<Extension> extension(Extension::Create(
119 manifest_path.DirName(), Extension::INVALID, *manifest.get(), 120 manifest_path.DirName(), Manifest::INVALID_LOCATION, *manifest.get(),
120 Extension::NO_FLAGS, &error)); 121 Extension::NO_FLAGS, &error));
121 ASSERT_TRUE(extension.get()); 122 ASSERT_TRUE(extension.get());
122 TestIconManager icon_manager(this); 123 TestIconManager icon_manager(this);
123 124
124 // Load the icon and grab the bitmap. 125 // Load the icon and grab the bitmap.
125 icon_manager.LoadIcon(profile.get(), extension.get()); 126 icon_manager.LoadIcon(profile.get(), extension.get());
126 WaitForImageLoad(); 127 WaitForImageLoad();
127 SkBitmap first_icon = icon_manager.GetIcon(extension->id()); 128 SkBitmap first_icon = icon_manager.GetIcon(extension->id());
128 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon)); 129 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon));
129 130
(...skipping 20 matching lines...) Expand all
150 FilePath manifest_path = test_dir.AppendASCII( 151 FilePath manifest_path = test_dir.AppendASCII(
151 "extensions/file_manager/app.json"); 152 "extensions/file_manager/app.json");
152 153
153 JSONFileValueSerializer serializer(manifest_path); 154 JSONFileValueSerializer serializer(manifest_path);
154 scoped_ptr<DictionaryValue> manifest( 155 scoped_ptr<DictionaryValue> manifest(
155 static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL))); 156 static_cast<DictionaryValue*>(serializer.Deserialize(NULL, NULL)));
156 ASSERT_TRUE(manifest.get() != NULL); 157 ASSERT_TRUE(manifest.get() != NULL);
157 158
158 std::string error; 159 std::string error;
159 scoped_refptr<Extension> extension(Extension::Create( 160 scoped_refptr<Extension> extension(Extension::Create(
160 manifest_path.DirName(), Extension::COMPONENT, *manifest.get(), 161 manifest_path.DirName(), Manifest::COMPONENT, *manifest.get(),
161 Extension::NO_FLAGS, &error)); 162 Extension::NO_FLAGS, &error));
162 ASSERT_TRUE(extension.get()); 163 ASSERT_TRUE(extension.get());
163 164
164 scoped_ptr<Profile> profile(new TestingProfile()); 165 scoped_ptr<Profile> profile(new TestingProfile());
165 TestIconManager icon_manager(this); 166 TestIconManager icon_manager(this);
166 // Load the icon and grab the bitmap. 167 // Load the icon and grab the bitmap.
167 icon_manager.LoadIcon(profile.get(), extension.get()); 168 icon_manager.LoadIcon(profile.get(), extension.get());
168 WaitForImageLoad(); 169 WaitForImageLoad();
169 SkBitmap first_icon = icon_manager.GetIcon(extension->id()); 170 SkBitmap first_icon = icon_manager.GetIcon(extension->id());
170 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon)); 171 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon));
171 172
172 // Remove the icon from the manager. 173 // Remove the icon from the manager.
173 icon_manager.RemoveIcon(extension->id()); 174 icon_manager.RemoveIcon(extension->id());
174 175
175 // Now re-load the icon - we should get the same result bitmap (and not the 176 // Now re-load the icon - we should get the same result bitmap (and not the
176 // default icon). 177 // default icon).
177 icon_manager.LoadIcon(profile.get(), extension.get()); 178 icon_manager.LoadIcon(profile.get(), extension.get());
178 WaitForImageLoad(); 179 WaitForImageLoad();
179 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); 180 SkBitmap second_icon = icon_manager.GetIcon(extension->id());
180 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); 181 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon));
181 182
182 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); 183 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon));
183 } 184 }
184 #endif 185 #endif
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_icon_image_unittest.cc ('k') | chrome/browser/extensions/extension_info_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698