| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "ppapi/c/dev/ppb_testing_dev.h" | 10 #include "ppapi/c/dev/ppb_testing_dev.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 REGISTER_TEST_CASE(PostMessage); | 24 REGISTER_TEST_CASE(PostMessage); |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 const char kTestString[] = "Hello world!"; | 28 const char kTestString[] = "Hello world!"; |
| 29 const bool kTestBool = true; | 29 const bool kTestBool = true; |
| 30 const int32_t kTestInt = 42; | 30 const int32_t kTestInt = 42; |
| 31 const double kTestDouble = 42.0; | 31 const double kTestDouble = 42.0; |
| 32 |
| 33 // On Windows XP bots, the NonMainThread test can run very slowly. So we dial |
| 34 // back the number of threads & messages when running on Windows. |
| 35 #ifdef PPAPI_OS_WIN |
| 36 const int32_t kThreadsToRun = 2; |
| 37 const int32_t kMessagesToSendPerThread = 5; |
| 38 #else |
| 32 const int32_t kThreadsToRun = 4; | 39 const int32_t kThreadsToRun = 4; |
| 33 const int32_t kMessagesToSendPerThread = 10; | 40 const int32_t kMessagesToSendPerThread = 10; |
| 41 #endif |
| 34 | 42 |
| 35 // The struct that invoke_post_message_thread_func expects for its argument. | 43 // The struct that invoke_post_message_thread_func expects for its argument. |
| 36 // It includes the instance on which to invoke PostMessage, and the value to | 44 // It includes the instance on which to invoke PostMessage, and the value to |
| 37 // pass to PostMessage. | 45 // pass to PostMessage. |
| 38 struct InvokePostMessageThreadArg { | 46 struct InvokePostMessageThreadArg { |
| 39 InvokePostMessageThreadArg(pp::Instance* i, const pp::Var& v) | 47 InvokePostMessageThreadArg(pp::Instance* i, const pp::Var& v) |
| 40 : instance(i), value_to_send(v) {} | 48 : instance(i), value_to_send(v) {} |
| 41 pp::Instance* instance; | 49 pp::Instance* instance; |
| 42 pp::Var value_to_send; | 50 pp::Var value_to_send; |
| 43 }; | 51 }; |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 ASSERT_TRUE(received_value <= kThreadsToRun); | 490 ASSERT_TRUE(received_value <= kThreadsToRun); |
| 483 ++received_counts[received_value]; | 491 ++received_counts[received_value]; |
| 484 } | 492 } |
| 485 ASSERT_EQ(received_counts, expected_counts); | 493 ASSERT_EQ(received_counts, expected_counts); |
| 486 | 494 |
| 487 message_data_.clear(); | 495 message_data_.clear(); |
| 488 ASSERT_TRUE(ClearListeners()); | 496 ASSERT_TRUE(ClearListeners()); |
| 489 | 497 |
| 490 PASS(); | 498 PASS(); |
| 491 } | 499 } |
| OLD | NEW |