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

Side by Side Diff: webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc

Issue 19052005: Move PathIsWritable, DirectoryExists, ContentsEqual, and TextContentsEqual to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 "webkit/browser/fileapi/sandbox_file_system_backend.h" 5 #include "webkit/browser/fileapi/sandbox_file_system_backend.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 SandboxFileSystemBackend::OriginEnumerator* CreateOriginEnumerator() const { 99 SandboxFileSystemBackend::OriginEnumerator* CreateOriginEnumerator() const {
100 return backend_->CreateOriginEnumerator(); 100 return backend_->CreateOriginEnumerator();
101 } 101 }
102 102
103 void CreateOriginTypeDirectory(const GURL& origin, 103 void CreateOriginTypeDirectory(const GURL& origin,
104 fileapi::FileSystemType type) { 104 fileapi::FileSystemType type) {
105 base::FilePath target = backend_-> 105 base::FilePath target = backend_->
106 GetBaseDirectoryForOriginAndType(origin, type, true); 106 GetBaseDirectoryForOriginAndType(origin, type, true);
107 ASSERT_TRUE(!target.empty()); 107 ASSERT_TRUE(!target.empty());
108 ASSERT_TRUE(file_util::DirectoryExists(target)); 108 ASSERT_TRUE(base::DirectoryExists(target));
109 } 109 }
110 110
111 bool GetRootPath(const GURL& origin_url, 111 bool GetRootPath(const GURL& origin_url,
112 fileapi::FileSystemType type, 112 fileapi::FileSystemType type,
113 OpenFileSystemMode mode, 113 OpenFileSystemMode mode,
114 base::FilePath* root_path) { 114 base::FilePath* root_path) {
115 base::PlatformFileError error = base::PLATFORM_FILE_OK; 115 base::PlatformFileError error = base::PLATFORM_FILE_OK;
116 backend_->OpenFileSystem( 116 backend_->OpenFileSystem(
117 origin_url, type, mode, 117 origin_url, type, mode,
118 base::Bind(&DidOpenFileSystem, &error)); 118 base::Bind(&DidOpenFileSystem, &error));
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 base::FilePath root_path; 249 base::FilePath root_path;
250 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), 250 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url),
251 kRootPathTestCases[i].type, 251 kRootPathTestCases[i].type,
252 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 252 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
253 &root_path)); 253 &root_path));
254 254
255 base::FilePath expected = file_system_path().AppendASCII( 255 base::FilePath expected = file_system_path().AppendASCII(
256 kRootPathTestCases[i].expected_path); 256 kRootPathTestCases[i].expected_path);
257 EXPECT_EQ(expected.value(), root_path.value()); 257 EXPECT_EQ(expected.value(), root_path.value());
258 EXPECT_TRUE(file_util::DirectoryExists(root_path)); 258 EXPECT_TRUE(base::DirectoryExists(root_path));
259 ASSERT_TRUE(returned_root_path.size() > i); 259 ASSERT_TRUE(returned_root_path.size() > i);
260 returned_root_path[i] = root_path; 260 returned_root_path[i] = root_path;
261 } 261 }
262 262
263 // Get the root directory with create=false and see if we get the 263 // Get the root directory with create=false and see if we get the
264 // same directory. 264 // same directory.
265 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { 265 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) {
266 SCOPED_TRACE(testing::Message() << "RootPath (get) #" << i << " " 266 SCOPED_TRACE(testing::Message() << "RootPath (get) #" << i << " "
267 << kRootPathTestCases[i].expected_path); 267 << kRootPathTestCases[i].expected_path);
268 268
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" 346 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #"
347 << i << " " << kRootPathFileURITestCases[i].expected_path); 347 << i << " " << kRootPathFileURITestCases[i].expected_path);
348 base::FilePath root_path; 348 base::FilePath root_path;
349 EXPECT_TRUE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), 349 EXPECT_TRUE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url),
350 kRootPathFileURITestCases[i].type, 350 kRootPathFileURITestCases[i].type,
351 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 351 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
352 &root_path)); 352 &root_path));
353 base::FilePath expected = file_system_path().AppendASCII( 353 base::FilePath expected = file_system_path().AppendASCII(
354 kRootPathFileURITestCases[i].expected_path); 354 kRootPathFileURITestCases[i].expected_path);
355 EXPECT_EQ(expected.value(), root_path.value()); 355 EXPECT_EQ(expected.value(), root_path.value());
356 EXPECT_TRUE(file_util::DirectoryExists(root_path)); 356 EXPECT_TRUE(base::DirectoryExists(root_path));
357 } 357 }
358 } 358 }
359 359
360 } // namespace fileapi 360 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698