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

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: 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 static_cast<base::DictionaryValue*>(
114 NULL))); 114 deserializer.Deserialize(NULL, NULL).release()));
115 ASSERT_TRUE(manifest.get() != NULL); 115 ASSERT_TRUE(manifest.get() != NULL);
116 116
117 std::string error; 117 std::string error;
118 scoped_refptr<Extension> extension(Extension::Create( 118 scoped_refptr<Extension> extension(Extension::Create(
119 manifest_path.DirName(), Manifest::INVALID_LOCATION, *manifest.get(), 119 manifest_path.DirName(), Manifest::INVALID_LOCATION, *manifest.get(),
120 Extension::NO_FLAGS, &error)); 120 Extension::NO_FLAGS, &error));
121 ASSERT_TRUE(extension.get()); 121 ASSERT_TRUE(extension.get());
122 TestIconManager icon_manager(this); 122 TestIconManager icon_manager(this);
123 123
124 // Load the icon and grab the bitmap. 124 // Load the icon and grab the bitmap.
(...skipping 21 matching lines...) Expand all
146 scoped_ptr<Profile> profile(new TestingProfile()); 146 scoped_ptr<Profile> profile(new TestingProfile());
147 SkBitmap default_icon = GetDefaultIcon(); 147 SkBitmap default_icon = GetDefaultIcon();
148 148
149 base::FilePath test_dir; 149 base::FilePath test_dir;
150 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); 150 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
151 base::FilePath manifest_path = test_dir.AppendASCII( 151 base::FilePath manifest_path = test_dir.AppendASCII(
152 "extensions/file_manager/app.json"); 152 "extensions/file_manager/app.json");
153 153
154 JSONFileValueDeserializer deserializer(manifest_path); 154 JSONFileValueDeserializer deserializer(manifest_path);
155 scoped_ptr<base::DictionaryValue> manifest( 155 scoped_ptr<base::DictionaryValue> manifest(
156 static_cast<base::DictionaryValue*>(deserializer.Deserialize(NULL, 156 static_cast<base::DictionaryValue*>(
157 NULL))); 157 deserializer.Deserialize(NULL, NULL).release()));
158 ASSERT_TRUE(manifest.get() != NULL); 158 ASSERT_TRUE(manifest.get() != NULL);
159 159
160 std::string error; 160 std::string error;
161 scoped_refptr<Extension> extension(Extension::Create( 161 scoped_refptr<Extension> extension(Extension::Create(
162 manifest_path.DirName(), Manifest::COMPONENT, *manifest.get(), 162 manifest_path.DirName(), Manifest::COMPONENT, *manifest.get(),
163 Extension::NO_FLAGS, &error)); 163 Extension::NO_FLAGS, &error));
164 ASSERT_TRUE(extension.get()); 164 ASSERT_TRUE(extension.get());
165 165
166 TestIconManager icon_manager(this); 166 TestIconManager icon_manager(this);
167 // Load the icon and grab the bitmap. 167 // Load the icon and grab the bitmap.
168 icon_manager.LoadIcon(profile.get(), extension.get()); 168 icon_manager.LoadIcon(profile.get(), extension.get());
169 WaitForImageLoad(); 169 WaitForImageLoad();
170 SkBitmap first_icon = icon_manager.GetIcon(extension->id()); 170 SkBitmap first_icon = icon_manager.GetIcon(extension->id());
171 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon)); 171 EXPECT_FALSE(gfx::BitmapsAreEqual(first_icon, default_icon));
172 172
173 // Remove the icon from the manager. 173 // Remove the icon from the manager.
174 icon_manager.RemoveIcon(extension->id()); 174 icon_manager.RemoveIcon(extension->id());
175 175
176 // 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
177 // default icon). 177 // default icon).
178 icon_manager.LoadIcon(profile.get(), extension.get()); 178 icon_manager.LoadIcon(profile.get(), extension.get());
179 WaitForImageLoad(); 179 WaitForImageLoad();
180 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); 180 SkBitmap second_icon = icon_manager.GetIcon(extension->id());
181 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); 181 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon));
182 182
183 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); 183 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon));
184 } 184 }
185 #endif 185 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698