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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 uint32_t sizes[] = { 0, 100, 1000, 10000, 100000 }; | 256 uint32_t sizes[] = { 0, 100, 1000, 10000, 100000 }; |
257 for (size_t i = 0; i < sizeof(sizes)/sizeof(sizes[i]); ++i) { | 257 for (size_t i = 0; i < sizeof(sizes)/sizeof(sizes[i]); ++i) { |
258 std::ostringstream size_stream; | 258 std::ostringstream size_stream; |
259 size_stream << sizes[i]; | 259 size_stream << sizes[i]; |
260 const std::string kSizeAsString(size_stream.str()); | 260 const std::string kSizeAsString(size_stream.str()); |
261 | 261 |
262 // Create an appropriately sized array buffer with test_data[i] == i. | 262 // Create an appropriately sized array buffer with test_data[i] == i. |
263 pp::VarArrayBuffer_Dev test_data(sizes[i]); | 263 pp::VarArrayBuffer_Dev test_data(sizes[i]); |
264 if (sizes[i] > 0) | 264 if (sizes[i] > 0) |
265 ASSERT_NE(NULL, test_data.Map()); | 265 ASSERT_NE(NULL, test_data.Map()); |
| 266 // Make sure we can Unmap/Map successfully (there's not really any way to |
| 267 // detect if it's unmapped, so we just re-map before getting the pointer to |
| 268 // the buffer). |
| 269 test_data.Unmap(); |
| 270 test_data.Map(); |
266 ASSERT_EQ(sizes[i], test_data.ByteLength()); | 271 ASSERT_EQ(sizes[i], test_data.ByteLength()); |
267 unsigned char* buff = static_cast<unsigned char*>(test_data.Map()); | 272 unsigned char* buff = static_cast<unsigned char*>(test_data.Map()); |
| 273 test_data.Unmap(); |
| 274 test_data.Map(); |
268 const uint32_t kByteLength = test_data.ByteLength(); | 275 const uint32_t kByteLength = test_data.ByteLength(); |
269 for (size_t j = 0; j < kByteLength; ++j) | 276 for (size_t j = 0; j < kByteLength; ++j) |
270 buff[j] = static_cast<uint8_t>(j % 256u); | 277 buff[j] = static_cast<uint8_t>(j % 256u); |
271 | 278 |
272 // Have the listener test some properties of the ArrayBuffer. | 279 // Have the listener test some properties of the ArrayBuffer. |
273 std::vector<std::string> properties_to_check; | 280 std::vector<std::string> properties_to_check; |
274 properties_to_check.push_back( | 281 properties_to_check.push_back( |
275 "message_event.data.constructor.name === 'ArrayBuffer'"); | 282 "message_event.data.constructor.name === 'ArrayBuffer'"); |
276 properties_to_check.push_back( | 283 properties_to_check.push_back( |
277 std::string("message_event.data.byteLength === ") + kSizeAsString); | 284 std::string("message_event.data.byteLength === ") + kSizeAsString); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 ASSERT_TRUE(received_value <= kThreadsToRun); | 484 ASSERT_TRUE(received_value <= kThreadsToRun); |
478 ++received_counts[received_value]; | 485 ++received_counts[received_value]; |
479 } | 486 } |
480 ASSERT_EQ(received_counts, expected_counts); | 487 ASSERT_EQ(received_counts, expected_counts); |
481 | 488 |
482 message_data_.clear(); | 489 message_data_.clear(); |
483 ASSERT_TRUE(ClearListeners()); | 490 ASSERT_TRUE(ClearListeners()); |
484 | 491 |
485 PASS(); | 492 PASS(); |
486 } | 493 } |
OLD | NEW |