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

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
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 }
165 171
166 virtual void Run(); 172 virtual void Run();
167 173
168 private: 174 private:
175 static Dart_Isolate CreateIsolate(uint8_t* buffer) {
176 Dart_ErrorBuffer err;
177 static const int kErrorMsgLength = 256;
178 err.buffer = reinterpret_cast<char*>(malloc(kErrorMsgLength));
179 err.length = kErrorMsgLength;
180 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.
181 free(err.buffer);
182 EXPECT(isolate != NULL);
183 return isolate;
184 }
185
169 RunEntry* const run_; 186 RunEntry* const run_;
170 }; 187 };
171 188
172 189
173 class TestIsolateScope { 190 class TestIsolateScope {
174 public: 191 public:
175 TestIsolateScope() { 192 TestIsolateScope() {
176 isolate_ = reinterpret_cast<Isolate*>(Dart_CreateIsolate(NULL, NULL)); 193 isolate_ = reinterpret_cast<Isolate*>(TestCase::CreateTestIsolate());
177 EXPECT(isolate_ != NULL);
178 Dart_EnterScope(); // Create a Dart API scope for unit tests. 194 Dart_EnterScope(); // Create a Dart API scope for unit tests.
179 } 195 }
180 ~TestIsolateScope() { 196 ~TestIsolateScope() {
181 Dart_ExitScope(); // Exit the Dart API scope created for unit tests. 197 Dart_ExitScope(); // Exit the Dart API scope created for unit tests.
182 ASSERT(isolate_ == Isolate::Current()); 198 ASSERT(isolate_ == Isolate::Current());
183 Dart_ShutdownIsolate(); 199 Dart_ShutdownIsolate();
184 isolate_ = NULL; 200 isolate_ = NULL;
185 } 201 }
186 Isolate* isolate() const { return isolate_; } 202 Isolate* isolate() const { return isolate_; }
187 203
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 270
255 #define EXPECT_VALID(handle) \ 271 #define EXPECT_VALID(handle) \
256 if (Dart_IsError((handle))) { \ 272 if (Dart_IsError((handle))) { \
257 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \ 273 dart::Expect(__FILE__, __LINE__).Fail("invalid handle '%s':\n '%s'\n", \
258 #handle, Dart_GetError(handle)); \ 274 #handle, Dart_GetError(handle)); \
259 } 275 }
260 276
261 } // namespace dart 277 } // namespace dart
262 278
263 #endif // VM_UNIT_TEST_H_ 279 #endif // VM_UNIT_TEST_H_
OLDNEW
« vm/dart_api_impl.cc ('K') | « vm/thread_win.cc ('k') | vm/vm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698