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

Side by Side Diff: vm/unit_test.h

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/thread_win.cc ('k') | vm/unit_test.cc » ('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 #ifndef VM_UNIT_TEST_H_ 5 #ifndef VM_UNIT_TEST_H_
6 #define VM_UNIT_TEST_H_ 6 #define VM_UNIT_TEST_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "vm/ast.h" 10 #include "vm/ast.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 class TestCase : TestCaseBase { 155 class TestCase : TestCaseBase {
156 public: 156 public:
157 typedef void (RunEntry)(); 157 typedef void (RunEntry)();
158 158
159 TestCase(RunEntry* run, const char* name) : TestCaseBase(name), run_(run) { } 159 TestCase(RunEntry* run, const char* name) : TestCaseBase(name), run_(run) { }
160 160
161 static Dart_Handle LoadTestScript(const char* script, 161 static Dart_Handle LoadTestScript(const char* script,
162 Dart_NativeEntryResolver resolver); 162 Dart_NativeEntryResolver resolver);
163 static Dart_Handle lib(); 163 static Dart_Handle lib();
164 static const char* url() { return "dart:test-lib"; } 164 static const char* url() { return "dart:test-lib"; }
165 static Dart_Isolate CreateTestIsolateFromSnapshot(uint8_t* buffer) {
166 return CreateIsolate(buffer);
167 }
168 static Dart_Isolate CreateTestIsolate() {
169 return CreateIsolate(NULL);
170 }
171 static Dart_Handle library_handler(Dart_LibraryTag tag,
172 Dart_Handle library,
173 Dart_Handle url);
165 174
166 virtual void Run(); 175 virtual void Run();
167 176
168 private: 177 private:
178 static Dart_Isolate CreateIsolate(uint8_t* buffer) {
179 char* err;
180 Dart_Isolate isolate = Dart_CreateIsolate(buffer, NULL, &err);
181 if (isolate == NULL) {
182 OS::Print("Creation of isolate failed '%s'\n", err);
183 free(err);
184 }
185 EXPECT(isolate != NULL);
186 return isolate;
187 }
188
169 RunEntry* const run_; 189 RunEntry* const run_;
170 }; 190 };
171 191
172 192
173 class TestIsolateScope { 193 class TestIsolateScope {
174 public: 194 public:
175 TestIsolateScope() { 195 TestIsolateScope() {
176 isolate_ = reinterpret_cast<Isolate*>(Dart_CreateIsolate(NULL, NULL)); 196 isolate_ = reinterpret_cast<Isolate*>(TestCase::CreateTestIsolate());
177 EXPECT(isolate_ != NULL);
178 Dart_EnterScope(); // Create a Dart API scope for unit tests. 197 Dart_EnterScope(); // Create a Dart API scope for unit tests.
179 } 198 }
180 ~TestIsolateScope() { 199 ~TestIsolateScope() {
181 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. 200 Dart_ExitScope(); // Exit the Dart API scope created for unit tests.
182 ASSERT(isolate_ == Isolate::Current()); 201 ASSERT(isolate_ == Isolate::Current());
183 Dart_ShutdownIsolate(); 202 Dart_ShutdownIsolate();
184 isolate_ = NULL; 203 isolate_ = NULL;
185 } 204 }
186 Isolate* isolate() const { return isolate_; } 205 Isolate* isolate() const { return isolate_; }
187 206
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 273
255 #define EXPECT_VALID(handle) \ 274 #define EXPECT_VALID(handle) \
256 if (Dart_IsError((handle))) { \ 275 if (Dart_IsError((handle))) { \
257 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \ 276 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \
258 #handle, Dart_GetError(handle)); \ 277 #handle, Dart_GetError(handle)); \
259 } 278 }
260 279
261 } // namespace dart 280 } // namespace dart
262 281
263 #endif // VM_UNIT_TEST_H_ 282 #endif // VM_UNIT_TEST_H_
OLDNEW
« no previous file with comments | « vm/thread_win.cc ('k') | vm/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698