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

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

Issue 13196006: Move path functions from file_util to FilePath object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try Created 7 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) 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 EXPECT_EQ(expected_path.value(), actual_path.value()) << 298 EXPECT_EQ(expected_path.value(), actual_path.value()) <<
299 " For the path " << url; 299 " For the path " << url;
300 } 300 }
301 } 301 }
302 302
303 TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) { 303 TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) {
304 // Setup filesystem for testing. 304 // Setup filesystem for testing.
305 base::FilePath root_path; 305 base::FilePath root_path;
306 ASSERT_TRUE(file_util::CreateNewTempDirectory( 306 ASSERT_TRUE(file_util::CreateNewTempDirectory(
307 base::FilePath::StringType(), &root_path)); 307 base::FilePath::StringType(), &root_path));
308 ASSERT_TRUE(file_util::AbsolutePath(&root_path)); 308 root_path = base::MakeAbsoluteFilePath(root_path);
309 ASSERT_FALSE(root_path.empty());
309 310
310 base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); 311 base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname"));
311 ASSERT_TRUE(file_util::CreateDirectory(api_path)); 312 ASSERT_TRUE(file_util::CreateDirectory(api_path));
312 313
313 const char data[] = "Test Data"; 314 const char data[] = "Test Data";
314 base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js")); 315 base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js"));
315 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); 316 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data)));
316 resource_path = api_path.Append(FILE_PATH_LITERAL("escape spaces.js")); 317 resource_path = api_path.Append(FILE_PATH_LITERAL("escape spaces.js"));
317 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); 318 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data)));
318 319
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( 594 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension(
594 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); 595 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error));
595 EXPECT_TRUE(extension3 == NULL); 596 EXPECT_TRUE(extension3 == NULL);
596 EXPECT_STREQ("Could not load icon 'icon.png' for page action.", 597 EXPECT_STREQ("Could not load icon 'icon.png' for page action.",
597 error.c_str()); 598 error.c_str());
598 } 599 }
599 600
600 // TODO(aa): More tests as motivation allows. Maybe steal some from 601 // TODO(aa): More tests as motivation allows. Maybe steal some from
601 // ExtensionService? Many of them could probably be tested here without the 602 // ExtensionService? Many of them could probably be tested here without the
602 // MessageLoop shenanigans. 603 // MessageLoop shenanigans.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698