| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/message_handler.h" | 6 #include "vm/message_handler.h" |
| 7 #include "vm/os.h" | 7 #include "vm/os.h" |
| 8 #include "vm/port.h" | 8 #include "vm/port.h" |
| 9 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool HandleMessage(Message* message) { return true; } | 40 bool HandleMessage(Message* message) { return true; } |
| 41 | 41 |
| 42 int notify_count; | 42 int notify_count; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 | 45 |
| 46 TEST_CASE(PortMap_CreateAndCloseOnePort) { | 46 TEST_CASE(PortMap_CreateAndCloseOnePort) { |
| 47 PortTestMessageHandler handler; | 47 PortTestMessageHandler handler; |
| 48 intptr_t port = PortMap::CreatePort(&handler); | 48 Dart_Port port = PortMap::CreatePort(&handler); |
| 49 EXPECT_NE(0, port); | 49 EXPECT_NE(0, port); |
| 50 EXPECT(PortMapTestPeer::IsActivePort(port)); | 50 EXPECT(PortMapTestPeer::IsActivePort(port)); |
| 51 | 51 |
| 52 PortMap::ClosePort(port); | 52 PortMap::ClosePort(port); |
| 53 EXPECT(!PortMapTestPeer::IsActivePort(port)); | 53 EXPECT(!PortMapTestPeer::IsActivePort(port)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 TEST_CASE(PortMap_CreateAndCloseTwoPorts) { | 57 TEST_CASE(PortMap_CreateAndCloseTwoPorts) { |
| 58 PortTestMessageHandler handler; | 58 PortTestMessageHandler handler; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Dart_Port port = PortMap::CreatePort(&handler); | 94 Dart_Port port = PortMap::CreatePort(&handler); |
| 95 EXPECT(PortMapTestPeer::IsActivePort(port)); | 95 EXPECT(PortMapTestPeer::IsActivePort(port)); |
| 96 PortMap::ClosePort(port); | 96 PortMap::ClosePort(port); |
| 97 EXPECT(!PortMapTestPeer::IsActivePort(port)); | 97 EXPECT(!PortMapTestPeer::IsActivePort(port)); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 TEST_CASE(PortMap_SetLive) { | 102 TEST_CASE(PortMap_SetLive) { |
| 103 PortTestMessageHandler handler; | 103 PortTestMessageHandler handler; |
| 104 intptr_t port = PortMap::CreatePort(&handler); | 104 Dart_Port port = PortMap::CreatePort(&handler); |
| 105 EXPECT_NE(0, port); | 105 EXPECT_NE(0, port); |
| 106 EXPECT(PortMapTestPeer::IsActivePort(port)); | 106 EXPECT(PortMapTestPeer::IsActivePort(port)); |
| 107 EXPECT(!PortMapTestPeer::IsLivePort(port)); | 107 EXPECT(!PortMapTestPeer::IsLivePort(port)); |
| 108 | 108 |
| 109 PortMap::SetLive(port); | 109 PortMap::SetLive(port); |
| 110 EXPECT(PortMapTestPeer::IsActivePort(port)); | 110 EXPECT(PortMapTestPeer::IsActivePort(port)); |
| 111 EXPECT(PortMapTestPeer::IsLivePort(port)); | 111 EXPECT(PortMapTestPeer::IsLivePort(port)); |
| 112 | 112 |
| 113 PortMap::ClosePort(port); | 113 PortMap::ClosePort(port); |
| 114 EXPECT(!PortMapTestPeer::IsActivePort(port)); | 114 EXPECT(!PortMapTestPeer::IsActivePort(port)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 142 | 142 |
| 143 const char* message = "msg"; | 143 const char* message = "msg"; |
| 144 intptr_t message_len = strlen(message) + 1; | 144 intptr_t message_len = strlen(message) + 1; |
| 145 | 145 |
| 146 EXPECT(!PortMap::PostMessage(new Message( | 146 EXPECT(!PortMap::PostMessage(new Message( |
| 147 port, reinterpret_cast<uint8_t*>(strdup(message)), message_len, | 147 port, reinterpret_cast<uint8_t*>(strdup(message)), message_len, |
| 148 Message::kNormalPriority))); | 148 Message::kNormalPriority))); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace dart | 151 } // namespace dart |
| OLD | NEW |