| 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()); |
| 268 const uint32_t kByteLength = test_data.ByteLength(); | 273 const uint32_t kByteLength = test_data.ByteLength(); |
| 269 for (size_t j = 0; j < kByteLength; ++j) | 274 for (size_t j = 0; j < kByteLength; ++j) |
| 270 buff[j] = static_cast<uint8_t>(j % 256u); | 275 buff[j] = static_cast<uint8_t>(j % 256u); |
| 271 | 276 |
| 272 // Have the listener test some properties of the ArrayBuffer. | 277 // Have the listener test some properties of the ArrayBuffer. |
| 273 std::vector<std::string> properties_to_check; | 278 std::vector<std::string> properties_to_check; |
| 274 properties_to_check.push_back( | 279 properties_to_check.push_back( |
| 275 "message_event.data.constructor.name === 'ArrayBuffer'"); | 280 "message_event.data.constructor.name === 'ArrayBuffer'"); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 ASSERT_TRUE(received_value <= kThreadsToRun); | 482 ASSERT_TRUE(received_value <= kThreadsToRun); |
| 478 ++received_counts[received_value]; | 483 ++received_counts[received_value]; |
| 479 } | 484 } |
| 480 ASSERT_EQ(received_counts, expected_counts); | 485 ASSERT_EQ(received_counts, expected_counts); |
| 481 | 486 |
| 482 message_data_.clear(); | 487 message_data_.clear(); |
| 483 ASSERT_TRUE(ClearListeners()); | 488 ASSERT_TRUE(ClearListeners()); |
| 484 | 489 |
| 485 PASS(); | 490 PASS(); |
| 486 } | 491 } |
| OLD | NEW |