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

Side by Side Diff: extensions/common/file_util_unittest.cc

Issue 2152373003: [Extensions] Code Cleanup - Remove redundant smart-ptr get()s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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
« no previous file with comments | « chrome/common/extensions/permissions/permission_set_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/file_util.h" 5 #include "extensions/common/file_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 const std::string& manifest_value, 46 const std::string& manifest_value,
47 const base::FilePath& manifest_dir, 47 const base::FilePath& manifest_dir,
48 Manifest::Location location, 48 Manifest::Location location,
49 int extra_flags, 49 int extra_flags,
50 std::string* error) { 50 std::string* error) {
51 JSONStringValueDeserializer deserializer(manifest_value); 51 JSONStringValueDeserializer deserializer(manifest_value);
52 std::unique_ptr<base::Value> result = deserializer.Deserialize(NULL, error); 52 std::unique_ptr<base::Value> result = deserializer.Deserialize(NULL, error);
53 if (!result.get()) 53 if (!result.get())
54 return NULL; 54 return NULL;
55 CHECK_EQ(base::Value::TYPE_DICTIONARY, result->GetType()); 55 CHECK_EQ(base::Value::TYPE_DICTIONARY, result->GetType());
56 return LoadExtensionManifest( 56 return LoadExtensionManifest(*base::DictionaryValue::From(std::move(result)),
57 *base::DictionaryValue::From(std::move(result)).get(), manifest_dir, 57 manifest_dir, location, extra_flags, error);
58 location, extra_flags, error);
59 } 58 }
60 59
61 } // namespace 60 } // namespace
62 61
63 typedef testing::Test FileUtilTest; 62 typedef testing::Test FileUtilTest;
64 63
65 TEST_F(FileUtilTest, InstallUninstallGarbageCollect) { 64 TEST_F(FileUtilTest, InstallUninstallGarbageCollect) {
66 base::ScopedTempDir temp; 65 base::ScopedTempDir temp;
67 ASSERT_TRUE(temp.CreateUniqueTempDir()); 66 ASSERT_TRUE(temp.CreateUniqueTempDir());
68 67
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 value->SetString("name", "test"); 287 value->SetString("name", "test");
289 value->SetString("version", "1"); 288 value->SetString("version", "1");
290 value->SetInteger("manifest_version", 1); 289 value->SetInteger("manifest_version", 1);
291 290
292 base::ListValue* scripts = new base::ListValue(); 291 base::ListValue* scripts = new base::ListValue();
293 scripts->AppendString("foo.js"); 292 scripts->AppendString("foo.js");
294 value->Set("background.scripts", scripts); 293 value->Set("background.scripts", scripts);
295 294
296 std::string error; 295 std::string error;
297 std::vector<extensions::InstallWarning> warnings; 296 std::vector<extensions::InstallWarning> warnings;
298 scoped_refptr<Extension> extension = LoadExtensionManifest( 297 scoped_refptr<Extension> extension =
299 *value.get(), temp.path(), Manifest::UNPACKED, 0, &error); 298 LoadExtensionManifest(*value, temp.path(), Manifest::UNPACKED, 0, &error);
300 ASSERT_TRUE(extension.get()) << error; 299 ASSERT_TRUE(extension.get()) << error;
301 300
302 EXPECT_FALSE( 301 EXPECT_FALSE(
303 file_util::ValidateExtension(extension.get(), &error, &warnings)); 302 file_util::ValidateExtension(extension.get(), &error, &warnings));
304 EXPECT_EQ( 303 EXPECT_EQ(
305 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, 304 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED,
306 base::ASCIIToUTF16("foo.js")), 305 base::ASCIIToUTF16("foo.js")),
307 error); 306 error);
308 EXPECT_EQ(0U, warnings.size()); 307 EXPECT_EQ(0U, warnings.size());
309 308
310 scripts->Clear(); 309 scripts->Clear();
311 scripts->AppendString("http://google.com/foo.js"); 310 scripts->AppendString("http://google.com/foo.js");
312 311
313 extension = LoadExtensionManifest(*value.get(), temp.path(), 312 extension =
314 Manifest::UNPACKED, 0, &error); 313 LoadExtensionManifest(*value, temp.path(), Manifest::UNPACKED, 0, &error);
315 ASSERT_TRUE(extension.get()) << error; 314 ASSERT_TRUE(extension.get()) << error;
316 315
317 warnings.clear(); 316 warnings.clear();
318 EXPECT_FALSE( 317 EXPECT_FALSE(
319 file_util::ValidateExtension(extension.get(), &error, &warnings)); 318 file_util::ValidateExtension(extension.get(), &error, &warnings));
320 EXPECT_EQ( 319 EXPECT_EQ(
321 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, 320 l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED,
322 base::ASCIIToUTF16("http://google.com/foo.js")), 321 base::ASCIIToUTF16("http://google.com/foo.js")),
323 error); 322 error);
324 EXPECT_EQ(0U, warnings.size()); 323 EXPECT_EQ(0U, warnings.size());
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 base::FilePath actual_path = 542 base::FilePath actual_path =
544 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); 543 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path);
545 EXPECT_EQ(expected_path.value(), actual_path.value()) << 544 EXPECT_EQ(expected_path.value(), actual_path.value()) <<
546 " For the path " << url; 545 " For the path " << url;
547 } 546 }
548 // Remove temp files. 547 // Remove temp files.
549 ASSERT_TRUE(base::DeleteFile(root_path, true)); 548 ASSERT_TRUE(base::DeleteFile(root_path, true));
550 } 549 }
551 550
552 } // namespace extensions 551 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/permissions/permission_set_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698