| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/edk/system/raw_channel.h" | 5 #include "mojo/edk/system/raw_channel.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 32 | 32 |
| 33 namespace mojo { | 33 namespace mojo { |
| 34 namespace system { | 34 namespace system { |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 scoped_ptr<MessageInTransit> MakeTestMessage(uint32_t num_bytes) { | 37 scoped_ptr<MessageInTransit> MakeTestMessage(uint32_t num_bytes) { |
| 38 std::vector<unsigned char> bytes(num_bytes, 0); | 38 std::vector<unsigned char> bytes(num_bytes, 0); |
| 39 for (size_t i = 0; i < num_bytes; i++) | 39 for (size_t i = 0; i < num_bytes; i++) |
| 40 bytes[i] = static_cast<unsigned char>(i + num_bytes); | 40 bytes[i] = static_cast<unsigned char>(i + num_bytes); |
| 41 return make_scoped_ptr( | 41 return make_scoped_ptr(new MessageInTransit( |
| 42 new MessageInTransit(MessageInTransit::kTypeMessagePipeEndpoint, | 42 MessageInTransit::kTypeEndpoint, MessageInTransit::kSubtypeEndpointData, |
| 43 MessageInTransit::kSubtypeMessagePipeEndpointData, | 43 num_bytes, bytes.empty() ? nullptr : &bytes[0])); |
| 44 num_bytes, bytes.empty() ? nullptr : &bytes[0])); | |
| 45 } | 44 } |
| 46 | 45 |
| 47 bool CheckMessageData(const void* bytes, uint32_t num_bytes) { | 46 bool CheckMessageData(const void* bytes, uint32_t num_bytes) { |
| 48 const unsigned char* b = static_cast<const unsigned char*>(bytes); | 47 const unsigned char* b = static_cast<const unsigned char*>(bytes); |
| 49 for (uint32_t i = 0; i < num_bytes; i++) { | 48 for (uint32_t i = 0; i < num_bytes; i++) { |
| 50 if (b[i] != static_cast<unsigned char>(i + num_bytes)) | 49 if (b[i] != static_cast<unsigned char>(i + num_bytes)) |
| 51 return false; | 50 return false; |
| 52 } | 51 } |
| 53 return true; | 52 return true; |
| 54 } | 53 } |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 674 |
| 676 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); | 675 EXPECT_FALSE(rc->WriteMessage(MakeTestMessage(1))); |
| 677 | 676 |
| 678 // Wait for the delegate, which will shut the |RawChannel| down. | 677 // Wait for the delegate, which will shut the |RawChannel| down. |
| 679 delegate.Wait(); | 678 delegate.Wait(); |
| 680 } | 679 } |
| 681 | 680 |
| 682 } // namespace | 681 } // namespace |
| 683 } // namespace system | 682 } // namespace system |
| 684 } // namespace mojo | 683 } // namespace mojo |
| OLD | NEW |