Index: ppapi/tests/test_utils.cc |
diff --git a/ppapi/tests/test_utils.cc b/ppapi/tests/test_utils.cc |
index 7405e93da34182a24e713ce9b13a827e2abe21d2..cae96dc74c75e201d704ca0072808d33913687eb 100644 |
--- a/ppapi/tests/test_utils.cc |
+++ b/ppapi/tests/test_utils.cc |
@@ -97,6 +97,7 @@ TestCompletionCallback::TestCompletionCallback(PP_Instance instance) |
// what the tests currently expect. |
callback_type_(PP_OPTIONAL), |
post_quit_task_(false), |
+ run_count_(0), // TODO(dmichael): Remove when all tests are updated. |
instance_(instance) { |
} |
@@ -172,10 +173,10 @@ void TestCompletionCallback::WaitForAbortResult(int32_t result) { |
final_result)); |
return; |
} |
- } else if (result != PP_OK) { |
+ } else if (result < PP_OK) { |
errors_.assign( |
- ReportError("TestCompletionCallback: Expected PP_ERROR_ABORTED or" |
- "PP_OK. Ran synchronously.", |
+ ReportError("TestCompletionCallback: Expected PP_ERROR_ABORTED or " |
+ "non-error response. Ran synchronously.", |
result)); |
return; |
} |
@@ -198,6 +199,7 @@ void TestCompletionCallback::Reset() { |
result_ = PP_OK_COMPLETIONPENDING; |
have_result_ = false; |
post_quit_task_ = false; |
+ run_count_ = 0; // TODO(dmichael): Remove when all tests are updated. |
errors_.clear(); |
} |
@@ -205,9 +207,12 @@ void TestCompletionCallback::Reset() { |
void TestCompletionCallback::Handler(void* user_data, int32_t result) { |
TestCompletionCallback* callback = |
static_cast<TestCompletionCallback*>(user_data); |
+ // If this check fails, it means that the callback was invoked twice or that |
+ // the PPAPI call completed synchronously, but also ran the callback. |
PP_DCHECK(!callback->have_result_); |
callback->result_ = result; |
callback->have_result_ = true; |
+ callback->run_count_++; // TODO(dmichael): Remove when all tests are updated. |
if (callback->post_quit_task_) { |
callback->post_quit_task_ = false; |
GetTestingInterface()->QuitMessageLoop(callback->instance_); |