Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 9347040: Add API function Dart_ZoneAllocate (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 3155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3166 3166
3167 3167
3168 void NewNativePort_send123(Dart_Port dest_port_id, 3168 void NewNativePort_send123(Dart_Port dest_port_id,
3169 Dart_Port reply_port_id, 3169 Dart_Port reply_port_id,
3170 Dart_CObject *message) { 3170 Dart_CObject *message) {
3171 // Gets a null message. 3171 // Gets a null message.
3172 EXPECT_NOTNULL(message); 3172 EXPECT_NOTNULL(message);
3173 EXPECT_EQ(Dart_CObject::kNull, message->type); 3173 EXPECT_EQ(Dart_CObject::kNull, message->type);
3174 3174
3175 // Post integer value. 3175 // Post integer value.
3176 Dart_CObject response; 3176 Dart_CObject* response =
3177 response.type = Dart_CObject::kInt32; 3177 reinterpret_cast<Dart_CObject*>(Dart_ZoneAllocate(sizeof(Dart_CObject)));
3178 response.value.as_int32 = 123; 3178 response->type = Dart_CObject::kInt32;
3179 Dart_PostCObject(reply_port_id, &response); 3179 response->value.as_int32 = 123;
3180 Dart_PostCObject(reply_port_id, response);
3180 } 3181 }
3181 3182
3182 3183
3183 void NewNativePort_send321(Dart_Port dest_port_id, 3184 void NewNativePort_send321(Dart_Port dest_port_id,
3184 Dart_Port reply_port_id, 3185 Dart_Port reply_port_id,
3185 Dart_CObject* message) { 3186 Dart_CObject* message) {
3186 // Gets a null message. 3187 // Gets a null message.
3187 EXPECT_NOTNULL(message); 3188 EXPECT_NOTNULL(message);
3188 EXPECT_EQ(Dart_CObject::kNull, message->type); 3189 EXPECT_EQ(Dart_CObject::kNull, message->type);
3189 3190
3190 // Post integer value. 3191 // Post integer value.
3191 Dart_CObject response; 3192 Dart_CObject* response =
3192 response.type = Dart_CObject::kInt32; 3193 reinterpret_cast<Dart_CObject*>(Dart_ZoneAllocate(sizeof(Dart_CObject)));
3193 response.value.as_int32 = 321; 3194 response->type = Dart_CObject::kInt32;
3194 Dart_PostCObject(reply_port_id, &response); 3195 response->value.as_int32 = 321;
3196 Dart_PostCObject(reply_port_id, response);
3195 } 3197 }
3196 3198
3197 3199
3198 UNIT_TEST_CASE(NewNativePort) { 3200 UNIT_TEST_CASE(NewNativePort) {
3199 // Create a port with a bogus handler. 3201 // Create a port with a bogus handler.
3200 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true); 3202 Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true);
3201 EXPECT_EQ(kIllegalPort, error_port); 3203 EXPECT_EQ(kIllegalPort, error_port);
3202 3204
3203 // Create the port w/o a current isolate, just to make sure that works. 3205 // Create the port w/o a current isolate, just to make sure that works.
3204 Dart_Port port_id1 = 3206 Dart_Port port_id1 =
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
3514 // We should have received the expected number of interrupts. 3516 // We should have received the expected number of interrupts.
3515 EXPECT_EQ(kInterruptCount, interrupt_count); 3517 EXPECT_EQ(kInterruptCount, interrupt_count);
3516 3518
3517 // Give the spawned thread enough time to properly exit. 3519 // Give the spawned thread enough time to properly exit.
3518 Isolate::SetInterruptCallback(saved); 3520 Isolate::SetInterruptCallback(saved);
3519 } 3521 }
3520 3522
3521 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 3523 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
3522 3524
3523 } // namespace dart 3525 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698