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

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

Issue 1394993004: Make ValueDeserializer::Deserialize return scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix and add todo about not failed trybot Created 5 years, 2 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
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/message_loop.h" 6 #include "base/message_loop/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"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 TEST_F(ExtensionIconManagerTest, LoadRemoveLoad) { 102 TEST_F(ExtensionIconManagerTest, LoadRemoveLoad) {
103 scoped_ptr<Profile> profile(new TestingProfile()); 103 scoped_ptr<Profile> profile(new TestingProfile());
104 SkBitmap default_icon = GetDefaultIcon(); 104 SkBitmap default_icon = GetDefaultIcon();
105 105
106 base::FilePath test_dir; 106 base::FilePath test_dir;
107 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); 107 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
108 base::FilePath manifest_path = test_dir.AppendASCII( 108 base::FilePath manifest_path = test_dir.AppendASCII(
109 "extensions/image_loading_tracker/app.json"); 109 "extensions/image_loading_tracker/app.json");
110 110
111 JSONFileValueDeserializer deserializer(manifest_path); 111 JSONFileValueDeserializer deserializer(manifest_path);
112 scoped_ptr<base::DictionaryValue> manifest( 112 scoped_ptr<base::DictionaryValue> manifest =
113 static_cast<base::DictionaryValue*>(deserializer.Deserialize(NULL, 113 base::DictionaryValue::From(deserializer.Deserialize(NULL, NULL));
114 NULL)));
115 ASSERT_TRUE(manifest.get() != NULL); 114 ASSERT_TRUE(manifest.get() != NULL);
116 115
117 std::string error; 116 std::string error;
118 scoped_refptr<Extension> extension(Extension::Create( 117 scoped_refptr<Extension> extension(Extension::Create(
119 manifest_path.DirName(), Manifest::INVALID_LOCATION, *manifest.get(), 118 manifest_path.DirName(), Manifest::INVALID_LOCATION, *manifest.get(),
120 Extension::NO_FLAGS, &error)); 119 Extension::NO_FLAGS, &error));
121 ASSERT_TRUE(extension.get()); 120 ASSERT_TRUE(extension.get());
122 TestIconManager icon_manager(this); 121 TestIconManager icon_manager(this);
123 122
124 // Load the icon and grab the bitmap. 123 // Load the icon and grab the bitmap.
(...skipping 20 matching lines...) Expand all
145 TEST_F(ExtensionIconManagerTest, LoadComponentExtensionResource) { 144 TEST_F(ExtensionIconManagerTest, LoadComponentExtensionResource) {
146 scoped_ptr<Profile> profile(new TestingProfile()); 145 scoped_ptr<Profile> profile(new TestingProfile());
147 SkBitmap default_icon = GetDefaultIcon(); 146 SkBitmap default_icon = GetDefaultIcon();
148 147
149 base::FilePath test_dir; 148 base::FilePath test_dir;
150 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); 149 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
151 base::FilePath manifest_path = test_dir.AppendASCII( 150 base::FilePath manifest_path = test_dir.AppendASCII(
152 "extensions/file_manager/app.json"); 151 "extensions/file_manager/app.json");
153 152
154 JSONFileValueDeserializer deserializer(manifest_path); 153 JSONFileValueDeserializer deserializer(manifest_path);
155 scoped_ptr<base::DictionaryValue> manifest( 154 scoped_ptr<base::DictionaryValue> manifest =
156 static_cast<base::DictionaryValue*>(deserializer.Deserialize(NULL, 155 base::DictionaryValue::From(deserializer.Deserialize(NULL, NULL));
157 NULL)));
158 ASSERT_TRUE(manifest.get() != NULL); 156 ASSERT_TRUE(manifest.get() != NULL);
159 157
160 std::string error; 158 std::string error;
161 scoped_refptr<Extension> extension(Extension::Create( 159 scoped_refptr<Extension> extension(Extension::Create(
162 manifest_path.DirName(), Manifest::COMPONENT, *manifest.get(), 160 manifest_path.DirName(), Manifest::COMPONENT, *manifest.get(),
163 Extension::NO_FLAGS, &error)); 161 Extension::NO_FLAGS, &error));
164 ASSERT_TRUE(extension.get()); 162 ASSERT_TRUE(extension.get());
165 163
166 TestIconManager icon_manager(this); 164 TestIconManager icon_manager(this);
167 // Load the icon and grab the bitmap. 165 // Load the icon and grab the bitmap.
168 icon_manager.LoadIcon(profile.get(), extension.get()); 166 icon_manager.LoadIcon(profile.get(), extension.get());
169 WaitForImageLoad(); 167 WaitForImageLoad();
170 SkBitmap first_icon = icon_manager.GetIcon(extension->id()); 168 SkBitmap first_icon = icon_manager.GetIcon(extension->id());
171 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon)); 169 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon));
172 170
173 // Remove the icon from the manager. 171 // Remove the icon from the manager.
174 icon_manager.RemoveIcon(extension->id()); 172 icon_manager.RemoveIcon(extension->id());
175 173
176 // 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
177 // default icon). 175 // default icon).
178 icon_manager.LoadIcon(profile.get(), extension.get()); 176 icon_manager.LoadIcon(profile.get(), extension.get());
179 WaitForImageLoad(); 177 WaitForImageLoad();
180 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); 178 SkBitmap second_icon = icon_manager.GetIcon(extension->id());
181 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); 179 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon));
182 180
183 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); 181 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon));
184 } 182 }
185 #endif 183 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698