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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_file_util.cc ('k') | chrome/common/extensions/manifest_handlers/content_scripts_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698