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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
10 #include "vm/thread.h" | 10 #include "vm/thread.h" |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 EXPECT_EQ(iso_2, Dart_CurrentIsolate()); | 1003 EXPECT_EQ(iso_2, Dart_CurrentIsolate()); |
1004 Dart_ShutdownIsolate(); | 1004 Dart_ShutdownIsolate(); |
1005 EXPECT(NULL == Dart_CurrentIsolate()); | 1005 EXPECT(NULL == Dart_CurrentIsolate()); |
1006 Dart_EnterIsolate(iso_1); | 1006 Dart_EnterIsolate(iso_1); |
1007 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); | 1007 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); |
1008 Dart_ShutdownIsolate(); | 1008 Dart_ShutdownIsolate(); |
1009 EXPECT(NULL == Dart_CurrentIsolate()); | 1009 EXPECT(NULL == Dart_CurrentIsolate()); |
1010 } | 1010 } |
1011 | 1011 |
1012 | 1012 |
1013 static bool MyPostMessageCallback(Dart_Isolate dest_isolate, | 1013 static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) { |
1014 Dart_Port send_port, | |
1015 Dart_Port reply_port, | |
1016 Dart_Message message) { | |
1017 return true; | |
1018 } | |
1019 | |
1020 | |
1021 static void MyClosePortCallback(Dart_Isolate dest_isolate, | |
1022 Dart_Port port) { | |
1023 } | 1014 } |
1024 | 1015 |
1025 | 1016 |
1026 UNIT_TEST_CASE(SetMessageCallbacks) { | 1017 UNIT_TEST_CASE(SetMessageCallbacks) { |
1027 Dart_Isolate dart_isolate = TestCase::CreateTestIsolate(); | 1018 Dart_Isolate dart_isolate = TestCase::CreateTestIsolate(); |
1028 Dart_SetMessageCallbacks(&MyPostMessageCallback, &MyClosePortCallback); | 1019 Dart_SetMessageNotifyCallback(&MyMessageNotifyCallback); |
1029 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 1020 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
1030 EXPECT_EQ(&MyPostMessageCallback, isolate->post_message_callback()); | 1021 EXPECT_EQ(&MyMessageNotifyCallback, isolate->message_notify_callback()); |
1031 EXPECT_EQ(&MyClosePortCallback, isolate->close_port_callback()); | |
1032 Dart_ShutdownIsolate(); | 1022 Dart_ShutdownIsolate(); |
1033 } | 1023 } |
1034 | 1024 |
1035 | 1025 |
1036 // Only ia32 and x64 can run execution tests. | 1026 // Only ia32 and x64 can run execution tests. |
1037 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 1027 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
1038 | 1028 |
1039 TEST_CASE(FieldAccess) { | 1029 TEST_CASE(FieldAccess) { |
1040 const char* kScriptChars = | 1030 const char* kScriptChars = |
1041 "class Fields {\n" | 1031 "class Fields {\n" |
(...skipping 1967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3009 // We should have received the expected number of interrupts. | 2999 // We should have received the expected number of interrupts. |
3010 EXPECT_EQ(kInterruptCount, interrupt_count); | 3000 EXPECT_EQ(kInterruptCount, interrupt_count); |
3011 | 3001 |
3012 // Give the spawned thread enough time to properly exit. | 3002 // Give the spawned thread enough time to properly exit. |
3013 Isolate::SetInterruptCallback(saved); | 3003 Isolate::SetInterruptCallback(saved); |
3014 } | 3004 } |
3015 | 3005 |
3016 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3006 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
3017 | 3007 |
3018 } // namespace dart | 3008 } // namespace dart |
OLD | NEW |