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

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

Issue 19547009: Move ".crx"/".pem" constants and extension_filenames constants into extensions/common/constants.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 std::string error; 147 std::string error;
148 EXPECT_TRUE(extension_file_util::CheckForIllegalFilenames(temp.path(), 148 EXPECT_TRUE(extension_file_util::CheckForIllegalFilenames(temp.path(),
149 &error)); 149 &error));
150 } 150 }
151 151
152 TEST_F(ExtensionFileUtilTest, CheckIllegalFilenamesOnlyReserved) { 152 TEST_F(ExtensionFileUtilTest, CheckIllegalFilenamesOnlyReserved) {
153 base::ScopedTempDir temp; 153 base::ScopedTempDir temp;
154 ASSERT_TRUE(temp.CreateUniqueTempDir()); 154 ASSERT_TRUE(temp.CreateUniqueTempDir());
155 155
156 const base::FilePath::CharType* folders[] = 156 const base::FilePath::CharType* folders[] =
157 { extensions::kLocaleFolder, extensions::kPlatformSpecificFolder }; 157 { extensions::filenames::kLocaleFolder,
158 extensions::filenames::kPlatformSpecificFolder };
158 159
159 for (size_t i = 0; i < arraysize(folders); i++) { 160 for (size_t i = 0; i < arraysize(folders); i++) {
160 base::FilePath src_path = temp.path().Append(folders[i]); 161 base::FilePath src_path = temp.path().Append(folders[i]);
161 ASSERT_TRUE(file_util::CreateDirectory(src_path)); 162 ASSERT_TRUE(file_util::CreateDirectory(src_path));
162 } 163 }
163 164
164 std::string error; 165 std::string error;
165 EXPECT_TRUE(extension_file_util::CheckForIllegalFilenames(temp.path(), 166 EXPECT_TRUE(extension_file_util::CheckForIllegalFilenames(temp.path(),
166 &error)); 167 &error));
167 } 168 }
168 169
169 TEST_F(ExtensionFileUtilTest, CheckIllegalFilenamesReservedAndIllegal) { 170 TEST_F(ExtensionFileUtilTest, CheckIllegalFilenamesReservedAndIllegal) {
170 base::ScopedTempDir temp; 171 base::ScopedTempDir temp;
171 ASSERT_TRUE(temp.CreateUniqueTempDir()); 172 ASSERT_TRUE(temp.CreateUniqueTempDir());
172 173
173 base::FilePath src_path = temp.path().Append(extensions::kLocaleFolder); 174 base::FilePath src_path =
175 temp.path().Append(extensions::filenames::kLocaleFolder);
174 ASSERT_TRUE(file_util::CreateDirectory(src_path)); 176 ASSERT_TRUE(file_util::CreateDirectory(src_path));
175 177
176 src_path = temp.path().AppendASCII("_some_dir"); 178 src_path = temp.path().AppendASCII("_some_dir");
177 ASSERT_TRUE(file_util::CreateDirectory(src_path)); 179 ASSERT_TRUE(file_util::CreateDirectory(src_path));
178 180
179 std::string error; 181 std::string error;
180 EXPECT_FALSE(extension_file_util::CheckForIllegalFilenames(temp.path(), 182 EXPECT_FALSE(extension_file_util::CheckForIllegalFilenames(temp.path(),
181 &error)); 183 &error));
182 } 184 }
183 185
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( 569 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension(
568 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); 570 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
569 EXPECT_TRUE(extension3.get() == NULL); 571 EXPECT_TRUE(extension3.get() == NULL);
570 EXPECT_STREQ("Could not load icon 'icon.png' for page action.", 572 EXPECT_STREQ("Could not load icon 'icon.png' for page action.",
571 error.c_str()); 573 error.c_str());
572 } 574 }
573 575
574 // TODO(aa): More tests as motivation allows. Maybe steal some from 576 // TODO(aa): More tests as motivation allows. Maybe steal some from
575 // ExtensionService? Many of them could probably be tested here without the 577 // ExtensionService? Many of them could probably be tested here without the
576 // MessageLoop shenanigans. 578 // MessageLoop shenanigans.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698