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

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: Created 7 years 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
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..54ac31624650a9a42312a77a14022c4f5d1fea80 100644
--- a/ppapi/tests/test_file_ref.cc
+++ b/ppapi/tests/test_file_ref.cc
@@ -112,6 +112,7 @@ void TestFileRef::RunTests(const std::string& filter) {
RUN_CALLBACK_TEST(TestFileRef, GetPath, filter);
RUN_CALLBACK_TEST(TestFileRef, GetParent, filter);
RUN_CALLBACK_TEST(TestFileRef, MakeDirectory, filter);
+ RUN_CALLBACK_TEST(TestFileRef, MakeDirectoryExclusive, filter);
RUN_CALLBACK_TEST(TestFileRef, QueryAndTouchFile, filter);
RUN_CALLBACK_TEST(TestFileRef, DeleteFileAndDirectory, filter);
RUN_CALLBACK_TEST(TestFileRef, RenameFileAndDirectory, filter);
@@ -337,6 +338,47 @@ std::string TestFileRef::TestMakeDirectory() {
PASS();
}
+std::string TestFileRef::TestMakeDirectoryExclusive() {
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+
+ // Open.
+ pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
+ callback.WaitForResult(file_system.Open(1024, callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ // Clean up.
+ pp::FileRef dir_ref(file_system, "/dir_exclusive");
+ int32_t rv = DeleteDirectoryRecursively(&dir_ref);
+ ASSERT_TRUE(rv == PP_OK || rv == PP_ERROR_FILENOTFOUND);
+
+ // MakeDirectoryExclusive.
+ callback.WaitForResult(dir_ref.MakeDirectoryExclusive(
+ PP_FALSE, callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ // MakeDirectoryExclusive on the existing directory should fail.
+ callback.WaitForResult(dir_ref.MakeDirectoryExclusive(
+ PP_FALSE, callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_ERROR_FILEEXISTS, callback.result());
+
+ // MakeDirectoryExclusive with nested path.
+ dir_ref = pp::FileRef(file_system, "/dir_exclusive/dir1/dir2");
+ callback.WaitForResult(dir_ref.MakeDirectoryExclusive(
+ PP_FALSE, callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_ERROR_FILENOTFOUND, callback.result());
+
+ callback.WaitForResult(dir_ref.MakeDirectoryExclusive(
+ PP_TRUE, callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ PASS();
+}
+
std::string TestFileRef::TestQueryAndTouchFile() {
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);

Powered by Google App Engine
This is Rietveld 408576698