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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return expected == actual; | 125 return expected == actual; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 bool VarsEqual(const pp::Var& expected, | 129 bool VarsEqual(const pp::Var& expected, |
130 const pp::Var& actual) { | 130 const pp::Var& actual) { |
131 std::map<int64_t, int64_t> visited_ids; | 131 std::map<int64_t, int64_t> visited_ids; |
132 return VarsEqual(expected, actual, &visited_ids); | 132 return VarsEqual(expected, actual, &visited_ids); |
133 } | 133 } |
134 | 134 |
135 class ScopedArrayBufferSizeSetter { | |
136 public: | |
137 ScopedArrayBufferSizeSetter(const PPB_Testing_Private* interface, | |
138 PP_Instance instance, | |
139 uint32_t threshold) | |
140 : interface_(interface), | |
141 instance_(instance) { | |
142 interface_->SetMinimumArrayBufferSizeForShmem(instance_, threshold); | |
143 } | |
144 ~ScopedArrayBufferSizeSetter() { | |
145 interface_->SetMinimumArrayBufferSizeForShmem(instance_, 0); | |
146 } | |
147 private: | |
148 const PPB_Testing_Private* interface_; | |
149 PP_Instance instance_; | |
150 }; | |
151 | |
152 #define FINISHED_WAITING_MESSAGE "TEST_POST_MESSAGE_FINISHED_WAITING" | 135 #define FINISHED_WAITING_MESSAGE "TEST_POST_MESSAGE_FINISHED_WAITING" |
153 | 136 |
154 } // namespace | 137 } // namespace |
155 | 138 |
156 TestPostMessage::TestPostMessage(TestingInstance* instance) | 139 TestPostMessage::TestPostMessage(TestingInstance* instance) |
157 : TestCase(instance) { | 140 : TestCase(instance) { |
158 } | 141 } |
159 | 142 |
160 TestPostMessage::~TestPostMessage() { | 143 TestPostMessage::~TestPostMessage() { |
161 instance_->PostMessage(pp::Var("This isn't guaranteed to be received, but " | 144 instance_->PostMessage(pp::Var("This isn't guaranteed to be received, but " |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 ASSERT_TRUE(received_value <= kThreadsToRun); | 894 ASSERT_TRUE(received_value <= kThreadsToRun); |
912 ++received_counts[received_value]; | 895 ++received_counts[received_value]; |
913 } | 896 } |
914 ASSERT_EQ(expected_counts, received_counts); | 897 ASSERT_EQ(expected_counts, received_counts); |
915 | 898 |
916 message_data_.clear(); | 899 message_data_.clear(); |
917 ASSERT_TRUE(ClearListeners()); | 900 ASSERT_TRUE(ClearListeners()); |
918 | 901 |
919 PASS(); | 902 PASS(); |
920 } | 903 } |
OLD | NEW |