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

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

Issue 2637193002: Support spawnUri in app snapshots. (Closed)
Patch Set: Created 3 years, 11 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
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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "vm/compiler.h" 6 #include "vm/compiler.h"
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_mirrors_api.h" 8 #include "include/dart_mirrors_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 #include "include/dart_tools_api.h" 10 #include "include/dart_tools_api.h"
(...skipping 3479 matching lines...) Expand 10 before | Expand all | Expand 10 after
3490 EXPECT_EQ(iso_1, Dart_CurrentIsolate()); 3490 EXPECT_EQ(iso_1, Dart_CurrentIsolate());
3491 Dart_ShutdownIsolate(); 3491 Dart_ShutdownIsolate();
3492 EXPECT(NULL == Dart_CurrentIsolate()); 3492 EXPECT(NULL == Dart_CurrentIsolate());
3493 } 3493 }
3494 3494
3495 3495
3496 UNIT_TEST_CASE(CurrentIsolateData) { 3496 UNIT_TEST_CASE(CurrentIsolateData) {
3497 intptr_t mydata = 12345; 3497 intptr_t mydata = 12345;
3498 char* err; 3498 char* err;
3499 Dart_Isolate isolate = 3499 Dart_Isolate isolate =
3500 Dart_CreateIsolate(NULL, NULL, bin::isolate_snapshot_buffer, NULL, 3500 Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_buffer, NULL,
3501 reinterpret_cast<void*>(mydata), &err); 3501 reinterpret_cast<void*>(mydata), &err);
3502 EXPECT(isolate != NULL); 3502 EXPECT(isolate != NULL);
3503 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData())); 3503 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData()));
3504 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate))); 3504 EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate)));
3505 Dart_ShutdownIsolate(); 3505 Dart_ShutdownIsolate();
3506 } 3506 }
3507 3507
3508 3508
3509 UNIT_TEST_CASE(IsolateSetCheckedMode) { 3509 UNIT_TEST_CASE(IsolateSetCheckedMode) {
3510 const char* kScriptChars = 3510 const char* kScriptChars =
(...skipping 10 matching lines...) Expand all
3521 // Create an isolate with checked mode flags. 3521 // Create an isolate with checked mode flags.
3522 Dart_IsolateFlags api_flags; 3522 Dart_IsolateFlags api_flags;
3523 api_flags.version = DART_FLAGS_CURRENT_VERSION; 3523 api_flags.version = DART_FLAGS_CURRENT_VERSION;
3524 api_flags.enable_type_checks = true; 3524 api_flags.enable_type_checks = true;
3525 api_flags.enable_asserts = true; 3525 api_flags.enable_asserts = true;
3526 api_flags.enable_error_on_bad_type = true; 3526 api_flags.enable_error_on_bad_type = true;
3527 api_flags.enable_error_on_bad_override = true; 3527 api_flags.enable_error_on_bad_override = true;
3528 3528
3529 char* err; 3529 char* err;
3530 Dart_Isolate isolate = Dart_CreateIsolate( 3530 Dart_Isolate isolate = Dart_CreateIsolate(
3531 NULL, NULL, bin::isolate_snapshot_buffer, &api_flags, NULL, &err); 3531 NULL, NULL, bin::core_isolate_snapshot_buffer, &api_flags, NULL, &err);
3532 if (isolate == NULL) { 3532 if (isolate == NULL) {
3533 OS::Print("Creation of isolate failed '%s'\n", err); 3533 OS::Print("Creation of isolate failed '%s'\n", err);
3534 free(err); 3534 free(err);
3535 } 3535 }
3536 EXPECT(isolate != NULL); 3536 EXPECT(isolate != NULL);
3537 3537
3538 { 3538 {
3539 Dart_EnterScope(); 3539 Dart_EnterScope();
3540 Dart_Handle url = NewString(TestCase::url()); 3540 Dart_Handle url = NewString(TestCase::url());
3541 Dart_Handle source = NewString(kScriptChars); 3541 Dart_Handle source = NewString(kScriptChars);
(...skipping 4024 matching lines...) Expand 10 before | Expand all | Expand 10 after
7566 " while (true) {\n" // Infinite empty loop. 7566 " while (true) {\n" // Infinite empty loop.
7567 " }\n" 7567 " }\n"
7568 "}\n"; 7568 "}\n";
7569 7569
7570 // Tell the other thread that shared_isolate is created. 7570 // Tell the other thread that shared_isolate is created.
7571 Dart_Handle lib; 7571 Dart_Handle lib;
7572 { 7572 {
7573 MonitorLocker ml(sync); 7573 MonitorLocker ml(sync);
7574 char* error = NULL; 7574 char* error = NULL;
7575 shared_isolate = Dart_CreateIsolate( 7575 shared_isolate = Dart_CreateIsolate(
7576 NULL, NULL, bin::isolate_snapshot_buffer, NULL, NULL, &error); 7576 NULL, NULL, bin::core_isolate_snapshot_buffer, NULL, NULL, &error);
7577 EXPECT(shared_isolate != NULL); 7577 EXPECT(shared_isolate != NULL);
7578 Dart_EnterScope(); 7578 Dart_EnterScope();
7579 Dart_Handle url = NewString(TestCase::url()); 7579 Dart_Handle url = NewString(TestCase::url());
7580 Dart_Handle source = NewString(kScriptChars); 7580 Dart_Handle source = NewString(kScriptChars);
7581 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler); 7581 Dart_Handle result = Dart_SetLibraryTagHandler(TestCase::library_handler);
7582 EXPECT_VALID(result); 7582 EXPECT_VALID(result);
7583 lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0); 7583 lib = Dart_LoadScript(url, Dart_Null(), source, 0, 0);
7584 EXPECT_VALID(lib); 7584 EXPECT_VALID(lib);
7585 result = Dart_FinalizeLoading(false); 7585 result = Dart_FinalizeLoading(false);
7586 EXPECT_VALID(result); 7586 EXPECT_VALID(result);
(...skipping 30 matching lines...) Expand all
7617 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback(); 7617 Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback();
7618 Isolate::SetShutdownCallback(IsolateShutdownTestCallback); 7618 Isolate::SetShutdownCallback(IsolateShutdownTestCallback);
7619 7619
7620 saved_callback_data = NULL; 7620 saved_callback_data = NULL;
7621 7621
7622 void* my_data = reinterpret_cast<void*>(12345); 7622 void* my_data = reinterpret_cast<void*>(12345);
7623 7623
7624 // Create an isolate. 7624 // Create an isolate.
7625 char* err; 7625 char* err;
7626 Dart_Isolate isolate = Dart_CreateIsolate( 7626 Dart_Isolate isolate = Dart_CreateIsolate(
7627 NULL, NULL, bin::isolate_snapshot_buffer, NULL, my_data, &err); 7627 NULL, NULL, bin::core_isolate_snapshot_buffer, NULL, my_data, &err);
7628 if (isolate == NULL) { 7628 if (isolate == NULL) {
7629 OS::Print("Creation of isolate failed '%s'\n", err); 7629 OS::Print("Creation of isolate failed '%s'\n", err);
7630 free(err); 7630 free(err);
7631 } 7631 }
7632 EXPECT(isolate != NULL); 7632 EXPECT(isolate != NULL);
7633 7633
7634 // The shutdown callback has not been called. 7634 // The shutdown callback has not been called.
7635 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data)); 7635 EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data));
7636 7636
7637 // Shutdown the isolate. 7637 // Shutdown the isolate.
(...skipping 28 matching lines...) Expand all
7666 " return a + b;\n" 7666 " return a + b;\n"
7667 "}\n" 7667 "}\n"
7668 "\n" 7668 "\n"
7669 "void main() {\n" 7669 "void main() {\n"
7670 " add(4, 5);\n" 7670 " add(4, 5);\n"
7671 "}\n"; 7671 "}\n";
7672 7672
7673 // Create an isolate. 7673 // Create an isolate.
7674 char* err; 7674 char* err;
7675 Dart_Isolate isolate = Dart_CreateIsolate( 7675 Dart_Isolate isolate = Dart_CreateIsolate(
7676 NULL, NULL, bin::isolate_snapshot_buffer, NULL, NULL, &err); 7676 NULL, NULL, bin::core_isolate_snapshot_buffer, NULL, NULL, &err);
7677 if (isolate == NULL) { 7677 if (isolate == NULL) {
7678 OS::Print("Creation of isolate failed '%s'\n", err); 7678 OS::Print("Creation of isolate failed '%s'\n", err);
7679 free(err); 7679 free(err);
7680 } 7680 }
7681 EXPECT(isolate != NULL); 7681 EXPECT(isolate != NULL);
7682 7682
7683 Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback); 7683 Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback);
7684 7684
7685 { 7685 {
7686 Dart_EnterScope(); 7686 Dart_EnterScope();
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after
9909 EXPECT_VALID(result); 9909 EXPECT_VALID(result);
9910 result = Dart_FinalizeLoading(false); 9910 result = Dart_FinalizeLoading(false);
9911 EXPECT_VALID(result); 9911 EXPECT_VALID(result);
9912 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL); 9912 result = Dart_Invoke(lib, NewString("foozoo"), 0, NULL);
9913 EXPECT(Dart_IsError(result)); 9913 EXPECT(Dart_IsError(result));
9914 } 9914 }
9915 9915
9916 #endif // !PRODUCT 9916 #endif // !PRODUCT
9917 9917
9918 } // namespace dart 9918 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698