diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 18:29:45 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-29 18:29:45 +0000 |
commit | 500fc4983abc1fbe077b9b503691a318a7f6996f (patch) | |
tree | 4c1bfff85a53aa6060cbbc40be212b40aa3fee81 /ppapi | |
parent | 7def14cd47fb49c0433eae101be352010aa9f292 (diff) | |
download | chromium_src-500fc4983abc1fbe077b9b503691a318a7f6996f.zip chromium_src-500fc4983abc1fbe077b9b503691a318a7f6996f.tar.gz chromium_src-500fc4983abc1fbe077b9b503691a318a7f6996f.tar.bz2 |
Cleanup: Remove operator from TestCompletionCallbackWithOutput.
BUG=
Review URL: https://chromiumcodereview.appspot.com/13203002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191407 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/tests/test_directory_reader.cc | 7 | ||||
-rw-r--r-- | ppapi/tests/test_file_io.cc | 4 | ||||
-rw-r--r-- | ppapi/tests/test_file_ref.cc | 2 | ||||
-rw-r--r-- | ppapi/tests/test_utils.h | 50 |
4 files changed, 42 insertions, 21 deletions
diff --git a/ppapi/tests/test_directory_reader.cc b/ppapi/tests/test_directory_reader.cc index f577b12..c0de4e1 100644 --- a/ppapi/tests/test_directory_reader.cc +++ b/ppapi/tests/test_directory_reader.cc @@ -51,7 +51,7 @@ int32_t TestDirectoryReader::DeleteDirectoryRecursively(pp::FileRef* dir) { int32_t rv = PP_OK; pp::DirectoryReader_Dev directory_reader(*dir); - rv = directory_reader.ReadEntries(output_callback); + rv = directory_reader.ReadEntries(output_callback.GetCallback()); if (rv == PP_OK_COMPLETIONPENDING) rv = output_callback.WaitForResult(); if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND) @@ -151,7 +151,7 @@ std::string TestDirectoryReader::TestReadEntries() { instance_->pp_instance(), force_async_); pp::DirectoryReader_Dev directory_reader(test_dir); - rv = directory_reader.ReadEntries(output_callback); + rv = directory_reader.ReadEntries(output_callback.GetCallback()); if (force_async_ && rv != PP_OK_COMPLETIONPENDING) return ReportError("DirectoryReader::ReadEntries force_async", rv); if (rv == PP_OK_COMPLETIONPENDING) @@ -194,7 +194,8 @@ std::string TestDirectoryReader::TestReadEntries() { instance_->pp_instance(), force_async_); // Note that the directory reader will be deleted immediately. - rv = pp::DirectoryReader_Dev(test_dir).ReadEntries(output_callback); + rv = pp::DirectoryReader_Dev(test_dir).ReadEntries( + output_callback.GetCallback()); if (force_async_ && rv != PP_OK_COMPLETIONPENDING) return ReportError("DirectoryReader::ReadEntries force_async", rv); if (output_callback.run_count() > 0) diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc index ea9224f..29348a6 100644 --- a/ppapi/tests/test_file_io.cc +++ b/ppapi/tests/test_file_io.cc @@ -92,7 +92,7 @@ int32_t ReadToArrayEntireFile(PP_Instance instance, instance, force_async); for (;;) { - callback.WaitForResult(file_io->Read(offset, 256, callback)); + callback.WaitForResult(file_io->Read(offset, 256, callback.GetCallback())); int32_t rv = callback.result(); if (rv < 0) return rv; @@ -461,7 +461,7 @@ std::string TestFileIO::TestReadToArrayWriteSetLength() { // Check for failing read operation. callback2.WaitForResult( file_io.Read(0, -1, // negative number of bytes to read - callback2)); + callback2.GetCallback())); CHECK_CALLBACK_BEHAVIOR(callback2); if (callback2.result() != PP_ERROR_FAILED) return ReportError("FileIO::Read", callback2.result()); diff --git a/ppapi/tests/test_file_ref.cc b/ppapi/tests/test_file_ref.cc index 3c91f18..e8e85bc 100644 --- a/ppapi/tests/test_file_ref.cc +++ b/ppapi/tests/test_file_ref.cc @@ -723,7 +723,7 @@ std::string TestFileRef::TestFileNameEscaping() { output_callback(instance_->pp_instance(), force_async_); pp::DirectoryReader_Dev directory_reader(test_dir_ref); - rv = directory_reader.ReadEntries(output_callback); + rv = directory_reader.ReadEntries(output_callback.GetCallback()); if (rv == PP_OK_COMPLETIONPENDING) rv = output_callback.WaitForResult(); if (rv != PP_OK && rv != PP_ERROR_FILENOTFOUND) diff --git a/ppapi/tests/test_utils.h b/ppapi/tests/test_utils.h index e61efbd..0018d61 100644 --- a/ppapi/tests/test_utils.h +++ b/ppapi/tests/test_utils.h @@ -148,8 +148,11 @@ class TestCompletionCallback { // Reset so that this callback can be used again. void Reset(); - protected: + CallbackType callback_type() { return callback_type_; } + void set_target_loop(const pp::MessageLoop& loop) { target_loop_ = loop; } static void Handler(void* user_data, int32_t result); + + protected: void RunMessageLoop(); void QuitMessageLoop(); @@ -170,37 +173,54 @@ class TestCompletionCallback { }; template <typename OutputT> -class TestCompletionCallbackWithOutput : public TestCompletionCallback { +class TestCompletionCallbackWithOutput { public: explicit TestCompletionCallbackWithOutput(PP_Instance instance) : - TestCompletionCallback(instance) { + callback_(instance) { } TestCompletionCallbackWithOutput(PP_Instance instance, bool force_async) : - TestCompletionCallback(instance, force_async) { + callback_(instance, force_async) { } TestCompletionCallbackWithOutput(PP_Instance instance, CallbackType callback_type) : - TestCompletionCallback(instance, callback_type) { - } - - pp::CompletionCallbackWithOutput<OutputT> GetCallbackWithOutput(); - operator pp::CompletionCallbackWithOutput<OutputT>() { - return GetCallbackWithOutput(); + callback_(instance, callback_type) { } + pp::CompletionCallbackWithOutput<OutputT> GetCallback(); const OutputT& output() { return output_storage_.output(); } + // Delegate functions to TestCompletionCallback + void SetDelegate(TestCompletionCallback::Delegate* delegate) { + callback_.SetDelegate(delegate); + } + int32_t WaitForResult() { return callback_.WaitForResult(); } + void WaitForResult(int32_t result) { callback_.WaitForResult(result); } + void WaitForAbortResult(int32_t result) { + callback_.WaitForAbortResult(result); + } + // TODO(dmichael): Remove run_count when all tests are updated. Most cases + // that use this can simply use CHECK_CALLBACK_BEHAVIOR. + unsigned run_count() const { return callback_.run_count(); } + // TODO(dmichael): Remove this; tests should use Reset() instead. + void reset_run_count() { callback_.reset_run_count(); } + bool failed() { return callback_.failed(); } + const std::string& errors() { return callback_.errors(); } + int32_t result() const { return callback_.result(); } + void Reset() { return callback_.Reset(); } + + private: + TestCompletionCallback callback_; typename pp::CompletionCallbackWithOutput<OutputT>::OutputStorageType output_storage_; }; template <typename OutputT> pp::CompletionCallbackWithOutput<OutputT> -TestCompletionCallbackWithOutput<OutputT>::GetCallbackWithOutput() { - Reset(); - if (callback_type_ == PP_BLOCKING) { +TestCompletionCallbackWithOutput<OutputT>::GetCallback() { + callback_.Reset(); + if (callback_.callback_type() == PP_BLOCKING) { pp::CompletionCallbackWithOutput<OutputT> cc( &TestCompletionCallback::Handler, this, @@ -208,12 +228,12 @@ TestCompletionCallbackWithOutput<OutputT>::GetCallbackWithOutput() { return cc; } - target_loop_ = pp::MessageLoop::GetCurrent(); + callback_.set_target_loop(pp::MessageLoop::GetCurrent()); pp::CompletionCallbackWithOutput<OutputT> cc( &TestCompletionCallback::Handler, this, &output_storage_); - if (callback_type_ == PP_OPTIONAL) + if (callback_.callback_type() == PP_OPTIONAL) cc.set_flags(PP_COMPLETIONCALLBACK_FLAG_OPTIONAL); return cc; } |