summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_file_system.cc
diff options
context:
space:
mode:
authorpolina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-30 21:42:37 +0000
committerpolina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-30 21:42:37 +0000
commit917e86adc3f824f518c999dcba20bfd4cbf18a18 (patch)
tree52fe38f61527360231c17a905015066fb5d34bba /ppapi/tests/test_file_system.cc
parent9ae7b9195f0e06b64664bba52e9cc0e8b3470f56 (diff)
downloadchromium_src-917e86adc3f824f518c999dcba20bfd4cbf18a18.zip
chromium_src-917e86adc3f824f518c999dcba20bfd4cbf18a18.tar.gz
chromium_src-917e86adc3f824f518c999dcba20bfd4cbf18a18.tar.bz2
Add a flag field to PP_CompletionCallback to control if the callback should
always be invoked asynchronously on success or error or skipped if the operation can complete synchronously without blocking. Keep the default behavior as-is until clients update their code. Bump revisions of all interfaces that take callbacks as args. Update browser interface function implementations and C++ layer to force callbacks if sync option is not set. Change ppapi/tests to run tests involving callbacks with both flag options. BUG=79376 TEST=ppapi_tests + bots Review URL: http://codereview.chromium.org/6899055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91205 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_file_system.cc')
-rw-r--r--ppapi/tests/test_file_system.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/ppapi/tests/test_file_system.cc b/ppapi/tests/test_file_system.cc
index 7758f5f..fe5c902 100644
--- a/ppapi/tests/test_file_system.cc
+++ b/ppapi/tests/test_file_system.cc
@@ -18,12 +18,12 @@ bool TestFileSystem::Init() {
}
void TestFileSystem::RunTest() {
- RUN_TEST(Open);
- RUN_TEST(MultipleOpens);
+ RUN_TEST_FORCEASYNC_AND_NOT(Open);
+ RUN_TEST_FORCEASYNC_AND_NOT(MultipleOpens);
}
std::string TestFileSystem::TestOpen() {
- TestCompletionCallback callback(instance_->pp_instance());
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
// Open.
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
@@ -39,6 +39,8 @@ std::string TestFileSystem::TestOpen() {
.Open(1024, callback);
if (callback.run_count() > 0)
return "FileSystem::Open ran callback synchronously.";
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
if (rv == PP_OK_COMPLETIONPENDING) {
rv = callback.WaitForResult();
if (rv != PP_ERROR_ABORTED)
@@ -53,27 +55,32 @@ std::string TestFileSystem::TestOpen() {
std::string TestFileSystem::TestMultipleOpens() {
// Should not allow multiple opens, no matter the first open has completed or
// not.
- TestCompletionCallback callback_1(instance_->pp_instance());
+ TestCompletionCallback callback_1(instance_->pp_instance(), force_async_);
pp::FileSystem_Dev file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
int32_t rv_1 = file_system.Open(1024, callback_1);
if (callback_1.run_count() > 0)
- return "FileSystem::Open ran callback synchronously.";
+ return "FileSystem::Open1 ran callback synchronously.";
+ if (force_async_ && rv_1 != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open1 force_async", rv_1);
- TestCompletionCallback callback_2(instance_->pp_instance());
+ TestCompletionCallback callback_2(instance_->pp_instance(), force_async_);
int32_t rv_2 = file_system.Open(1024, callback_2);
+ if (force_async_ && rv_2 != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open2 force_async", rv_2);
if (rv_2 == PP_OK_COMPLETIONPENDING || rv_2 == PP_OK)
- return "FileSystem::Open should not allow multiple opens.";
+ return "FileSystem::Open2 should not allow multiple opens.";
if (rv_1 == PP_OK_COMPLETIONPENDING)
rv_1 = callback_1.WaitForResult();
if (rv_1 != PP_OK)
- return ReportError("FileSystem::Open", rv_1);
+ return ReportError("FileSystem::Open1", rv_1);
- TestCompletionCallback callback_3(instance_->pp_instance());
+ TestCompletionCallback callback_3(instance_->pp_instance(), force_async_);
int32_t rv_3 = file_system.Open(1024, callback_3);
+ if (force_async_ && rv_3 != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open3 force_async", rv_3);
if (rv_3 == PP_OK_COMPLETIONPENDING || rv_3 == PP_OK)
- return "FileSystem::Open should not allow multiple opens.";
+ return "FileSystem::Open3 should not allow multiple opens.";
PASS();
}
-