| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/tests/test_post_message.h" | 5 #include "ppapi/tests/test_post_message.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 int TestPostMessage::WaitForMessages() { | 288 int TestPostMessage::WaitForMessages() { |
| 289 size_t message_size_before = message_data_.size(); | 289 size_t message_size_before = message_data_.size(); |
| 290 // We first post a FINISHED_WAITING_MESSAGE. This should be guaranteed to | 290 // We first post a FINISHED_WAITING_MESSAGE. This should be guaranteed to |
| 291 // come back _after_ any other incoming messages that were already pending. | 291 // come back _after_ any other incoming messages that were already pending. |
| 292 instance_->PostMessage(pp::Var(FINISHED_WAITING_MESSAGE)); | 292 instance_->PostMessage(pp::Var(FINISHED_WAITING_MESSAGE)); |
| 293 testing_interface_->RunMessageLoop(instance_->pp_instance()); | 293 testing_interface_->RunMessageLoop(instance_->pp_instance()); |
| 294 // Now that the FINISHED_WAITING_MESSAGE has been echoed back to us, we know | 294 // Now that the FINISHED_WAITING_MESSAGE has been echoed back to us, we know |
| 295 // that all pending messages have been slurped up. Return the number we | 295 // that all pending messages have been slurped up. Return the number we |
| 296 // received (which may be zero). | 296 // received (which may be zero). |
| 297 return message_data_.size() - message_size_before; | 297 return static_cast<int>(message_data_.size() - message_size_before); |
| 298 } | 298 } |
| 299 | 299 |
| 300 std::string TestPostMessage::CheckMessageProperties( | 300 std::string TestPostMessage::CheckMessageProperties( |
| 301 const pp::Var& test_data, | 301 const pp::Var& test_data, |
| 302 const std::vector<std::string>& properties_to_check) { | 302 const std::vector<std::string>& properties_to_check) { |
| 303 typedef std::vector<std::string>::const_iterator Iterator; | 303 typedef std::vector<std::string>::const_iterator Iterator; |
| 304 for (Iterator iter = properties_to_check.begin(); | 304 for (Iterator iter = properties_to_check.begin(); |
| 305 iter != properties_to_check.end(); | 305 iter != properties_to_check.end(); |
| 306 ++iter) { | 306 ++iter) { |
| 307 ASSERT_TRUE(AddEchoingListener(*iter)); | 307 ASSERT_TRUE(AddEchoingListener(*iter)); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 std::string TestPostMessage::TestSendingResource() { | 587 std::string TestPostMessage::TestSendingResource() { |
| 588 // Clean up after previous tests. This also swallows the message sent by Init | 588 // Clean up after previous tests. This also swallows the message sent by Init |
| 589 // if we didn't run the 'SendInInit' test. All tests other than 'SendInInit' | 589 // if we didn't run the 'SendInInit' test. All tests other than 'SendInInit' |
| 590 // should start with these. | 590 // should start with these. |
| 591 WaitForMessages(); | 591 WaitForMessages(); |
| 592 message_data_.clear(); | 592 message_data_.clear(); |
| 593 ASSERT_TRUE(ClearListeners()); | 593 ASSERT_TRUE(ClearListeners()); |
| 594 | 594 |
| 595 std::string file_path("/"); | 595 std::string file_path("/"); |
| 596 file_path += kTestFilename; | 596 file_path += kTestFilename; |
| 597 int content_length = strlen(kTestString); | 597 int content_length = static_cast<int>(strlen(kTestString)); |
| 598 | 598 |
| 599 // Create a file in the HTML5 temporary file system, in the Pepper plugin. | 599 // Create a file in the HTML5 temporary file system, in the Pepper plugin. |
| 600 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); | 600 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
| 601 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); | 601 pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY); |
| 602 callback.WaitForResult(file_system.Open(1024, callback.GetCallback())); | 602 callback.WaitForResult(file_system.Open(1024, callback.GetCallback())); |
| 603 CHECK_CALLBACK_BEHAVIOR(callback); | 603 CHECK_CALLBACK_BEHAVIOR(callback); |
| 604 ASSERT_EQ(PP_OK, callback.result()); | 604 ASSERT_EQ(PP_OK, callback.result()); |
| 605 pp::FileRef write_file_ref(file_system, file_path.c_str()); | 605 pp::FileRef write_file_ref(file_system, file_path.c_str()); |
| 606 // Write to the file. | 606 // Write to the file. |
| 607 pp::FileIO write_file_io(instance_); | 607 pp::FileIO write_file_io(instance_); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 ASSERT_TRUE(received_value <= kThreadsToRun); | 909 ASSERT_TRUE(received_value <= kThreadsToRun); |
| 910 ++received_counts[received_value]; | 910 ++received_counts[received_value]; |
| 911 } | 911 } |
| 912 ASSERT_EQ(expected_counts, received_counts); | 912 ASSERT_EQ(expected_counts, received_counts); |
| 913 | 913 |
| 914 message_data_.clear(); | 914 message_data_.clear(); |
| 915 ASSERT_TRUE(ClearListeners()); | 915 ASSERT_TRUE(ClearListeners()); |
| 916 | 916 |
| 917 PASS(); | 917 PASS(); |
| 918 } | 918 } |
| OLD | NEW |