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

Side by Side Diff: extensions/common/file_util_unittest.cc

Issue 99923002: Move temp file functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « courgette/memory_allocator.cc ('k') | net/base/file_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "extensions/common/file_util.h" 5 #include "extensions/common/file_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 EXPECT_FALSE(actual_path.IsAbsolute()) << 49 EXPECT_FALSE(actual_path.IsAbsolute()) <<
50 " For the path " << actual_path.value(); 50 " For the path " << actual_path.value();
51 EXPECT_EQ(expected_path.value(), actual_path.value()) << 51 EXPECT_EQ(expected_path.value(), actual_path.value()) <<
52 " For the path " << url; 52 " For the path " << url;
53 } 53 }
54 } 54 }
55 55
56 TEST_F(FileUtilTest, ExtensionResourceURLToFilePath) { 56 TEST_F(FileUtilTest, ExtensionResourceURLToFilePath) {
57 // Setup filesystem for testing. 57 // Setup filesystem for testing.
58 base::FilePath root_path; 58 base::FilePath root_path;
59 ASSERT_TRUE(file_util::CreateNewTempDirectory( 59 ASSERT_TRUE(base::CreateNewTempDirectory(
60 base::FilePath::StringType(), &root_path)); 60 base::FilePath::StringType(), &root_path));
61 root_path = base::MakeAbsoluteFilePath(root_path); 61 root_path = base::MakeAbsoluteFilePath(root_path);
62 ASSERT_FALSE(root_path.empty()); 62 ASSERT_FALSE(root_path.empty());
63 63
64 base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname")); 64 base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname"));
65 ASSERT_TRUE(file_util::CreateDirectory(api_path)); 65 ASSERT_TRUE(file_util::CreateDirectory(api_path));
66 66
67 const char data[] = "Test Data"; 67 const char data[] = "Test Data";
68 base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js")); 68 base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js"));
69 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data))); 69 ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data)));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append( 112 expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append(
113 test_cases[i].expected_path); 113 test_cases[i].expected_path);
114 base::FilePath actual_path = 114 base::FilePath actual_path =
115 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path); 115 extensions::file_util::ExtensionResourceURLToFilePath(url, root_path);
116 EXPECT_EQ(expected_path.value(), actual_path.value()) << 116 EXPECT_EQ(expected_path.value(), actual_path.value()) <<
117 " For the path " << url; 117 " For the path " << url;
118 } 118 }
119 // Remove temp files. 119 // Remove temp files.
120 ASSERT_TRUE(base::DeleteFile(root_path, true)); 120 ASSERT_TRUE(base::DeleteFile(root_path, true));
121 } 121 }
OLDNEW
« no previous file with comments | « courgette/memory_allocator.cc ('k') | net/base/file_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698