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

Side by Side Diff: base/file_util_unittest.cc

Issue 654013: Deprecate file_util::AppendToPath() on non-Windows. (Closed)
Patch Set: ok Created 10 years, 10 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
« no previous file with comments | « base/file_util_deprecated.h ('k') | chrome/browser/chrome_plugin_host.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 {L"/foo/bar", L"path", L"/foo/bar/path"}, 138 {L"/foo/bar", L"path", L"/foo/bar/path"},
139 {L"/foo/bar/", L"path", L"/foo/bar/path"}, 139 {L"/foo/bar/", L"path", L"/foo/bar/path"},
140 {L"/foo/bar//", L"path", L"/foo/bar//path"}, 140 {L"/foo/bar//", L"path", L"/foo/bar//path"},
141 {L"/foo/bar/", L"", L"/foo/bar/"}, 141 {L"/foo/bar/", L"", L"/foo/bar/"},
142 {L"/foo/bar", L"", L"/foo/bar/"}, 142 {L"/foo/bar", L"", L"/foo/bar/"},
143 {L"", L"path", L"/path"}, 143 {L"", L"path", L"/path"},
144 {L"", L"", L"/"}, 144 {L"", L"", L"/"},
145 #endif 145 #endif
146 }; 146 };
147 147
148 #if defined(OS_WIN)
149 // This function is deprecated, but still used on Windows.
148 TEST_F(FileUtilTest, AppendToPath) { 150 TEST_F(FileUtilTest, AppendToPath) {
149 for (unsigned int i = 0; i < arraysize(append_cases); ++i) { 151 for (unsigned int i = 0; i < arraysize(append_cases); ++i) {
150 const append_case& value = append_cases[i]; 152 const append_case& value = append_cases[i];
151 std::wstring result = value.path; 153 std::wstring result = value.path;
152 file_util::AppendToPath(&result, value.ending); 154 file_util::AppendToPath(&result, value.ending);
153 EXPECT_EQ(value.result, result); 155 EXPECT_EQ(value.result, result);
154 } 156 }
155 157
156 #ifdef NDEBUG 158 #ifdef NDEBUG
157 file_util::AppendToPath(NULL, L"path"); // asserts in debug mode 159 file_util::AppendToPath(NULL, L"path"); // asserts in debug mode
158 #endif 160 #endif
159 } 161 }
162 #endif // defined(OS_WIN)
163
160 164
161 static const struct InsertBeforeExtensionCase { 165 static const struct InsertBeforeExtensionCase {
162 const FilePath::CharType* path; 166 const FilePath::CharType* path;
163 const FilePath::CharType* suffix; 167 const FilePath::CharType* suffix;
164 const FilePath::CharType* result; 168 const FilePath::CharType* result;
165 } kInsertBeforeExtension[] = { 169 } kInsertBeforeExtension[] = {
166 {FPL(""), FPL(""), FPL("")}, 170 {FPL(""), FPL(""), FPL("")},
167 {FPL(""), FPL("txt"), FPL("txt")}, 171 {FPL(""), FPL("txt"), FPL("txt")},
168 {FPL("."), FPL("txt"), FPL("txt.")}, 172 {FPL("."), FPL("txt"), FPL("txt.")},
169 {FPL("."), FPL(""), FPL(".")}, 173 {FPL("."), FPL(""), FPL(".")},
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 // modification times with 2s resolution. 1414 // modification times with 2s resolution.
1411 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT", 1415 ASSERT_TRUE(base::Time::FromString(L"Tue, 15 Nov 1994, 12:45:26 GMT",
1412 &modification_time)); 1416 &modification_time));
1413 ASSERT_TRUE(file_util::SetLastModifiedTime(foobar, modification_time)); 1417 ASSERT_TRUE(file_util::SetLastModifiedTime(foobar, modification_time));
1414 file_util::FileInfo file_info; 1418 file_util::FileInfo file_info;
1415 ASSERT_TRUE(file_util::GetFileInfo(foobar, &file_info)); 1419 ASSERT_TRUE(file_util::GetFileInfo(foobar, &file_info));
1416 ASSERT_TRUE(file_info.last_modified == modification_time); 1420 ASSERT_TRUE(file_info.last_modified == modification_time);
1417 } 1421 }
1418 1422
1419 } // namespace 1423 } // namespace
OLDNEW
« no previous file with comments | « base/file_util_deprecated.h ('k') | chrome/browser/chrome_plugin_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698