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

Unified Diff: ppapi/tests/test_transport.cc

Issue 6899055: PPAPI: Force async callback invocation option. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
« no previous file with comments | « ppapi/tests/test_graphics_2d.cc ('k') | ppapi/tests/test_url_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_transport.cc
===================================================================
--- ppapi/tests/test_transport.cc (revision 91178)
+++ ppapi/tests/test_transport.cc (working copy)
@@ -54,7 +54,7 @@
buffer_.resize(kReadBufferSize);
int result = transport_->Recv(
&buffer_[0], buffer_.size(),
- callback_factory_.NewCallback(&StreamReader::OnReadFinished));
+ callback_factory_.NewOptionalCallback(&StreamReader::OnReadFinished));
if (result > 0)
DidFinishRead(result);
else
@@ -104,7 +104,7 @@
void TestTransport::RunTest() {
RUN_TEST(Create);
RUN_TEST(Connect);
- RUN_TEST(SendDataUdp);
+ RUN_TEST_FORCEASYNC(SendDataUdp);
RUN_TEST(SendDataTcp);
RUN_TEST(ConnectAndCloseUdp);
RUN_TEST(ConnectAndCloseTcp);
@@ -198,10 +198,15 @@
// Put packet index in the beginning.
memcpy(&send_buffer[0], &i, sizeof(i));
- TestCompletionCallback send_cb(instance_->pp_instance());
- ASSERT_EQ(
- transport2_->Send(&send_buffer[0], send_buffer.size(), send_cb),
- static_cast<int>(send_buffer.size()));
+ TestCompletionCallback send_cb(instance_->pp_instance(), force_async_);
+ int32_t result = transport2_->Send(&send_buffer[0], send_buffer.size(),
+ send_cb);
+ if (force_async_) {
+ ASSERT_EQ(result, PP_OK_COMPLETIONPENDING);
+ ASSERT_EQ(send_cb.WaitForResult(), static_cast<int>(send_buffer.size()));
+ } else {
+ ASSERT_EQ(result, static_cast<int>(send_buffer.size()));
+ }
sent_packets[i] = send_buffer;
}
@@ -243,9 +248,11 @@
int pos = 0;
while (pos < static_cast<int>(send_buffer.size())) {
- TestCompletionCallback send_cb(instance_->pp_instance());
+ TestCompletionCallback send_cb(instance_->pp_instance(), force_async_);
int result = transport2_->Send(
&send_buffer[0] + pos, send_buffer.size() - pos, send_cb);
+ if (force_async_)
+ ASSERT_EQ(result, PP_OK_COMPLETIONPENDING);
if (result == PP_OK_COMPLETIONPENDING)
result = send_cb.WaitForResult();
ASSERT_TRUE(result > 0);
« no previous file with comments | « ppapi/tests/test_graphics_2d.cc ('k') | ppapi/tests/test_url_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698