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

Unified Diff: ppapi/tests/test_broker.cc

Issue 10081020: PPAPI: Make blocking completion callbacks work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try again Created 8 years, 7 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_broker.cc
diff --git a/ppapi/tests/test_broker.cc b/ppapi/tests/test_broker.cc
index db75def4f3602f43f30004bccdc055549e819949..7dd30d7ef11144ee4def9e407f3b52cf13fcfad0 100644
--- a/ppapi/tests/test_broker.cc
+++ b/ppapi/tests/test_broker.cc
@@ -211,8 +211,8 @@ void TestBroker::RunTests(const std::string& filter) {
RUN_TEST(Create, filter);
RUN_TEST(Create, filter);
RUN_TEST(GetHandleFailure, filter);
- RUN_TEST(ConnectFailure, filter);
- RUN_TEST(ConnectAndPipe, filter);
+ RUN_TEST_FORCEASYNC_AND_NOT(ConnectFailure, filter);
+ RUN_TEST_FORCEASYNC_AND_NOT(ConnectAndPipe, filter);
}
std::string TestBroker::TestCreate() {
@@ -229,20 +229,11 @@ std::string TestBroker::TestCreate() {
// Test connection on invalid resource.
std::string TestBroker::TestConnectFailure() {
- // Callback NOT force async. Connect should fail. The callback will not be
- // posted so there's no need to wait for the callback to complete.
- TestCompletionCallback cb_1(instance_->pp_instance(), false);
- ASSERT_EQ(PP_ERROR_BADRESOURCE,
- broker_interface_->Connect(
- 0, pp::CompletionCallback(cb_1).pp_completion_callback()));
-
- // Callback force async. Connect will return PP_OK_COMPLETIONPENDING and the
- // callback will be posted. However, the callback should fail.
- TestCompletionCallback cb_2(instance_->pp_instance(), true);
- ASSERT_EQ(PP_OK_COMPLETIONPENDING,
- broker_interface_->Connect(
- 0, pp::CompletionCallback(cb_2).pp_completion_callback()));
- ASSERT_EQ(PP_ERROR_BADRESOURCE, cb_2.WaitForResult());
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+ callback.WaitForResult(broker_interface_->Connect(0,
+ callback.GetCallback().pp_completion_callback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_ERROR_BADRESOURCE, callback.result());
PASS();
}
@@ -267,11 +258,11 @@ std::string TestBroker::TestConnectAndPipe() {
instance_->pp_instance());
ASSERT_TRUE(broker);
- TestCompletionCallback cb_3(instance_->pp_instance());
- ASSERT_EQ(PP_OK_COMPLETIONPENDING,
- broker_interface_->Connect(
- broker, pp::CompletionCallback(cb_3).pp_completion_callback()));
- ASSERT_EQ(PP_OK, cb_3.WaitForResult());
+ TestCompletionCallback callback(instance_->pp_instance(), callback_type());
+ callback.WaitForResult(broker_interface_->Connect(broker,
+ callback.GetCallback().pp_completion_callback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
int32_t handle = kInvalidHandle;
ASSERT_EQ(PP_OK, broker_interface_->GetHandle(broker, &handle));

Powered by Google App Engine
This is Rietveld 408576698