| OLD | NEW |
| 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_test_util.h" | 12 #include "chrome/common/extensions/extension_test_util.h" |
| 13 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 13 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "components/crx_file/id_util.h" |
| 15 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 16 #include "extensions/common/extension_resource.h" | 17 #include "extensions/common/extension_resource.h" |
| 17 #include "extensions/common/file_util.h" | 18 #include "extensions/common/file_util.h" |
| 18 #include "extensions/common/manifest.h" | 19 #include "extensions/common/manifest.h" |
| 19 #include "extensions/common/permissions/permissions_data.h" | 20 #include "extensions/common/permissions/permissions_data.h" |
| 20 #include "net/base/mime_sniffer.h" | 21 #include "net/base/mime_sniffer.h" |
| 21 #include "net/dns/mock_host_resolver.h" | 22 #include "net/dns/mock_host_resolver.h" |
| 22 #include "skia/ext/image_operations.h" | 23 #include "skia/ext/image_operations.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 EXPECT_EQ(0U, warnings.size()); | 178 EXPECT_EQ(0U, warnings.size()); |
| 178 | 179 |
| 179 EXPECT_EQ(extension->path().AppendASCII("test.html").value(), | 180 EXPECT_EQ(extension->path().AppendASCII("test.html").value(), |
| 180 extension->GetResource("test.html").GetFilePath().value()); | 181 extension->GetResource("test.html").GetFilePath().value()); |
| 181 EXPECT_EQ(extension->path().AppendASCII("test.js").value(), | 182 EXPECT_EQ(extension->path().AppendASCII("test.js").value(), |
| 182 extension->GetResource("test.js").GetFilePath().value()); | 183 extension->GetResource("test.js").GetFilePath().value()); |
| 183 } | 184 } |
| 184 | 185 |
| 185 | 186 |
| 186 TEST(ExtensionTest, IdIsValid) { | 187 TEST(ExtensionTest, IdIsValid) { |
| 187 EXPECT_TRUE(Extension::IdIsValid("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); | 188 EXPECT_TRUE(crx_file::id_util::IdIsValid("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); |
| 188 EXPECT_TRUE(Extension::IdIsValid("pppppppppppppppppppppppppppppppp")); | 189 EXPECT_TRUE(crx_file::id_util::IdIsValid("pppppppppppppppppppppppppppppppp")); |
| 189 EXPECT_TRUE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmnop")); | 190 EXPECT_TRUE(crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmnop")); |
| 190 EXPECT_TRUE(Extension::IdIsValid("ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP")); | 191 EXPECT_TRUE(crx_file::id_util::IdIsValid("ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP")); |
| 191 EXPECT_FALSE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmno")); | 192 EXPECT_FALSE(crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmno")); |
| 192 EXPECT_FALSE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmnopa")); | 193 EXPECT_FALSE( |
| 193 EXPECT_FALSE(Extension::IdIsValid("0123456789abcdef0123456789abcdef")); | 194 crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmnopa")); |
| 194 EXPECT_FALSE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmnoq")); | 195 EXPECT_FALSE( |
| 195 EXPECT_FALSE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmno0")); | 196 crx_file::id_util::IdIsValid("0123456789abcdef0123456789abcdef")); |
| 197 EXPECT_FALSE( |
| 198 crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmnoq")); |
| 199 EXPECT_FALSE( |
| 200 crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmno0")); |
| 196 } | 201 } |
| 197 | 202 |
| 198 | 203 |
| 199 // This test ensures that the mimetype sniffing code stays in sync with the | 204 // This test ensures that the mimetype sniffing code stays in sync with the |
| 200 // actual crx files that we test other parts of the system with. | 205 // actual crx files that we test other parts of the system with. |
| 201 TEST(ExtensionTest, MimeTypeSniffing) { | 206 TEST(ExtensionTest, MimeTypeSniffing) { |
| 202 base::FilePath path; | 207 base::FilePath path; |
| 203 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | 208 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
| 204 path = path.AppendASCII("extensions").AppendASCII("good.crx"); | 209 path = path.AppendASCII("extensions").AppendASCII("good.crx"); |
| 205 | 210 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 314 |
| 310 extension = LoadManifest("app", "manifest.json", Extension::FROM_BOOKMARK); | 315 extension = LoadManifest("app", "manifest.json", Extension::FROM_BOOKMARK); |
| 311 EXPECT_TRUE(extension->from_bookmark()); | 316 EXPECT_TRUE(extension->from_bookmark()); |
| 312 | 317 |
| 313 extension = LoadManifest("app", "manifest.json", Extension::NO_FLAGS); | 318 extension = LoadManifest("app", "manifest.json", Extension::NO_FLAGS); |
| 314 EXPECT_FALSE(extension->from_bookmark()); | 319 EXPECT_FALSE(extension->from_bookmark()); |
| 315 EXPECT_FALSE(extension->from_webstore()); | 320 EXPECT_FALSE(extension->from_webstore()); |
| 316 } | 321 } |
| 317 | 322 |
| 318 } // namespace extensions | 323 } // namespace extensions |
| OLD | NEW |