Commit 3970c423 authored by zelidrag@chromium.org's avatar zelidrag@chromium.org

Fixed remaining CL comments from review of http://codereview.chromium.org/9561009/

BUG=chromium-os:26961
TEST=none
Review URL: https://chromiumcodereview.appspot.com/9580016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124742 0039d316-1c4b-4281-b951-d872f2087c98
parent cb01852b
...@@ -472,6 +472,10 @@ void GDataFileSystem::CreateDirectoryInternal( ...@@ -472,6 +472,10 @@ void GDataFileSystem::CreateDirectoryInternal(
// this function. // this function.
break; break;
} }
default: {
NOTREACHED();
break;
}
} }
// Do we have a parent directory here as well? We can't then create target // Do we have a parent directory here as well? We can't then create target
...@@ -588,10 +592,11 @@ void GDataFileSystem::OnCreateDirectoryCompleted( ...@@ -588,10 +592,11 @@ void GDataFileSystem::OnCreateDirectoryCompleted(
// Not done yet with recursive directory creation? // Not done yet with recursive directory creation?
if (params.target_directory_path != params.created_directory_path && if (params.target_directory_path != params.created_directory_path &&
params.is_recursive) { params.is_recursive) {
CreateDirectory(params.target_directory_path, CreateDirectoryInternal(params.target_directory_path,
params.is_exclusive, params.is_exclusive,
params.is_recursive, params.is_recursive,
params.callback); params.callback,
params.proxy);
return; return;
} }
...@@ -755,7 +760,6 @@ base::PlatformFileError GDataFileSystem::UpdateDirectoryWithDocumentFeed( ...@@ -755,7 +760,6 @@ base::PlatformFileError GDataFileSystem::UpdateDirectoryWithDocumentFeed(
return base::PLATFORM_FILE_OK; return base::PLATFORM_FILE_OK;
} }
base::PlatformFileError GDataFileSystem::AddNewDirectory( base::PlatformFileError GDataFileSystem::AddNewDirectory(
const FilePath& directory_path, base::Value* entry_value) { const FilePath& directory_path, base::Value* entry_value) {
if (!entry_value) if (!entry_value)
...@@ -779,6 +783,9 @@ base::PlatformFileError GDataFileSystem::AddNewDirectory( ...@@ -779,6 +783,9 @@ base::PlatformFileError GDataFileSystem::AddNewDirectory(
if (!file) if (!file)
return base::PLATFORM_FILE_ERROR_FAILED; return base::PLATFORM_FILE_ERROR_FAILED;
// Check if parent is a directory since in theory since this is a callback
// something could in the meantime have nuked the parent dir and created a
// file with the exact same name.
GDataDirectory* parent_dir = file->AsGDataDirectory(); GDataDirectory* parent_dir = file->AsGDataDirectory();
if (!parent_dir) if (!parent_dir)
return base::PLATFORM_FILE_ERROR_FAILED; return base::PLATFORM_FILE_ERROR_FAILED;
......
...@@ -305,7 +305,7 @@ class GDataFileSystem : public ProfileKeyedService { ...@@ -305,7 +305,7 @@ class GDataFileSystem : public ProfileKeyedService {
FOUND_INVALID, FOUND_INVALID,
// Found missing directory segment while searching for given directory. // Found missing directory segment while searching for given directory.
FOUND_MISSING, FOUND_MISSING,
// Found target directory, it's already exists. // Found target directory, it already exists.
DIRECTORY_ALREADY_PRESENT, DIRECTORY_ALREADY_PRESENT,
}; };
......
...@@ -50,10 +50,7 @@ class FindFileDelegateReplyBase : public FindFileDelegate { ...@@ -50,10 +50,7 @@ class FindFileDelegateReplyBase : public FindFileDelegate {
: file_system_(file_system), : file_system_(file_system),
search_file_path_(search_file_path), search_file_path_(search_file_path),
require_content_(require_content) { require_content_(require_content) {
BrowserThread::ID thread_id; reply_message_proxy_ = MessageLoopProxy::current();
CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id));
replay_message_proxy_ =
BrowserThread::GetMessageLoopProxyForThread(thread_id);
} }
virtual ~FindFileDelegateReplyBase() {} virtual ~FindFileDelegateReplyBase() {}
...@@ -98,7 +95,7 @@ class FindFileDelegateReplyBase : public FindFileDelegate { ...@@ -98,7 +95,7 @@ class FindFileDelegateReplyBase : public FindFileDelegate {
FilePath search_file_path_; FilePath search_file_path_;
// True if the final directory content is required. // True if the final directory content is required.
bool require_content_; bool require_content_;
scoped_refptr<MessageLoopProxy> replay_message_proxy_; scoped_refptr<MessageLoopProxy> reply_message_proxy_;
}; };
// GetFileInfoDelegate is used to handle results of proxy's content search // GetFileInfoDelegate is used to handle results of proxy's content search
...@@ -138,7 +135,7 @@ class GetFileInfoDelegate : public FindFileDelegateReplyBase { ...@@ -138,7 +135,7 @@ class GetFileInfoDelegate : public FindFileDelegateReplyBase {
const base::PlatformFileInfo& file_info, const base::PlatformFileInfo& file_info,
const FilePath& platform_path) { const FilePath& platform_path) {
if (!callback_.is_null()) { if (!callback_.is_null()) {
replay_message_proxy_->PostTask(FROM_HERE, reply_message_proxy_->PostTask(FROM_HERE,
Bind(&GetFileInfoDelegate::ReplyOnCallingThread, Bind(&GetFileInfoDelegate::ReplyOnCallingThread,
this, this,
result, result,
...@@ -218,7 +215,7 @@ class ReadDirectoryDelegate : public FindFileDelegateReplyBase { ...@@ -218,7 +215,7 @@ class ReadDirectoryDelegate : public FindFileDelegateReplyBase {
const std::vector<base::FileUtilProxy::Entry>& file_list, const std::vector<base::FileUtilProxy::Entry>& file_list,
bool has_more) { bool has_more) {
if (!callback_.is_null()) { if (!callback_.is_null()) {
replay_message_proxy_->PostTask(FROM_HERE, reply_message_proxy_->PostTask(FROM_HERE,
Bind(&ReadDirectoryDelegate::ReplyOnCallingThread, Bind(&ReadDirectoryDelegate::ReplyOnCallingThread,
this, this,
result, result,
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -45,7 +46,7 @@ class GDataFileSystemTest : public testing::Test { ...@@ -45,7 +46,7 @@ class GDataFileSystemTest : public testing::Test {
// Loads test json file as root ("/gdata") element. // Loads test json file as root ("/gdata") element.
void LoadRootFeedDocument(const std::string& filename) { void LoadRootFeedDocument(const std::string& filename) {
LoadSubdirFeedDocument(FilePath("gdata"), filename); LoadSubdirFeedDocument(FilePath(FILE_PATH_LITERAL("gdata")), filename);
} }
// Loads test json file as subdirectory content of |directory_path|. // Loads test json file as subdirectory content of |directory_path|.
...@@ -183,10 +184,10 @@ TEST_F(GDataFileSystemTest, SearchRootDirectory) { ...@@ -183,10 +184,10 @@ TEST_F(GDataFileSystemTest, SearchRootDirectory) {
new MockFindFileDelegate(); new MockFindFileDelegate();
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnDirectoryFound(FilePath("gdata"), _)) OnDirectoryFound(FilePath(FILE_PATH_LITERAL("gdata")), _))
.Times(1); .Times(1);
file_system_->FindFileByPath(FilePath("gdata"), file_system_->FindFileByPath(FilePath(FILE_PATH_LITERAL("gdata")),
mock_find_file_delegate); mock_find_file_delegate);
} }
...@@ -196,13 +197,13 @@ TEST_F(GDataFileSystemTest, SearchExistingFile) { ...@@ -196,13 +197,13 @@ TEST_F(GDataFileSystemTest, SearchExistingFile) {
new MockFindFileDelegate(); new MockFindFileDelegate();
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnEnterDirectory(FilePath("gdata"), _)) OnEnterDirectory(FilePath(FILE_PATH_LITERAL("gdata")), _))
.Times(1) .Times(1)
.WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES)); .WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES));
EXPECT_CALL(*mock_find_file_delegate.get(), OnFileFound(_)) EXPECT_CALL(*mock_find_file_delegate.get(), OnFileFound(_))
.Times(1); .Times(1);
file_system_->FindFileByPath(FilePath("gdata/File 1.txt"), file_system_->FindFileByPath(FilePath(FILE_PATH_LITERAL("gdata/File 1.txt")),
mock_find_file_delegate); mock_find_file_delegate);
} }
...@@ -212,14 +213,15 @@ TEST_F(GDataFileSystemTest, SearchExistingDocument) { ...@@ -212,14 +213,15 @@ TEST_F(GDataFileSystemTest, SearchExistingDocument) {
new MockFindFileDelegate(); new MockFindFileDelegate();
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnEnterDirectory(FilePath("gdata"), _)) OnEnterDirectory(FilePath(FILE_PATH_LITERAL("gdata")), _))
.Times(1) .Times(1)
.WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES)); .WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES));
EXPECT_CALL(*mock_find_file_delegate.get(), OnFileFound(_)) EXPECT_CALL(*mock_find_file_delegate.get(), OnFileFound(_))
.Times(1); .Times(1);
file_system_->FindFileByPath(FilePath("gdata/Document 1.gdocument"), file_system_->FindFileByPath(
mock_find_file_delegate); FilePath(FILE_PATH_LITERAL("gdata/Document 1.gdocument")),
mock_find_file_delegate);
} }
TEST_F(GDataFileSystemTest, SearchDuplicateNames) { TEST_F(GDataFileSystemTest, SearchDuplicateNames) {
...@@ -228,24 +230,26 @@ TEST_F(GDataFileSystemTest, SearchDuplicateNames) { ...@@ -228,24 +230,26 @@ TEST_F(GDataFileSystemTest, SearchDuplicateNames) {
scoped_refptr<MockFindFileDelegate> mock_find_file_delegate = scoped_refptr<MockFindFileDelegate> mock_find_file_delegate =
new MockFindFileDelegate(); new MockFindFileDelegate();
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnEnterDirectory(FilePath("gdata"), _)) OnEnterDirectory(FilePath(FILE_PATH_LITERAL("gdata")), _))
.Times(1) .Times(1)
.WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES)); .WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES));
EXPECT_CALL(*mock_find_file_delegate.get(), OnFileFound(_)) EXPECT_CALL(*mock_find_file_delegate.get(), OnFileFound(_))
.Times(1); .Times(1);
file_system_->FindFileByPath(FilePath("gdata/Duplicate Name.txt"), file_system_->FindFileByPath(
mock_find_file_delegate); FilePath(FILE_PATH_LITERAL("gdata/Duplicate Name.txt")),
mock_find_file_delegate);
scoped_refptr<MockFindFileDelegate> mock_find_file_delegate2 = scoped_refptr<MockFindFileDelegate> mock_find_file_delegate2 =
new MockFindFileDelegate(); new MockFindFileDelegate();
EXPECT_CALL(*mock_find_file_delegate2.get(), EXPECT_CALL(*mock_find_file_delegate2.get(),
OnEnterDirectory(FilePath("gdata"), _)) OnEnterDirectory(FilePath(FILE_PATH_LITERAL("gdata")), _))
.Times(1) .Times(1)
.WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES)); .WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES));
EXPECT_CALL(*mock_find_file_delegate2.get(), OnFileFound(_)) EXPECT_CALL(*mock_find_file_delegate2.get(), OnFileFound(_))
.Times(1); .Times(1);
file_system_->FindFileByPath(FilePath("gdata/Duplicate Name (2).txt"), file_system_->FindFileByPath(
mock_find_file_delegate2); FilePath(FILE_PATH_LITERAL("gdata/Duplicate Name (2).txt")),
mock_find_file_delegate2);
} }
TEST_F(GDataFileSystemTest, SearchExistingDirectory) { TEST_F(GDataFileSystemTest, SearchExistingDirectory) {
...@@ -254,13 +258,13 @@ TEST_F(GDataFileSystemTest, SearchExistingDirectory) { ...@@ -254,13 +258,13 @@ TEST_F(GDataFileSystemTest, SearchExistingDirectory) {
new MockFindFileDelegate(); new MockFindFileDelegate();
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnEnterDirectory(FilePath("gdata"), _)) OnEnterDirectory(FilePath(FILE_PATH_LITERAL("gdata")), _))
.Times(1) .Times(1)
.WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES)); .WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES));
EXPECT_CALL(*mock_find_file_delegate.get(), OnDirectoryFound(_, _)) EXPECT_CALL(*mock_find_file_delegate.get(), OnDirectoryFound(_, _))
.Times(1); .Times(1);
file_system_->FindFileByPath(FilePath("gdata/Directory 1"), file_system_->FindFileByPath(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")),
mock_find_file_delegate); mock_find_file_delegate);
} }
...@@ -271,15 +275,16 @@ TEST_F(GDataFileSystemTest, SearchNonExistingFile) { ...@@ -271,15 +275,16 @@ TEST_F(GDataFileSystemTest, SearchNonExistingFile) {
new MockFindFileDelegate(); new MockFindFileDelegate();
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnEnterDirectory(FilePath("gdata"), _)) OnEnterDirectory(FilePath(FILE_PATH_LITERAL("gdata")), _))
.Times(1) .Times(1)
.WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES)); .WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES));
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnError(base::PLATFORM_FILE_ERROR_NOT_FOUND)) OnError(base::PLATFORM_FILE_ERROR_NOT_FOUND))
.Times(1); .Times(1);
file_system_->FindFileByPath(FilePath("gdata/nonexisting.file"), file_system_->FindFileByPath(
mock_find_file_delegate); FilePath(FILE_PATH_LITERAL("gdata/nonexisting.file")),
mock_find_file_delegate);
} }
TEST_F(GDataFileSystemTest, StopFileSearch) { TEST_F(GDataFileSystemTest, StopFileSearch) {
...@@ -289,28 +294,30 @@ TEST_F(GDataFileSystemTest, StopFileSearch) { ...@@ -289,28 +294,30 @@ TEST_F(GDataFileSystemTest, StopFileSearch) {
// Stop on first directory entry. // Stop on first directory entry.
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnEnterDirectory(FilePath("gdata"), _)) OnEnterDirectory(FilePath(FILE_PATH_LITERAL("gdata")), _))
.Times(1) .Times(1)
.WillOnce(Return(FindFileDelegate::FIND_FILE_TERMINATES)); .WillOnce(Return(FindFileDelegate::FIND_FILE_TERMINATES));
file_system_->FindFileByPath(FilePath("gdata/Directory 1"), file_system_->FindFileByPath(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")),
mock_find_file_delegate); mock_find_file_delegate);
} }
TEST_F(GDataFileSystemTest, SearchInSubdir) { TEST_F(GDataFileSystemTest, SearchInSubdir) {
LoadRootFeedDocument("root_feed.json"); LoadRootFeedDocument("root_feed.json");
LoadSubdirFeedDocument(FilePath("gdata/Directory 1"), "subdir_feed.json"); LoadSubdirFeedDocument(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")),
"subdir_feed.json");
scoped_refptr<MockFindFileDelegate> mock_find_file_delegate = scoped_refptr<MockFindFileDelegate> mock_find_file_delegate =
new MockFindFileDelegate(); new MockFindFileDelegate();
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnEnterDirectory(FilePath("gdata"), _)) OnEnterDirectory(FilePath(FILE_PATH_LITERAL("gdata")), _))
.Times(1) .Times(1)
.WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES)); .WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES));
EXPECT_CALL(*mock_find_file_delegate.get(), EXPECT_CALL(*mock_find_file_delegate.get(),
OnEnterDirectory(FilePath("gdata/Directory 1"), _)) OnEnterDirectory(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")),
_))
.Times(1) .Times(1)
.WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES)); .WillOnce(Return(FindFileDelegate::FIND_FILE_CONTINUES));
...@@ -318,27 +325,31 @@ TEST_F(GDataFileSystemTest, SearchInSubdir) { ...@@ -318,27 +325,31 @@ TEST_F(GDataFileSystemTest, SearchInSubdir) {
.Times(1); .Times(1);
file_system_->FindFileByPath( file_system_->FindFileByPath(
FilePath("gdata/Directory 1/SubDirectory File 1.txt"), FilePath(FILE_PATH_LITERAL("gdata/Directory 1/SubDirectory File 1.txt")),
mock_find_file_delegate); mock_find_file_delegate);
} }
TEST_F(GDataFileSystemTest, FilePathTests) { TEST_F(GDataFileSystemTest, FilePathTests) {
LoadRootFeedDocument("root_feed.json"); LoadRootFeedDocument("root_feed.json");
LoadSubdirFeedDocument(FilePath("gdata/Directory 1"), "subdir_feed.json"); LoadSubdirFeedDocument(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")),
"subdir_feed.json");
FindAndTestFilePath(FilePath("gdata/File 1.txt")); FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/File 1.txt")));
FindAndTestFilePath(FilePath("gdata/Directory 1")); FindAndTestFilePath(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")));
FindAndTestFilePath(FilePath("gdata/Directory 1/SubDirectory File 1.txt")); FindAndTestFilePath(
FilePath(FILE_PATH_LITERAL("gdata/Directory 1/SubDirectory File 1.txt")));
} }
TEST_F(GDataFileSystemTest, RemoveFiles) { TEST_F(GDataFileSystemTest, RemoveFiles) {
LoadRootFeedDocument("root_feed.json"); LoadRootFeedDocument("root_feed.json");
LoadSubdirFeedDocument(FilePath("gdata/Directory 1"), "subdir_feed.json"); LoadSubdirFeedDocument(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")),
"subdir_feed.json");
FilePath nonexisting_file("gdata/Dummy file.txt"); FilePath nonexisting_file(FILE_PATH_LITERAL("gdata/Dummy file.txt"));
FilePath file_in_root("gdata/File 1.txt"); FilePath file_in_root(FILE_PATH_LITERAL("gdata/File 1.txt"));
FilePath dir_in_root("gdata/Directory 1"); FilePath dir_in_root(FILE_PATH_LITERAL("gdata/Directory 1"));
FilePath file_in_subdir("gdata/Directory 1/SubDirectory File 1.txt"); FilePath file_in_subdir(
FILE_PATH_LITERAL("gdata/Directory 1/SubDirectory File 1.txt"));
EXPECT_TRUE(FindFile(file_in_root) != NULL); EXPECT_TRUE(FindFile(file_in_root) != NULL);
EXPECT_TRUE(FindFile(dir_in_root) != NULL); EXPECT_TRUE(FindFile(dir_in_root) != NULL);
...@@ -363,22 +374,22 @@ TEST_F(GDataFileSystemTest, RemoveFiles) { ...@@ -363,22 +374,22 @@ TEST_F(GDataFileSystemTest, RemoveFiles) {
EXPECT_FALSE(RemoveFile(nonexisting_file)); EXPECT_FALSE(RemoveFile(nonexisting_file));
// Try removing root file element. // Try removing root file element.
EXPECT_FALSE(RemoveFile(FilePath("gdata"))); EXPECT_FALSE(RemoveFile(FilePath(FILE_PATH_LITERAL("gdata"))));
} }
TEST_F(GDataFileSystemTest, CreateDirectory) { TEST_F(GDataFileSystemTest, CreateDirectory) {
LoadRootFeedDocument("root_feed.json"); LoadRootFeedDocument("root_feed.json");
LoadSubdirFeedDocument(FilePath("gdata/Directory 1"), "subdir_feed.json"); LoadSubdirFeedDocument(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")),
"subdir_feed.json");
// Create directory in root. // Create directory in root.
FilePath dir_path("gdata/New Folder 1"); FilePath dir_path(FILE_PATH_LITERAL("gdata/New Folder 1"));
EXPECT_TRUE(FindFile(dir_path) == NULL); EXPECT_TRUE(FindFile(dir_path) == NULL);
AddDirectoryFromFile(dir_path, "directory_entry_atom.json"); AddDirectoryFromFile(dir_path, "directory_entry_atom.json");
EXPECT_TRUE(FindFile(dir_path) != NULL); EXPECT_TRUE(FindFile(dir_path) != NULL);
// Create directory in a sub dirrectory. // Create directory in a sub dirrectory.
FilePath subdir_path("gdata/New Folder 1/New Folder 2"); FilePath subdir_path(FILE_PATH_LITERAL("gdata/New Folder 1/New Folder 2"));
EXPECT_TRUE(FindFile(subdir_path) == NULL); EXPECT_TRUE(FindFile(subdir_path) == NULL);
AddDirectoryFromFile(subdir_path, "directory_entry_atom.json"); AddDirectoryFromFile(subdir_path, "directory_entry_atom.json");
EXPECT_TRUE(FindFile(subdir_path) != NULL); EXPECT_TRUE(FindFile(subdir_path) != NULL);
...@@ -386,56 +397,60 @@ TEST_F(GDataFileSystemTest, CreateDirectory) { ...@@ -386,56 +397,60 @@ TEST_F(GDataFileSystemTest, CreateDirectory) {
TEST_F(GDataFileSystemTest, FindFirstMissingParentDirectory) { TEST_F(GDataFileSystemTest, FindFirstMissingParentDirectory) {
LoadRootFeedDocument("root_feed.json"); LoadRootFeedDocument("root_feed.json");
LoadSubdirFeedDocument(FilePath("gdata/Directory 1"), "subdir_feed.json"); LoadSubdirFeedDocument(FilePath(FILE_PATH_LITERAL("gdata/Directory 1")),
"subdir_feed.json");
GURL last_dir_content_url; GURL last_dir_content_url;
FilePath first_missing_parent_path; FilePath first_missing_parent_path;
// Create directory in root. // Create directory in root.
FilePath dir_path("gdata/New Folder 1"); FilePath dir_path(FILE_PATH_LITERAL("gdata/New Folder 1"));
EXPECT_EQ( EXPECT_EQ(
GDataFileSystem::FOUND_MISSING,
file_system_->FindFirstMissingParentDirectory(dir_path, file_system_->FindFirstMissingParentDirectory(dir_path,
&last_dir_content_url, &last_dir_content_url,
&first_missing_parent_path), &first_missing_parent_path));
GDataFileSystem::FOUND_MISSING); EXPECT_EQ(FilePath(FILE_PATH_LITERAL("gdata/New Folder 1")),
EXPECT_EQ(dir_path, first_missing_parent_path); first_missing_parent_path);
EXPECT_TRUE(last_dir_content_url.is_empty()); // root directory. EXPECT_TRUE(last_dir_content_url.is_empty()); // root directory.
// Missing folders in subdir of an existing folder. // Missing folders in subdir of an existing folder.
FilePath dir_path2("gdata/Directory 1/New Folder 2"); FilePath dir_path2(FILE_PATH_LITERAL("gdata/Directory 1/New Folder 2"));
EXPECT_EQ( EXPECT_EQ(
GDataFileSystem::FOUND_MISSING,
file_system_->FindFirstMissingParentDirectory(dir_path2, file_system_->FindFirstMissingParentDirectory(dir_path2,
&last_dir_content_url, &last_dir_content_url,
&first_missing_parent_path), &first_missing_parent_path));
GDataFileSystem::FOUND_MISSING); EXPECT_EQ(FilePath(FILE_PATH_LITERAL("gdata/Directory 1/New Folder 2")),
EXPECT_EQ(dir_path2, first_missing_parent_path); first_missing_parent_path);
EXPECT_FALSE(last_dir_content_url.is_empty()); // non-root directory. EXPECT_FALSE(last_dir_content_url.is_empty()); // non-root directory.
// Missing two folders on the path. // Missing two folders on the path.
FilePath dir_path3 = dir_path2.Append("Another Foder"); FilePath dir_path3 = dir_path2.Append(FILE_PATH_LITERAL("Another Foder"));
EXPECT_EQ( EXPECT_EQ(
GDataFileSystem::FOUND_MISSING,
file_system_->FindFirstMissingParentDirectory(dir_path3, file_system_->FindFirstMissingParentDirectory(dir_path3,
&last_dir_content_url, &last_dir_content_url,
&first_missing_parent_path), &first_missing_parent_path));
GDataFileSystem::FOUND_MISSING); EXPECT_EQ(FilePath(FILE_PATH_LITERAL("gdata/Directory 1/New Folder 2")),
EXPECT_EQ(dir_path3.DirName(), first_missing_parent_path); first_missing_parent_path);
EXPECT_FALSE(last_dir_content_url.is_empty()); // non-root directory. EXPECT_FALSE(last_dir_content_url.is_empty()); // non-root directory.
// Folders on top of an existing file. // Folders on top of an existing file.
EXPECT_EQ( EXPECT_EQ(
GDataFileSystem::FOUND_INVALID,
file_system_->FindFirstMissingParentDirectory( file_system_->FindFirstMissingParentDirectory(
FilePath("gdata/File 1.txt/BadDir"), FilePath(FILE_PATH_LITERAL("gdata/File 1.txt/BadDir")),
&last_dir_content_url, &last_dir_content_url,
&first_missing_parent_path), &first_missing_parent_path));
GDataFileSystem::FOUND_INVALID);
// Existing folder. // Existing folder.
EXPECT_EQ( EXPECT_EQ(
GDataFileSystem::DIRECTORY_ALREADY_PRESENT,
file_system_->FindFirstMissingParentDirectory( file_system_->FindFirstMissingParentDirectory(
FilePath("gdata/Directory 1"), FilePath(FILE_PATH_LITERAL("gdata/Directory 1")),
&last_dir_content_url, &last_dir_content_url,
&first_missing_parent_path), &first_missing_parent_path));
GDataFileSystem::DIRECTORY_ALREADY_PRESENT);
} }
} // namespace gdata } // namespace gdata
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment