Chromium Code Reviews| Index: vm/unit_test.h |
| =================================================================== |
| --- vm/unit_test.h (revision 1818) |
| +++ vm/unit_test.h (working copy) |
| @@ -162,10 +162,27 @@ |
| Dart_NativeEntryResolver resolver); |
| static Dart_Handle lib(); |
| static const char* url() { return "dart:test-lib"; } |
| + static Dart_Isolate CreateTestIsolateFromSnapshot(uint8_t* buffer) { |
| + return CreateIsolate(buffer); |
| + } |
| + static Dart_Isolate CreateTestIsolate() { |
| + return CreateIsolate(NULL); |
| + } |
| virtual void Run(); |
| private: |
| + static Dart_Isolate CreateIsolate(uint8_t* buffer) { |
| + Dart_ErrorBuffer err; |
| + static const int kErrorMsgLength = 256; |
| + err.buffer = reinterpret_cast<char*>(malloc(kErrorMsgLength)); |
| + err.length = kErrorMsgLength; |
| + Dart_Isolate isolate = Dart_CreateIsolate(buffer, NULL, err); |
|
turnidge
2011/11/28 18:39:58
You might as well add an if that prints the isolat
siva
2011/11/29 00:54:25
Done.
|
| + free(err.buffer); |
| + EXPECT(isolate != NULL); |
| + return isolate; |
| + } |
| + |
| RunEntry* const run_; |
| }; |
| @@ -173,8 +190,7 @@ |
| class TestIsolateScope { |
| public: |
| TestIsolateScope() { |
| - isolate_ = reinterpret_cast<Isolate*>(Dart_CreateIsolate(NULL, NULL)); |
| - EXPECT(isolate_ != NULL); |
| + isolate_ = reinterpret_cast<Isolate*>(TestCase::CreateTestIsolate()); |
| Dart_EnterScope(); // Create a Dart API scope for unit tests. |
| } |
| ~TestIsolateScope() { |