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

Side by Side Diff: content/browser/fileapi/external_mount_points_unittest.cc

Issue 654403002: Convert ARRAYSIZE_UNSAFE -> arraysize in content/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "storage/browser/fileapi/external_mount_points.h" 5 #include "storage/browser/fileapi/external_mount_points.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "storage/browser/fileapi/file_system_url.h" 10 #include "storage/browser/fileapi/file_system_url.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 { "win2", DRIVE FPL("\\try/separators\\win"), false, NULL }, 99 { "win2", DRIVE FPL("\\try/separators\\win"), false, NULL },
100 #else 100 #else
101 { "win", DRIVE FPL("\\separators\\win"), false, NULL }, 101 { "win", DRIVE FPL("\\separators\\win"), false, NULL },
102 { "win1", DRIVE FPL("\\try/separators\\win1"), false, NULL }, 102 { "win1", DRIVE FPL("\\try/separators\\win1"), false, NULL },
103 #endif 103 #endif
104 // Win separators, but relative path. 104 // Win separators, but relative path.
105 { "win2", DRIVE FPL("try\\separators\\win2"), false, NULL }, 105 { "win2", DRIVE FPL("try\\separators\\win2"), false, NULL },
106 }; 106 };
107 107
108 // Test adding mount points. 108 // Test adding mount points.
109 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { 109 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
110 EXPECT_EQ( 110 EXPECT_EQ(
111 kTestCases[i].success, 111 kTestCases[i].success,
112 mount_points->RegisterFileSystem(kTestCases[i].name, 112 mount_points->RegisterFileSystem(kTestCases[i].name,
113 storage::kFileSystemTypeNativeLocal, 113 storage::kFileSystemTypeNativeLocal,
114 storage::FileSystemMountOption(), 114 storage::FileSystemMountOption(),
115 base::FilePath(kTestCases[i].path))) 115 base::FilePath(kTestCases[i].path)))
116 << "Adding mount point: " << kTestCases[i].name << " with path " 116 << "Adding mount point: " << kTestCases[i].name << " with path "
117 << kTestCases[i].path; 117 << kTestCases[i].path;
118 } 118 }
119 119
120 // Test that final mount point presence state is as expected. 120 // Test that final mount point presence state is as expected.
121 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { 121 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
122 base::FilePath found_path; 122 base::FilePath found_path;
123 EXPECT_EQ(kTestCases[i].registered_path != NULL, 123 EXPECT_EQ(kTestCases[i].registered_path != NULL,
124 mount_points->GetRegisteredPath(kTestCases[i].name, &found_path)) 124 mount_points->GetRegisteredPath(kTestCases[i].name, &found_path))
125 << "Test case: " << i; 125 << "Test case: " << i;
126 126
127 if (kTestCases[i].registered_path) { 127 if (kTestCases[i].registered_path) {
128 base::FilePath expected_path(kTestCases[i].registered_path); 128 base::FilePath expected_path(kTestCases[i].registered_path);
129 EXPECT_EQ(expected_path.NormalizePathSeparators(), found_path); 129 EXPECT_EQ(expected_path.NormalizePathSeparators(), found_path);
130 } 130 }
131 } 131 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 { DRIVE FPL("/root/foo"), true, FPL("mount") }, 207 { DRIVE FPL("/root/foo"), true, FPL("mount") },
208 // Mount point contains character whose ASCII code is smaller than file path 208 // Mount point contains character whose ASCII code is smaller than file path
209 // separator's. 209 // separator's.
210 { DRIVE FPL("/a/b/c(1)/d/e"), true, FPL("c(1)/d/e") }, 210 { DRIVE FPL("/a/b/c(1)/d/e"), true, FPL("c(1)/d/e") },
211 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 211 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
212 // Path with win separators mixed in. 212 // Path with win separators mixed in.
213 { DRIVE FPL("/a\\b\\c/d"), true, FPL("c/d") }, 213 { DRIVE FPL("/a\\b\\c/d"), true, FPL("c/d") },
214 #endif 214 #endif
215 }; 215 };
216 216
217 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { 217 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
218 // Initialize virtual path with a value. 218 // Initialize virtual path with a value.
219 base::FilePath virtual_path(DRIVE FPL("/mount")); 219 base::FilePath virtual_path(DRIVE FPL("/mount"));
220 base::FilePath local_path(kTestCases[i].local_path); 220 base::FilePath local_path(kTestCases[i].local_path);
221 EXPECT_EQ(kTestCases[i].success, 221 EXPECT_EQ(kTestCases[i].success,
222 mount_points->GetVirtualPath(local_path, &virtual_path)) 222 mount_points->GetVirtualPath(local_path, &virtual_path))
223 << "Resolving " << kTestCases[i].local_path; 223 << "Resolving " << kTestCases[i].local_path;
224 224
225 // There are no guarantees for |virtual_path| value if |GetVirtualPath| 225 // There are no guarantees for |virtual_path| value if |GetVirtualPath|
226 // fails. 226 // fails.
227 if (!kTestCases[i].success) 227 if (!kTestCases[i].success)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 {FPL("/empty_path/a/../b"), false, storage::kFileSystemTypeUnknown, FPL(""), 338 {FPL("/empty_path/a/../b"), false, storage::kFileSystemTypeUnknown, FPL(""),
339 ""}, 339 ""},
340 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 340 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
341 {FPL("c/d\\e"), true, storage::kFileSystemTypeNativeLocal, 341 {FPL("c/d\\e"), true, storage::kFileSystemTypeNativeLocal,
342 DRIVE FPL("/a/b/c/d/e"), "c"}, 342 DRIVE FPL("/a/b/c/d/e"), "c"},
343 {FPL("mount\\a\\b"), true, storage::kFileSystemTypeDrive, 343 {FPL("mount\\a\\b"), true, storage::kFileSystemTypeDrive,
344 DRIVE FPL("/root/a/b"), "mount"}, 344 DRIVE FPL("/root/a/b"), "mount"},
345 #endif 345 #endif
346 }; 346 };
347 347
348 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { 348 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
349 FileSystemURL cracked = mount_points->CreateCrackedFileSystemURL( 349 FileSystemURL cracked = mount_points->CreateCrackedFileSystemURL(
350 kTestOrigin, 350 kTestOrigin,
351 storage::kFileSystemTypeExternal, 351 storage::kFileSystemTypeExternal,
352 base::FilePath(kTestCases[i].path)); 352 base::FilePath(kTestCases[i].path));
353 353
354 EXPECT_EQ(kTestCases[i].expect_valid, cracked.is_valid()) 354 EXPECT_EQ(kTestCases[i].expect_valid, cracked.is_valid())
355 << "Test case index: " << i; 355 << "Test case index: " << i;
356 356
357 if (!kTestCases[i].expect_valid) 357 if (!kTestCases[i].expect_valid)
358 continue; 358 continue;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 {FPL("/empty_path/a/../b"), false, storage::kFileSystemTypeUnknown, FPL(""), 432 {FPL("/empty_path/a/../b"), false, storage::kFileSystemTypeUnknown, FPL(""),
433 ""}, 433 ""},
434 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 434 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
435 {FPL("c/d\\e"), true, storage::kFileSystemTypeNativeLocal, 435 {FPL("c/d\\e"), true, storage::kFileSystemTypeNativeLocal,
436 DRIVE FPL("/a/b/c/d/e"), "c"}, 436 DRIVE FPL("/a/b/c/d/e"), "c"},
437 {FPL("mount\\a\\b"), true, storage::kFileSystemTypeDrive, 437 {FPL("mount\\a\\b"), true, storage::kFileSystemTypeDrive,
438 DRIVE FPL("/root/a/b"), "mount"}, 438 DRIVE FPL("/root/a/b"), "mount"},
439 #endif 439 #endif
440 }; 440 };
441 441
442 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { 442 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
443 std::string cracked_name; 443 std::string cracked_name;
444 storage::FileSystemType cracked_type; 444 storage::FileSystemType cracked_type;
445 std::string cracked_id; 445 std::string cracked_id;
446 base::FilePath cracked_path; 446 base::FilePath cracked_path;
447 storage::FileSystemMountOption cracked_option; 447 storage::FileSystemMountOption cracked_option;
448 EXPECT_EQ(kTestCases[i].expect_valid, 448 EXPECT_EQ(kTestCases[i].expect_valid,
449 mount_points->CrackVirtualPath(base::FilePath(kTestCases[i].path), 449 mount_points->CrackVirtualPath(base::FilePath(kTestCases[i].path),
450 &cracked_name, &cracked_type, &cracked_id, &cracked_path, 450 &cracked_name, &cracked_type, &cracked_id, &cracked_path,
451 &cracked_option)) 451 &cracked_option))
452 << "Test case index: " << i; 452 << "Test case index: " << i;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 &option)); 492 &option));
493 EXPECT_EQ(storage::COPY_SYNC_OPTION_NO_SYNC, option.copy_sync_option()); 493 EXPECT_EQ(storage::COPY_SYNC_OPTION_NO_SYNC, option.copy_sync_option());
494 EXPECT_TRUE(mount_points->CrackVirtualPath( 494 EXPECT_TRUE(mount_points->CrackVirtualPath(
495 base::FilePath(FPL("sync/file")), &name, &type, &cracked_id, &path, 495 base::FilePath(FPL("sync/file")), &name, &type, &cracked_id, &path,
496 &option)); 496 &option));
497 EXPECT_EQ(storage::COPY_SYNC_OPTION_SYNC, option.copy_sync_option()); 497 EXPECT_EQ(storage::COPY_SYNC_OPTION_SYNC, option.copy_sync_option());
498 } 498 }
499 499
500 } // namespace content 500 } // namespace content
501 501
OLDNEW
« no previous file with comments | « content/browser/download/save_package_unittest.cc ('k') | content/browser/fileapi/file_system_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698