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

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

Issue 236213002: Move most of extension_file_util.cc into extensions/common/file_util.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (file-util) 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/format_macros.h" 6 #include "base/format_macros.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
11 #include "chrome/common/extensions/command.h" 11 #include "chrome/common/extensions/command.h"
12 #include "chrome/common/extensions/extension_file_util.h"
13 #include "chrome/common/extensions/extension_test_util.h" 12 #include "chrome/common/extensions/extension_test_util.h"
14 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" 13 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
15 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
16 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
17 #include "extensions/common/extension_resource.h" 16 #include "extensions/common/extension_resource.h"
17 #include "extensions/common/file_util.h"
18 #include "extensions/common/manifest.h" 18 #include "extensions/common/manifest.h"
19 #include "extensions/common/permissions/permissions_data.h" 19 #include "extensions/common/permissions/permissions_data.h"
20 #include "net/base/mime_sniffer.h" 20 #include "net/base/mime_sniffer.h"
21 #include "net/dns/mock_host_resolver.h" 21 #include "net/dns/mock_host_resolver.h"
22 #include "skia/ext/image_operations.h" 22 #include "skia/ext/image_operations.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
25 #include "ui/gfx/codec/png_codec.h" 25 #include "ui/gfx/codec/png_codec.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 for (size_t i = 0; i < arraysize(invalid_path_test_cases); ++i) 166 for (size_t i = 0; i < arraysize(invalid_path_test_cases); ++i)
167 EXPECT_TRUE(extension->GetResource(invalid_path_test_cases[i]).empty()); 167 EXPECT_TRUE(extension->GetResource(invalid_path_test_cases[i]).empty());
168 } 168 }
169 169
170 TEST(ExtensionTest, GetAbsolutePathNoError) { 170 TEST(ExtensionTest, GetAbsolutePathNoError) {
171 scoped_refptr<Extension> extension = LoadManifestStrict("absolute_path", 171 scoped_refptr<Extension> extension = LoadManifestStrict("absolute_path",
172 "absolute.json"); 172 "absolute.json");
173 EXPECT_TRUE(extension.get()); 173 EXPECT_TRUE(extension.get());
174 std::string err; 174 std::string err;
175 std::vector<InstallWarning> warnings; 175 std::vector<InstallWarning> warnings;
176 EXPECT_TRUE(extension_file_util::ValidateExtension(extension.get(), 176 EXPECT_TRUE(file_util::ValidateExtension(extension.get(), &err, &warnings));
177 &err, &warnings));
178 EXPECT_EQ(0U, warnings.size()); 177 EXPECT_EQ(0U, warnings.size());
179 178
180 EXPECT_EQ(extension->path().AppendASCII("test.html").value(), 179 EXPECT_EQ(extension->path().AppendASCII("test.html").value(),
181 extension->GetResource("test.html").GetFilePath().value()); 180 extension->GetResource("test.html").GetFilePath().value());
182 EXPECT_EQ(extension->path().AppendASCII("test.js").value(), 181 EXPECT_EQ(extension->path().AppendASCII("test.js").value(),
183 extension->GetResource("test.js").GetFilePath().value()); 182 extension->GetResource("test.js").GetFilePath().value());
184 } 183 }
185 184
186 185
187 TEST(ExtensionTest, IdIsValid) { 186 TEST(ExtensionTest, IdIsValid) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 345
347 extension = LoadManifest("app", "manifest.json", Extension::FROM_BOOKMARK); 346 extension = LoadManifest("app", "manifest.json", Extension::FROM_BOOKMARK);
348 EXPECT_TRUE(extension->from_bookmark()); 347 EXPECT_TRUE(extension->from_bookmark());
349 348
350 extension = LoadManifest("app", "manifest.json", Extension::NO_FLAGS); 349 extension = LoadManifest("app", "manifest.json", Extension::NO_FLAGS);
351 EXPECT_FALSE(extension->from_bookmark()); 350 EXPECT_FALSE(extension->from_bookmark());
352 EXPECT_FALSE(extension->from_webstore()); 351 EXPECT_FALSE(extension->from_webstore());
353 } 352 }
354 353
355 } // namespace extensions 354 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698