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

Unified Diff: ppapi/tests/test_file_ref.cc

Issue 12817009: Add Query() support to FileRef (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix yuzhu's concerns, fix tests Created 7 years, 9 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
Index: ppapi/tests/test_file_ref.cc
diff --git a/ppapi/tests/test_file_ref.cc b/ppapi/tests/test_file_ref.cc
index 3c91f18276fa82df29e3a10c188ab97539d6fb11..1596938a8958c6523f3199013406af3b51339a11 100644
--- a/ppapi/tests/test_file_ref.cc
+++ b/ppapi/tests/test_file_ref.cc
@@ -59,6 +59,7 @@ void TestFileRef::RunTests(const std::string& filter) {
RUN_TEST_FORCEASYNC_AND_NOT(QueryAndTouchFile, filter);
RUN_TEST_FORCEASYNC_AND_NOT(DeleteFileAndDirectory, filter);
RUN_TEST_FORCEASYNC_AND_NOT(RenameFileAndDirectory, filter);
+ RUN_TEST_FORCEASYNC_AND_NOT(Query, filter);
#ifndef PPAPI_OS_NACL // NaCl can't run this test yet.
RUN_TEST_FORCEASYNC_AND_NOT(FileNameEscaping, filter);
#endif
@@ -682,6 +683,49 @@ std::string TestFileRef::TestRenameFileAndDirectory() {
PASS();
}
+std::string TestFileRef::TestQuery() {
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+
+ 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());
+
+ pp::FileRef file_ref(file_system, "/file");
+ pp::FileIO file_io(instance_);
+ callback.WaitForResult(file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE,
+ callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ // We touch the file so we can easily check access and modified time.
+ callback.WaitForResult(file_io.Touch(0, 0, callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+
+ TestCompletionCallbackWithOutput<PP_FileInfo> out_callback(
+ instance_->pp_instance(), callback_type());
+ out_callback.WaitForResult(file_ref.Query(
+ out_callback.GetCallbackWithOutput()));
+ CHECK_CALLBACK_BEHAVIOR(out_callback);
+ ASSERT_EQ(PP_OK, out_callback.result());
+
+ PP_FileInfo info = out_callback.output();
+ ASSERT_EQ(0, info.size);
+ ASSERT_EQ(PP_FILETYPE_REGULAR, info.type);
+ ASSERT_EQ(PP_FILESYSTEMTYPE_LOCALTEMPORARY, info.system_type);
+ ASSERT_DOUBLE_EQ(0.0, info.last_access_time);
+ ASSERT_DOUBLE_EQ(0.0, info.last_modified_time);
+
+ pp::FileRef missing_file_ref(file_system, "/missing_file");
+ out_callback.WaitForResult(missing_file_ref.Query(
+ out_callback.GetCallbackWithOutput()));
+ CHECK_CALLBACK_BEHAVIOR(out_callback);
+ ASSERT_EQ(PP_ERROR_FILENOTFOUND, out_callback.result());
+
+ PASS();
+}
+
#ifndef PPAPI_OS_NACL
std::string TestFileRef::TestFileNameEscaping() {
TestCompletionCallback callback(instance_->pp_instance(), force_async_);

Powered by Google App Engine
This is Rietveld 408576698