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

Side by Side Diff: extensions/browser/image_loader_unittest.cc

Issue 1909773002: Convert //extensions/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/image_loader.h" 5 #include "extensions/browser/image_loader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 base::FilePath extension_dir; 79 base::FilePath extension_dir;
80 if (!PathService::Get(DIR_TEST_DATA, &extension_dir)) { 80 if (!PathService::Get(DIR_TEST_DATA, &extension_dir)) {
81 EXPECT_FALSE(true); 81 EXPECT_FALSE(true);
82 return NULL; 82 return NULL;
83 } 83 }
84 extension_dir = extension_dir.AppendASCII(dir_name); 84 extension_dir = extension_dir.AppendASCII(dir_name);
85 int error_code = 0; 85 int error_code = 0;
86 std::string error; 86 std::string error;
87 JSONFileValueDeserializer deserializer( 87 JSONFileValueDeserializer deserializer(
88 extension_dir.AppendASCII("manifest.json")); 88 extension_dir.AppendASCII("manifest.json"));
89 scoped_ptr<base::DictionaryValue> valid_value = base::DictionaryValue::From( 89 std::unique_ptr<base::DictionaryValue> valid_value =
90 deserializer.Deserialize(&error_code, &error)); 90 base::DictionaryValue::From(
91 deserializer.Deserialize(&error_code, &error));
91 EXPECT_EQ(0, error_code) << error; 92 EXPECT_EQ(0, error_code) << error;
92 if (error_code != 0) 93 if (error_code != 0)
93 return NULL; 94 return NULL;
94 95
95 EXPECT_TRUE(valid_value.get()); 96 EXPECT_TRUE(valid_value.get());
96 if (!valid_value) 97 if (!valid_value)
97 return NULL; 98 return NULL;
98 99
99 return Extension::Create( 100 return Extension::Create(
100 extension_dir, location, *valid_value, Extension::NO_FLAGS, &error); 101 extension_dir, location, *valid_value, Extension::NO_FLAGS, &error);
101 } 102 }
102 103
103 gfx::Image image_; 104 gfx::Image image_;
104 gfx::ImageFamily image_family_; 105 gfx::ImageFamily image_family_;
105 106
106 private: 107 private:
107 void SetUp() override { 108 void SetUp() override {
108 testing::Test::SetUp(); 109 testing::Test::SetUp();
109 file_thread_.Start(); 110 file_thread_.Start();
110 io_thread_.Start(); 111 io_thread_.Start();
111 } 112 }
112 113
113 int image_loaded_count_; 114 int image_loaded_count_;
114 bool quit_in_image_loaded_; 115 bool quit_in_image_loaded_;
115 base::MessageLoop ui_loop_; 116 base::MessageLoop ui_loop_;
116 content::TestBrowserThread ui_thread_; 117 content::TestBrowserThread ui_thread_;
117 content::TestBrowserThread file_thread_; 118 content::TestBrowserThread file_thread_;
118 content::TestBrowserThread io_thread_; 119 content::TestBrowserThread io_thread_;
119 scoped_ptr<NotificationService> notification_service_; 120 std::unique_ptr<NotificationService> notification_service_;
120 }; 121 };
121 122
122 // Tests loading an image works correctly. 123 // Tests loading an image works correctly.
123 TEST_F(ImageLoaderTest, LoadImage) { 124 TEST_F(ImageLoaderTest, LoadImage) {
124 scoped_refptr<Extension> extension( 125 scoped_refptr<Extension> extension(
125 CreateExtension("image_loader", Manifest::INVALID_LOCATION)); 126 CreateExtension("image_loader", Manifest::INVALID_LOCATION));
126 ASSERT_TRUE(extension.get() != NULL); 127 ASSERT_TRUE(extension.get() != NULL);
127 128
128 ExtensionResource image_resource = 129 ExtensionResource image_resource =
129 IconsInfo::GetIconResource(extension.get(), 130 IconsInfo::GetIconResource(extension.get(),
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 305
305 const gfx::ImageSkiaRep* img_rep1 = &image_reps[0]; 306 const gfx::ImageSkiaRep* img_rep1 = &image_reps[0];
306 const gfx::ImageSkiaRep* img_rep2 = &image_reps[1]; 307 const gfx::ImageSkiaRep* img_rep2 = &image_reps[1];
307 EXPECT_EQ(extension_misc::EXTENSION_ICON_BITTY, img_rep1->pixel_width()); 308 EXPECT_EQ(extension_misc::EXTENSION_ICON_BITTY, img_rep1->pixel_width());
308 EXPECT_EQ(1.0f, img_rep1->scale()); 309 EXPECT_EQ(1.0f, img_rep1->scale());
309 EXPECT_EQ(extension_misc::EXTENSION_ICON_SMALLISH, img_rep2->pixel_width()); 310 EXPECT_EQ(extension_misc::EXTENSION_ICON_SMALLISH, img_rep2->pixel_width());
310 EXPECT_EQ(2.0f, img_rep2->scale()); 311 EXPECT_EQ(2.0f, img_rep2->scale());
311 } 312 }
312 313
313 } // namespace extensions 314 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/web_view/web_view_permission_helper.cc ('k') | extensions/browser/info_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698