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

Side by Side Diff: chrome/common/extensions/extension_file_util_unittest.cc

Issue 217233004: Revert of Remove ExtensionService Garbage-Collecting methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « chrome/common/extensions/extension_file_util.cc ('k') | extensions/common/one_shot_event.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/common/extensions/extension_file_util.h" 5 #include "chrome/common/extensions/extension_file_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 base::FilePath version_3 = extension_file_util::InstallExtension( 76 base::FilePath version_3 = extension_file_util::InstallExtension(
77 src, 77 src,
78 extension_id, 78 extension_id,
79 version, 79 version,
80 all_extensions); 80 all_extensions);
81 ASSERT_EQ(version_3.value(), 81 ASSERT_EQ(version_3.value(),
82 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_2") 82 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_2")
83 .value()); 83 .value());
84 ASSERT_TRUE(base::DirectoryExists(version_3)); 84 ASSERT_TRUE(base::DirectoryExists(version_3));
85 85
86 // Collect garbage. Should remove first one.
87 std::multimap<std::string, base::FilePath> extension_paths;
88 extension_paths.insert(std::make_pair(extension_id,
89 base::FilePath().AppendASCII(extension_id).Append(version_2.BaseName())));
90 extension_paths.insert(std::make_pair(extension_id,
91 base::FilePath().AppendASCII(extension_id).Append(version_3.BaseName())));
92 extension_file_util::GarbageCollectExtensions(all_extensions,
93 extension_paths,
94 true);
95 ASSERT_FALSE(base::DirectoryExists(version_1));
96 ASSERT_TRUE(base::DirectoryExists(version_2));
97 ASSERT_TRUE(base::DirectoryExists(version_3));
98
86 // Uninstall. Should remove entire extension subtree. 99 // Uninstall. Should remove entire extension subtree.
87 extension_file_util::UninstallExtension(all_extensions, extension_id); 100 extension_file_util::UninstallExtension(all_extensions, extension_id);
88 ASSERT_FALSE(base::DirectoryExists(version_1.DirName()));
89 ASSERT_FALSE(base::DirectoryExists(version_2.DirName())); 101 ASSERT_FALSE(base::DirectoryExists(version_2.DirName()));
90 ASSERT_FALSE(base::DirectoryExists(version_3.DirName())); 102 ASSERT_FALSE(base::DirectoryExists(version_3.DirName()));
91 ASSERT_TRUE(base::DirectoryExists(all_extensions)); 103 ASSERT_TRUE(base::DirectoryExists(all_extensions));
92 } 104 }
93 105
94 TEST_F(ExtensionFileUtilTest, LoadExtensionWithValidLocales) { 106 TEST_F(ExtensionFileUtilTest, LoadExtensionWithValidLocales) {
95 base::FilePath install_dir; 107 base::FilePath install_dir;
96 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); 108 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir));
97 install_dir = install_dir.AppendASCII("extensions") 109 install_dir = install_dir.AppendASCII("extensions")
98 .AppendASCII("good") 110 .AppendASCII("good")
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( 460 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension(
449 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); 461 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
450 EXPECT_TRUE(extension3.get() == NULL); 462 EXPECT_TRUE(extension3.get() == NULL);
451 EXPECT_STREQ("Could not load icon 'icon.png' for page action.", 463 EXPECT_STREQ("Could not load icon 'icon.png' for page action.",
452 error.c_str()); 464 error.c_str());
453 } 465 }
454 466
455 // TODO(aa): More tests as motivation allows. Maybe steal some from 467 // TODO(aa): More tests as motivation allows. Maybe steal some from
456 // ExtensionService? Many of them could probably be tested here without the 468 // ExtensionService? Many of them could probably be tested here without the
457 // MessageLoop shenanigans. 469 // MessageLoop shenanigans.
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_file_util.cc ('k') | extensions/common/one_shot_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698