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

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

Issue 204983020: Remove ExtensionService Garbage-Collecting methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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 "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;
Yoyo Zhou 2014/03/26 01:54:12 Is this part of the code still tested?
Devlin 2014/03/26 23:56:32 Yes. This was specifically testing the file-threa
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
99 // Uninstall. Should remove entire extension subtree. 86 // Uninstall. Should remove entire extension subtree.
100 extension_file_util::UninstallExtension(all_extensions, extension_id); 87 extension_file_util::UninstallExtension(all_extensions, extension_id);
88 ASSERT_FALSE(base::DirectoryExists(version_1.DirName()));
101 ASSERT_FALSE(base::DirectoryExists(version_2.DirName())); 89 ASSERT_FALSE(base::DirectoryExists(version_2.DirName()));
102 ASSERT_FALSE(base::DirectoryExists(version_3.DirName())); 90 ASSERT_FALSE(base::DirectoryExists(version_3.DirName()));
103 ASSERT_TRUE(base::DirectoryExists(all_extensions)); 91 ASSERT_TRUE(base::DirectoryExists(all_extensions));
104 } 92 }
105 93
106 TEST_F(ExtensionFileUtilTest, LoadExtensionWithValidLocales) { 94 TEST_F(ExtensionFileUtilTest, LoadExtensionWithValidLocales) {
107 base::FilePath install_dir; 95 base::FilePath install_dir;
108 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); 96 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir));
109 install_dir = install_dir.AppendASCII("extensions") 97 install_dir = install_dir.AppendASCII("extensions")
110 .AppendASCII("good") 98 .AppendASCII("good")
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( 448 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension(
461 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); 449 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
462 EXPECT_TRUE(extension3.get() == NULL); 450 EXPECT_TRUE(extension3.get() == NULL);
463 EXPECT_STREQ("Could not load icon 'icon.png' for page action.", 451 EXPECT_STREQ("Could not load icon 'icon.png' for page action.",
464 error.c_str()); 452 error.c_str());
465 } 453 }
466 454
467 // TODO(aa): More tests as motivation allows. Maybe steal some from 455 // TODO(aa): More tests as motivation allows. Maybe steal some from
468 // ExtensionService? Many of them could probably be tested here without the 456 // ExtensionService? Many of them could probably be tested here without the
469 // MessageLoop shenanigans. 457 // MessageLoop shenanigans.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698