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

Unified Diff: ppapi/tests/test_post_message.cc

Issue 6745015: Make PPAPI PostMessage behave asynchronously. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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 | « chrome/test/ui/ppapi_uitest.cc ('k') | webkit/plugins/ppapi/message_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_post_message.cc
===================================================================
--- ppapi/tests/test_post_message.cc (revision 79483)
+++ ppapi/tests/test_post_message.cc (working copy)
@@ -51,6 +51,7 @@
void TestPostMessage::HandleMessage(const pp::Var& message_data) {
message_data_.push_back(message_data);
+ testing_interface_->QuitMessageLoop(instance_->pp_instance());
}
bool TestPostMessage::MakeOnMessageEcho(const std::string& expression) {
@@ -74,20 +75,26 @@
// the data back to us, and we check that they match.
message_data_.clear();
instance_->PostMessage(pp::Var(kTestString));
- // Note that the trusted in-process version is completely synchronous, so we
- // do not need to use 'RunMessageLoop' to wait.
+ // PostMessage is asynchronous, so we should not receive a response yet.
+ ASSERT_EQ(message_data_.size(), 0);
+
+ testing_interface_->RunMessageLoop(instance_->pp_instance());
ASSERT_EQ(message_data_.size(), 1);
ASSERT_TRUE(message_data_.back().is_string());
ASSERT_EQ(message_data_.back().AsString(), kTestString);
message_data_.clear();
instance_->PostMessage(pp::Var(kTestBool));
+ ASSERT_EQ(message_data_.size(), 0);
+ testing_interface_->RunMessageLoop(instance_->pp_instance());
ASSERT_EQ(message_data_.size(), 1);
ASSERT_TRUE(message_data_.back().is_bool());
ASSERT_EQ(message_data_.back().AsBool(), kTestBool);
message_data_.clear();
instance_->PostMessage(pp::Var(kTestInt));
+ ASSERT_EQ(message_data_.size(), 0);
+ testing_interface_->RunMessageLoop(instance_->pp_instance());
ASSERT_EQ(message_data_.size(), 1);
ASSERT_TRUE(message_data_.back().is_number());
ASSERT_DOUBLE_EQ(message_data_.back().AsDouble(),
@@ -95,17 +102,23 @@
message_data_.clear();
instance_->PostMessage(pp::Var(kTestDouble));
+ ASSERT_EQ(message_data_.size(), 0);
+ testing_interface_->RunMessageLoop(instance_->pp_instance());
ASSERT_EQ(message_data_.size(), 1);
ASSERT_TRUE(message_data_.back().is_number());
ASSERT_DOUBLE_EQ(message_data_.back().AsDouble(), kTestDouble);
message_data_.clear();
instance_->PostMessage(pp::Var());
+ ASSERT_EQ(message_data_.size(), 0);
+ testing_interface_->RunMessageLoop(instance_->pp_instance());
ASSERT_EQ(message_data_.size(), 1);
ASSERT_TRUE(message_data_.back().is_undefined());
message_data_.clear();
instance_->PostMessage(pp::Var(pp::Var::Null()));
+ ASSERT_EQ(message_data_.size(), 0);
+ testing_interface_->RunMessageLoop(instance_->pp_instance());
ASSERT_EQ(message_data_.size(), 1);
ASSERT_TRUE(message_data_.back().is_null());
@@ -121,6 +134,8 @@
ASSERT_TRUE(MakeOnMessageEcho("typeof(message_event)"));
message_data_.clear();
instance_->PostMessage(pp::Var(kTestInt));
+ ASSERT_EQ(message_data_.size(), 0);
+ testing_interface_->RunMessageLoop(instance_->pp_instance());
ASSERT_EQ(message_data_.size(), 1);
ASSERT_TRUE(message_data_.back().is_string());
ASSERT_EQ(message_data_.back().AsString(), "object");
@@ -136,8 +151,8 @@
ASSERT_TRUE(success);
message_data_.clear();
instance_->PostMessage(pp::Var(kTestInt));
- // Note that the trusted in-process version is completely synchronous, so we
- // do not need to use 'RunMessageLoop' to wait.
+ ASSERT_EQ(message_data_.size(), 0);
+ testing_interface_->RunMessageLoop(instance_->pp_instance());
ASSERT_EQ(message_data_.size(), 1);
ASSERT_TRUE(message_data_.back().is_bool());
ASSERT_TRUE(message_data_.back().AsBool());
@@ -159,6 +174,7 @@
// don't crash).
message_data_.clear();
instance_->PostMessage(pp::Var());
+ testing_interface_->RunMessageLoop(instance_->pp_instance());
ASSERT_EQ(message_data_.size(), 0);
PASS();
« no previous file with comments | « chrome/test/ui/ppapi_uitest.cc ('k') | webkit/plugins/ppapi/message_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698