| 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" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 130 |
| 131 | 131 |
| 132 // This test ensures that the mimetype sniffing code stays in sync with the | 132 // This test ensures that the mimetype sniffing code stays in sync with the |
| 133 // actual crx files that we test other parts of the system with. | 133 // actual crx files that we test other parts of the system with. |
| 134 TEST(ExtensionTest, MimeTypeSniffing) { | 134 TEST(ExtensionTest, MimeTypeSniffing) { |
| 135 base::FilePath path; | 135 base::FilePath path; |
| 136 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | 136 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
| 137 path = path.AppendASCII("extensions").AppendASCII("good.crx"); | 137 path = path.AppendASCII("extensions").AppendASCII("good.crx"); |
| 138 | 138 |
| 139 std::string data; | 139 std::string data; |
| 140 ASSERT_TRUE(file_util::ReadFileToString(path, &data)); | 140 ASSERT_TRUE(base::ReadFileToString(path, &data)); |
| 141 | 141 |
| 142 std::string result; | 142 std::string result; |
| 143 EXPECT_TRUE(net::SniffMimeType(data.c_str(), | 143 EXPECT_TRUE(net::SniffMimeType(data.c_str(), |
| 144 data.size(), | 144 data.size(), |
| 145 GURL("http://www.example.com/foo.crx"), | 145 GURL("http://www.example.com/foo.crx"), |
| 146 std::string(), | 146 std::string(), |
| 147 &result)); | 147 &result)); |
| 148 EXPECT_EQ(std::string(Extension::kMimeType), result); | 148 EXPECT_EQ(std::string(Extension::kMimeType), result); |
| 149 | 149 |
| 150 data.clear(); | 150 data.clear(); |
| 151 result.clear(); | 151 result.clear(); |
| 152 path = path.DirName().AppendASCII("bad_magic.crx"); | 152 path = path.DirName().AppendASCII("bad_magic.crx"); |
| 153 ASSERT_TRUE(file_util::ReadFileToString(path, &data)); | 153 ASSERT_TRUE(base::ReadFileToString(path, &data)); |
| 154 EXPECT_TRUE(net::SniffMimeType(data.c_str(), | 154 EXPECT_TRUE(net::SniffMimeType(data.c_str(), |
| 155 data.size(), | 155 data.size(), |
| 156 GURL("http://www.example.com/foo.crx"), | 156 GURL("http://www.example.com/foo.crx"), |
| 157 std::string(), | 157 std::string(), |
| 158 &result)); | 158 &result)); |
| 159 EXPECT_EQ("application/octet-stream", result); | 159 EXPECT_EQ("application/octet-stream", result); |
| 160 } | 160 } |
| 161 | 161 |
| 162 TEST(ExtensionTest, WantsFileAccess) { | 162 TEST(ExtensionTest, WantsFileAccess) { |
| 163 scoped_refptr<Extension> extension; | 163 scoped_refptr<Extension> extension; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 extension = LoadManifest("app", "manifest.json", Extension::FROM_BOOKMARK); | 279 extension = LoadManifest("app", "manifest.json", Extension::FROM_BOOKMARK); |
| 280 EXPECT_TRUE(extension->from_bookmark()); | 280 EXPECT_TRUE(extension->from_bookmark()); |
| 281 | 281 |
| 282 extension = LoadManifest("app", "manifest.json", Extension::NO_FLAGS); | 282 extension = LoadManifest("app", "manifest.json", Extension::NO_FLAGS); |
| 283 EXPECT_FALSE(extension->from_bookmark()); | 283 EXPECT_FALSE(extension->from_bookmark()); |
| 284 EXPECT_FALSE(extension->from_webstore()); | 284 EXPECT_FALSE(extension->from_webstore()); |
| 285 } | 285 } |
| 286 | 286 |
| 287 } // namespace extensions | 287 } // namespace extensions |
| OLD | NEW |