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

Unified Diff: vm/dart_api_impl_test.cc

Issue 10450016: Add a callback to inform embedders when an isolate is being shut down. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | « vm/dart_api_impl.cc ('k') | vm/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/dart_api_impl_test.cc
===================================================================
--- vm/dart_api_impl_test.cc (revision 7933)
+++ vm/dart_api_impl_test.cc (working copy)
@@ -4707,10 +4707,42 @@
// We should have received the expected number of interrupts.
EXPECT_EQ(kInterruptCount, interrupt_count);
- // Give the spawned thread enough time to properly exit.
Isolate::SetInterruptCallback(saved);
}
+static void* saved_callback_data;
+static void IsolateShutdownTestCallback(void* callback_data) {
+ saved_callback_data = callback_data;
+}
+
+UNIT_TEST_CASE(IsolateShutdown) {
+ Dart_IsolateShutdownCallback saved = Isolate::ShutdownCallback();
+ Isolate::SetShutdownCallback(IsolateShutdownTestCallback);
+
+ saved_callback_data = NULL;
+
+ void* my_data = reinterpret_cast<void*>(12345);
+
+ // Create an isolate.
+ char* err;
+ Dart_Isolate isolate = Dart_CreateIsolate(NULL, NULL, NULL, my_data, &err);
+ if (isolate == NULL) {
+ OS::Print("Creation of isolate failed '%s'\n", err);
+ free(err);
+ }
+ EXPECT(isolate != NULL);
+
+ // The shutdown callback has not been called.
+ EXPECT_EQ(0, reinterpret_cast<intptr_t>(saved_callback_data));
+
+ // Shutdown the isolate.
+ Dart_ShutdownIsolate();
+
+ // The shutdown callback has been called.
+ EXPECT_EQ(12345, reinterpret_cast<intptr_t>(saved_callback_data));
+
+ Isolate::SetShutdownCallback(saved);
+}
#endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
} // namespace dart
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698