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

Unified Diff: ppapi/tests/test_file_ref.cc

Issue 113363004: PPAPI: Add new PPB_FileRef.MakeDirectory to support exclusive operation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/tests/test_file_io.cc ('k') | ppapi/thunk/interfaces_ppb_public_dev_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_file_ref.cc
diff --git a/ppapi/tests/test_file_ref.cc b/ppapi/tests/test_file_ref.cc
index 0a10a32192819ce8118b42855ad1234795b0c720..015f54cc6486e6c084fc57feb37a661412a5221c 100644
--- a/ppapi/tests/test_file_ref.cc
+++ b/ppapi/tests/test_file_ref.cc
@@ -298,41 +298,59 @@ std::string TestFileRef::TestMakeDirectory() {
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
- // MakeDirectory.
- pp::FileRef dir_ref(file_system, "/test_dir_make_directory");
- callback.WaitForResult(dir_ref.MakeDirectory(callback.GetCallback()));
+ // Make a directory.
+ pp::FileRef dir_ref(file_system, "/dir_make_dir");
+ callback.WaitForResult(
+ dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ // Make a directory on the existing path without exclusive flag.
+ callback.WaitForResult(
+ dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
- // MakeDirectory aborted.
+ // Making a directory should be aborted.
int32_t rv = PP_ERROR_FAILED;
{
- rv = pp::FileRef(file_system, "/test_dir_make_abort")
- .MakeDirectory(callback.GetCallback());
+ rv = pp::FileRef(file_system, "/dir_make_dir_abort")
+ .MakeDirectory(PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback());
}
callback.WaitForAbortResult(rv);
CHECK_CALLBACK_BEHAVIOR(callback);
- // MakeDirectoryIncludingAncestors.
- dir_ref = pp::FileRef(file_system, "/dir_make_dir_1/dir_make_dir_2");
+ // Make nested directories.
+ dir_ref = pp::FileRef(file_system, "/dir_make_nested_dir_1/dir");
callback.WaitForResult(
- dir_ref.MakeDirectoryIncludingAncestors(callback.GetCallback()));
+ dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS,
+ callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
- // MakeDirectoryIncludingAncestors aborted.
- {
- rv = pp::FileRef(file_system, "/dir_make_abort_1/dir_make_abort_2")
- .MakeDirectoryIncludingAncestors(callback.GetCallback());
- }
- callback.WaitForAbortResult(rv);
+ dir_ref = pp::FileRef(file_system, "/dir_make_nested_dir_2/dir");
+ callback.WaitForResult(
+ dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_ERROR_FILENOTFOUND, callback.result());
+
+ // Ensure there is no directory on the path to test exclusive cases.
+ dir_ref = pp::FileRef(file_system, "/dir_make_dir_exclusive");
+ rv = DeleteDirectoryRecursively(&dir_ref);
+ ASSERT_TRUE(rv == PP_OK || rv == PP_ERROR_FILENOTFOUND);
+
+ // Make a directory exclusively.
+ callback.WaitForResult(
+ dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_EXCLUSIVE,
+ callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
- // MakeDirectory with nested path should fail.
- dir_ref = pp::FileRef(file_system, "/dir_make_dir_3/dir_make_dir_4");
- callback.WaitForResult(dir_ref.MakeDirectory(callback.GetCallback()));
+ callback.WaitForResult(
+ dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_EXCLUSIVE,
+ callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
- ASSERT_NE(PP_OK, callback.result());
+ ASSERT_EQ(PP_ERROR_FILEEXISTS, callback.result());
PASS();
}
@@ -432,7 +450,8 @@ std::string TestFileRef::TestDeleteFileAndDirectory() {
ASSERT_EQ(PP_OK, callback.result());
pp::FileRef dir_ref(file_system, "/dir_delete");
- callback.WaitForResult(dir_ref.MakeDirectory(callback.GetCallback()));
+ callback.WaitForResult(dir_ref.MakeDirectory(
+ PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
@@ -442,7 +461,8 @@ std::string TestFileRef::TestDeleteFileAndDirectory() {
pp::FileRef nested_dir_ref(file_system, "/dir_delete_1/dir_delete_2");
callback.WaitForResult(
- nested_dir_ref.MakeDirectoryIncludingAncestors(callback.GetCallback()));
+ nested_dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS,
+ callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
@@ -496,7 +516,8 @@ std::string TestFileRef::TestRenameFileAndDirectory() {
ASSERT_EQ(PP_OK, callback.result());
pp::FileRef dir_ref(file_system, "/dir_rename");
- callback.WaitForResult(dir_ref.MakeDirectory(callback.GetCallback()));
+ callback.WaitForResult(dir_ref.MakeDirectory(
+ PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
@@ -508,7 +529,8 @@ std::string TestFileRef::TestRenameFileAndDirectory() {
pp::FileRef nested_dir_ref(file_system, "/dir_rename_1/dir_rename_2");
callback.WaitForResult(
- nested_dir_ref.MakeDirectoryIncludingAncestors(callback.GetCallback()));
+ nested_dir_ref.MakeDirectory(PP_MAKEDIRECTORYFLAG_WITH_ANCESTORS,
+ callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
@@ -615,7 +637,8 @@ std::string TestFileRef::TestFileNameEscaping() {
std::string test_dir_path = "/dir_for_escaping_test";
// Create a directory in which to test.
pp::FileRef test_dir_ref(file_system, test_dir_path.c_str());
- callback.WaitForResult(test_dir_ref.MakeDirectory(callback.GetCallback()));
+ callback.WaitForResult(test_dir_ref.MakeDirectory(
+ PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
@@ -663,7 +686,8 @@ std::string TestFileRef::TestReadDirectoryEntries() {
int32_t rv = DeleteDirectoryRecursively(&test_dir);
ASSERT_TRUE(rv == PP_OK || rv == PP_ERROR_FILENOTFOUND);
- callback.WaitForResult(test_dir.MakeDirectory(callback.GetCallback()));
+ callback.WaitForResult(test_dir.MakeDirectory(
+ PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
@@ -690,7 +714,8 @@ std::string TestFileRef::TestReadDirectoryEntries() {
buffer << test_dir_name << '/' << dir_prefix << i;
pp::FileRef file_ref(file_system, buffer.str().c_str());
- callback.WaitForResult(file_ref.MakeDirectory(callback.GetCallback()));
+ callback.WaitForResult(file_ref.MakeDirectory(
+ PP_MAKEDIRECTORYFLAG_NONE, callback.GetCallback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_EQ(PP_OK, callback.result());
« no previous file with comments | « ppapi/tests/test_file_io.cc ('k') | ppapi/thunk/interfaces_ppb_public_dev_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698