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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 1130753006: Hide Isolate pointer from embedder (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 78d12cf437ed1c9e9345e2a39378febfc0ce36ed..8e609ab7cae35b53e7c71cf991c4f7dd0d46a9c3 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -3674,40 +3674,43 @@ UNIT_TEST_CASE(LocalZoneMemory) {
UNIT_TEST_CASE(Isolates) {
- // This test currently assumes that the Dart_Isolate type is an opaque
- // representation of Isolate*.
Dart_Isolate iso_1 = TestCase::CreateTestIsolate();
EXPECT_EQ(iso_1, Api::CastIsolate(Isolate::Current()));
Dart_Isolate isolate = Dart_CurrentIsolate();
EXPECT_EQ(iso_1, isolate);
Dart_ExitIsolate();
- EXPECT(NULL == Dart_CurrentIsolate());
+ EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate());
+ // Test that Dart_EnterIsolate returns an error when passed a bad isolate id.
+ EXPECT(!Dart_EnterIsolate(DART_ILLEGAL_ISOLATE));
Dart_Isolate iso_2 = TestCase::CreateTestIsolate();
EXPECT_EQ(iso_2, Dart_CurrentIsolate());
Dart_ExitIsolate();
- EXPECT(NULL == Dart_CurrentIsolate());
+ EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate());
Dart_EnterIsolate(iso_2);
EXPECT_EQ(iso_2, Dart_CurrentIsolate());
Dart_ShutdownIsolate();
- EXPECT(NULL == Dart_CurrentIsolate());
+ EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate());
Dart_EnterIsolate(iso_1);
EXPECT_EQ(iso_1, Dart_CurrentIsolate());
Dart_ShutdownIsolate();
- EXPECT(NULL == Dart_CurrentIsolate());
+ EXPECT(DART_ILLEGAL_ISOLATE == Dart_CurrentIsolate());
}
UNIT_TEST_CASE(CurrentIsolateData) {
intptr_t mydata = 12345;
char* err;
+ // We expect that Dart_Port and Dart_Isolate are the same size.
+ EXPECT_EQ(sizeof(Dart_Port), sizeof(Dart_Isolate));
Dart_Isolate isolate =
Dart_CreateIsolate(NULL, NULL, bin::isolate_snapshot_buffer,
reinterpret_cast<void*>(mydata),
&err);
- EXPECT(isolate != NULL);
+ EXPECT(isolate != DART_ILLEGAL_ISOLATE);
EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_CurrentIsolateData()));
EXPECT_EQ(mydata, reinterpret_cast<intptr_t>(Dart_IsolateData(isolate)));
Dart_ShutdownIsolate();
+ EXPECT(Dart_IsolateData(DART_ILLEGAL_ISOLATE) == NULL);
}
@@ -3756,7 +3759,7 @@ static void MyMessageNotifyCallback(Dart_Isolate dest_isolate) {
UNIT_TEST_CASE(SetMessageCallbacks) {
Dart_Isolate dart_isolate = TestCase::CreateTestIsolate();
Dart_SetMessageNotifyCallback(&MyMessageNotifyCallback);
- Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate);
+ Isolate* isolate = Api::CastIsolate(dart_isolate);
EXPECT_EQ(&MyMessageNotifyCallback, isolate->message_notify_callback());
Dart_ShutdownIsolate();
}
@@ -7224,7 +7227,7 @@ void NewNativePort_send321(Dart_Port dest_port_id,
TEST_CASE(IllegalNewSendPort) {
- Dart_Handle error = Dart_NewSendPort(ILLEGAL_PORT);
+ Dart_Handle error = Dart_NewSendPort(DART_ILLEGAL_PORT);
EXPECT(Dart_IsError(error));
EXPECT(Dart_IsApiError(error));
}
@@ -7232,7 +7235,7 @@ TEST_CASE(IllegalNewSendPort) {
TEST_CASE(IllegalPost) {
Dart_Handle message = Dart_True();
- bool success = Dart_Post(ILLEGAL_PORT, message);
+ bool success = Dart_Post(DART_ILLEGAL_PORT, message);
EXPECT(!success);
}
@@ -7240,7 +7243,7 @@ TEST_CASE(IllegalPost) {
UNIT_TEST_CASE(NewNativePort) {
// Create a port with a bogus handler.
Dart_Port error_port = Dart_NewNativePort("Foo", NULL, true);
- EXPECT_EQ(ILLEGAL_PORT, error_port);
+ EXPECT_EQ(DART_ILLEGAL_PORT, error_port);
// Create the port w/o a current isolate, just to make sure that works.
Dart_Port port_id1 =
@@ -7326,11 +7329,11 @@ static Dart_Isolate RunLoopTestCallback(const char* script_name,
" };\n"
"}\n";
- if (Dart_CurrentIsolate() != NULL) {
+ if (Dart_CurrentIsolate() != DART_ILLEGAL_ISOLATE) {
Dart_ExitIsolate();
}
Dart_Isolate isolate = TestCase::CreateTestIsolate(script_name);
- ASSERT(isolate != NULL);
+ ASSERT(isolate != DART_ILLEGAL_ISOLATE);
if (Dart_IsServiceIsolate(isolate)) {
return isolate;
}
@@ -7476,7 +7479,7 @@ void BusyLoop_start(uword unused) {
shared_isolate = Dart_CreateIsolate(NULL, NULL,
bin::isolate_snapshot_buffer,
NULL, &error);
- EXPECT(shared_isolate != NULL);
+ EXPECT(shared_isolate != DART_ILLEGAL_ISOLATE);
Dart_EnterScope();
Dart_Handle url = NewString(TestCase::url());
Dart_Handle source = NewString(kScriptChars);
@@ -7555,6 +7558,10 @@ TEST_CASE(IsolateInterrupt) {
}
}
+ // Test that Dart_InterruptIsolate returns false when passed an illegal
+ // isolate.
+ EXPECT(!Dart_InterruptIsolate(DART_ILLEGAL_ISOLATE));
+
// Send a number of interrupts to the other isolate. All but the
// last allow execution to continue. The last causes an exception in
// the isolate.
@@ -7575,7 +7582,7 @@ TEST_CASE(IsolateInterrupt) {
{
MonitorLocker ml(sync);
// Wait for our isolate to finish.
- while (shared_isolate != NULL) {
+ while (shared_isolate != DART_ILLEGAL_ISOLATE) {
ml.Wait();
}
}
@@ -7604,11 +7611,11 @@ UNIT_TEST_CASE(IsolateShutdown) {
Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL,
bin::isolate_snapshot_buffer,
my_data, &err);
- if (isolate == NULL) {
+ if (isolate == DART_ILLEGAL_ISOLATE) {
OS::Print("Creation of isolate failed '%s'\n", err);
free(err);
}
- EXPECT(isolate != NULL);
+ EXPECT(isolate != DART_ILLEGAL_ISOLATE);
// The shutdown callback has not been called.
EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data));
@@ -7654,11 +7661,11 @@ UNIT_TEST_CASE(IsolateShutdownRunDartCode) {
Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL,
bin::isolate_snapshot_buffer,
NULL, &err);
- if (isolate == NULL) {
+ if (isolate == DART_ILLEGAL_ISOLATE) {
OS::Print("Creation of isolate failed '%s'\n", err);
free(err);
}
- EXPECT(isolate != NULL);
+ EXPECT(isolate != DART_ILLEGAL_ISOLATE);
Isolate::SetShutdownCallback(IsolateShutdownRunDartCodeTestCallback);
@@ -7681,7 +7688,7 @@ UNIT_TEST_CASE(IsolateShutdownRunDartCode) {
// The shutdown callback has not been called.
EXPECT_EQ(0, add_result);
- EXPECT(isolate != NULL);
+ EXPECT(isolate != DART_ILLEGAL_ISOLATE);
// Shutdown the isolate.
Dart_ShutdownIsolate();
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698