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

Side by Side Diff: vm/custom_isolate_test.cc

Issue 8673002: - Refactor the isolate callback mechanism to also include creation of the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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
« no previous file with comments | « vm/bootstrap_nocorelib.cc ('k') | vm/dart.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 6
7 #include "vm/unit_test.h" 7 #include "vm/unit_test.h"
8 8
9 // Custom Isolate Test. 9 // Custom Isolate Test.
10 // 10 //
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 EXPECT(Dart_IsString(param)); 349 EXPECT(Dart_IsString(param));
350 const char* isolate_main = NULL; 350 const char* isolate_main = NULL;
351 EXPECT_VALID(Dart_StringToCString(param, &isolate_main)); 351 EXPECT_VALID(Dart_StringToCString(param, &isolate_main));
352 isolate_main = strdup(isolate_main); 352 isolate_main = strdup(isolate_main);
353 353
354 // Save current isolate. 354 // Save current isolate.
355 Dart_Isolate saved_isolate = Dart_CurrentIsolate(); 355 Dart_Isolate saved_isolate = Dart_CurrentIsolate();
356 Dart_ExitIsolate(); 356 Dart_ExitIsolate();
357 357
358 // Create a new Dart_Isolate. 358 // Create a new Dart_Isolate.
359 Dart_Isolate new_isolate = Dart_CreateIsolate(NULL, NULL); 359 Dart_Isolate new_isolate = TestCase::CreateTestIsolate();
360 EXPECT(new_isolate != NULL);
360 Dart_SetMessageCallbacks(&PostMessage, &ClosePort); 361 Dart_SetMessageCallbacks(&PostMessage, &ClosePort);
361 Dart_Port new_port = Dart_GetMainPortId(); 362 Dart_Port new_port = Dart_GetMainPortId();
362 363
363 OS::Print("-- Adding StartEvent to queue --\n"); 364 OS::Print("-- Adding StartEvent to queue --\n");
364 event_queue->Add(new StartEvent(new_isolate, isolate_main)); 365 event_queue->Add(new StartEvent(new_isolate, isolate_main));
365 366
366 // Restore the original isolate. 367 // Restore the original isolate.
367 Dart_ExitIsolate(); 368 Dart_ExitIsolate();
368 Dart_EnterIsolate(saved_isolate); 369 Dart_EnterIsolate(saved_isolate);
369 Dart_EnterScope(); 370 Dart_EnterScope();
370 371
371 Dart_Handle send_port = Dart_NewSendPort(new_port); 372 Dart_Handle send_port = Dart_NewSendPort(new_port);
372 EXPECT_VALID(send_port); 373 EXPECT_VALID(send_port);
373 Dart_SetReturnValue(args, send_port); 374 Dart_SetReturnValue(args, send_port);
374 375
375 OS::Print("-- Exit: CustomIsolateImpl_start --\n"); 376 OS::Print("-- Exit: CustomIsolateImpl_start --\n");
376 Dart_ExitScope(); 377 Dart_ExitScope();
377 } 378 }
378 379
379 380
380 UNIT_TEST_CASE(CustomIsolates) { 381 UNIT_TEST_CASE(CustomIsolates) {
381 event_queue = new EventQueue(); 382 event_queue = new EventQueue();
382 current_event = NULL; 383 current_event = NULL;
383 384
384 Dart_CreateIsolate(NULL, NULL); 385 Dart_Isolate dart_isolate = TestCase::CreateTestIsolate();
386 EXPECT(dart_isolate != NULL);
385 Dart_SetMessageCallbacks(&PostMessage, &ClosePort); 387 Dart_SetMessageCallbacks(&PostMessage, &ClosePort);
386 Dart_EnterScope(); 388 Dart_EnterScope();
387 Dart_Handle result; 389 Dart_Handle result;
388 390
389 // Create a test library. 391 // Create a test library.
390 Dart_Handle lib = TestCase::LoadTestScript(kCustomIsolateScriptChars, 392 Dart_Handle lib = TestCase::LoadTestScript(kCustomIsolateScriptChars,
391 NativeLookup); 393 NativeLookup);
392 EXPECT_VALID(lib); 394 EXPECT_VALID(lib);
393 395
394 // Run main. 396 // Run main.
(...skipping 23 matching lines...) Expand all
418 OS::Print("-- Finished event loop --\n"); 420 OS::Print("-- Finished event loop --\n");
419 EXPECT_STREQ("Received: 43", saved_echo); 421 EXPECT_STREQ("Received: 43", saved_echo);
420 free(const_cast<char*>(saved_echo)); 422 free(const_cast<char*>(saved_echo));
421 423
422 delete event_queue; 424 delete event_queue;
423 } 425 }
424 426
425 #endif // TARGET_ARCH_IA32. 427 #endif // TARGET_ARCH_IA32.
426 428
427 } // namespace dart 429 } // namespace dart
OLDNEW
« no previous file with comments | « vm/bootstrap_nocorelib.cc ('k') | vm/dart.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698