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

Side by Side Diff: runtime/vm/custom_isolate_test.cc

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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
« no previous file with comments | « runtime/vm/cpuinfo_macos.cc ('k') | runtime/vm/dart.h » ('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 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_native_api.h" 6 #include "include/dart_native_api.h"
7 7
8 #include "vm/unit_test.h" 8 #include "vm/unit_test.h"
9 9
10 // Custom Isolate Test. 10 // Custom Isolate Test.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 private: 92 private:
93 friend class EventQueue; 93 friend class EventQueue;
94 Dart_Isolate isolate_; 94 Dart_Isolate isolate_;
95 Event* next_; 95 Event* next_;
96 }; 96 };
97 97
98 98
99 // A simple event queue for our test. 99 // A simple event queue for our test.
100 class EventQueue { 100 class EventQueue {
101 public: 101 public:
102 EventQueue() { 102 EventQueue() { head_ = NULL; }
103 head_ = NULL;
104 }
105 103
106 void Add(Event* event) { 104 void Add(Event* event) {
107 if (head_ == NULL) { 105 if (head_ == NULL) {
108 head_ = event; 106 head_ = event;
109 tail_ = event; 107 tail_ = event;
110 } else { 108 } else {
111 tail_->next_ = event; 109 tail_->next_ = event;
112 tail_ = event; 110 tail_ = event;
113 } 111 }
114 } 112 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 EventQueue* event_queue; 154 EventQueue* event_queue;
157 155
158 156
159 // Start an isolate. 157 // Start an isolate.
160 class StartEvent : public Event { 158 class StartEvent : public Event {
161 public: 159 public:
162 StartEvent(Dart_Isolate isolate, const char* main) 160 StartEvent(Dart_Isolate isolate, const char* main)
163 : Event(isolate), main_(main) {} 161 : Event(isolate), main_(main) {}
164 162
165 virtual void Process(); 163 virtual void Process();
164
166 private: 165 private:
167 const char* main_; 166 const char* main_;
168 }; 167 };
169 168
170 169
171 void StartEvent::Process() { 170 void StartEvent::Process() {
172 OS::Print(">> StartEvent with isolate(%p)--\n", isolate()); 171 OS::Print(">> StartEvent with isolate(%p)--\n", isolate());
173 Dart_EnterIsolate(isolate()); 172 Dart_EnterIsolate(isolate());
174 Dart_EnterScope(); 173 Dart_EnterScope();
175 Dart_Handle result; 174 Dart_Handle result;
(...skipping 10 matching lines...) Expand all
186 Dart_ExitScope(); 185 Dart_ExitScope();
187 Dart_ExitIsolate(); 186 Dart_ExitIsolate();
188 } 187 }
189 188
190 189
191 // Notify an isolate of a pending message. 190 // Notify an isolate of a pending message.
192 class MessageEvent : public Event { 191 class MessageEvent : public Event {
193 public: 192 public:
194 explicit MessageEvent(Dart_Isolate isolate) : Event(isolate) {} 193 explicit MessageEvent(Dart_Isolate isolate) : Event(isolate) {}
195 194
196 ~MessageEvent() { 195 ~MessageEvent() {}
197 }
198 196
199 virtual void Process(); 197 virtual void Process();
200 }; 198 };
201 199
202 200
203 void MessageEvent::Process() { 201 void MessageEvent::Process() {
204 OS::Print("$$ MessageEvent with isolate(%p)\n", isolate()); 202 OS::Print("$$ MessageEvent with isolate(%p)\n", isolate());
205 Dart_EnterIsolate(isolate()); 203 Dart_EnterIsolate(isolate());
206 Dart_EnterScope(); 204 Dart_EnterScope();
207 205
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 Dart_ExitIsolate(); 280 Dart_ExitIsolate();
283 281
284 // Create a new Dart_Isolate. 282 // Create a new Dart_Isolate.
285 Dart_Isolate new_isolate = TestCase::CreateTestIsolate(); 283 Dart_Isolate new_isolate = TestCase::CreateTestIsolate();
286 EXPECT(new_isolate != NULL); 284 EXPECT(new_isolate != NULL);
287 Dart_SetMessageNotifyCallback(&NotifyMessage); 285 Dart_SetMessageNotifyCallback(&NotifyMessage);
288 Dart_EnterScope(); 286 Dart_EnterScope();
289 // Reload all the test classes here. 287 // Reload all the test classes here.
290 // 288 //
291 // TODO(turnidge): Use the create isolate callback instead? 289 // TODO(turnidge): Use the create isolate callback instead?
292 Dart_Handle lib = TestCase::LoadTestScript(kCustomIsolateScriptChars, 290 Dart_Handle lib =
293 NativeLookup); 291 TestCase::LoadTestScript(kCustomIsolateScriptChars, NativeLookup);
294 EXPECT_VALID(lib); 292 EXPECT_VALID(lib);
295 293
296 Dart_Handle main_send_port = Dart_GetField(lib, NewString("mainSendPort")); 294 Dart_Handle main_send_port = Dart_GetField(lib, NewString("mainSendPort"));
297 EXPECT_VALID(main_send_port); 295 EXPECT_VALID(main_send_port);
298 Dart_Port main_port_id; 296 Dart_Port main_port_id;
299 Dart_Handle err = Dart_SendPortGetId(main_send_port, &main_port_id); 297 Dart_Handle err = Dart_SendPortGetId(main_send_port, &main_port_id);
300 EXPECT_VALID(err); 298 EXPECT_VALID(err);
301 299
302 OS::Print("-- Adding StartEvent to queue --\n"); 300 OS::Print("-- Adding StartEvent to queue --\n");
303 event_queue->Add(new StartEvent(new_isolate, isolate_main)); 301 event_queue->Add(new StartEvent(new_isolate, isolate_main));
(...skipping 22 matching lines...) Expand all
326 #endif 324 #endif
327 event_queue = new EventQueue(); 325 event_queue = new EventQueue();
328 326
329 Dart_Isolate dart_isolate = TestCase::CreateTestIsolate(); 327 Dart_Isolate dart_isolate = TestCase::CreateTestIsolate();
330 EXPECT(dart_isolate != NULL); 328 EXPECT(dart_isolate != NULL);
331 Dart_SetMessageNotifyCallback(&NotifyMessage); 329 Dart_SetMessageNotifyCallback(&NotifyMessage);
332 Dart_EnterScope(); 330 Dart_EnterScope();
333 Dart_Handle result; 331 Dart_Handle result;
334 332
335 // Create a test library. 333 // Create a test library.
336 Dart_Handle lib = TestCase::LoadTestScript(kCustomIsolateScriptChars, 334 Dart_Handle lib =
337 NativeLookup); 335 TestCase::LoadTestScript(kCustomIsolateScriptChars, NativeLookup);
338 EXPECT_VALID(lib); 336 EXPECT_VALID(lib);
339 337
340 // Run main. 338 // Run main.
341 result = Dart_Invoke(lib, NewString("main"), 0, NULL); 339 result = Dart_Invoke(lib, NewString("main"), 0, NULL);
342 EXPECT_VALID(result); 340 EXPECT_VALID(result);
343 EXPECT(Dart_IsString(result)); 341 EXPECT(Dart_IsString(result));
344 const char* result_str = NULL; 342 const char* result_str = NULL;
345 EXPECT_VALID(Dart_StringToCString(result, &result_str)); 343 EXPECT_VALID(Dart_StringToCString(result, &result_str));
346 EXPECT_STREQ("success", result_str); 344 EXPECT_STREQ("success", result_str);
347 345
(...skipping 10 matching lines...) Expand all
358 OS::Print("-- Finished event loop --\n"); 356 OS::Print("-- Finished event loop --\n");
359 EXPECT_STREQ("Received: 43", saved_echo); 357 EXPECT_STREQ("Received: 43", saved_echo);
360 free(saved_echo); 358 free(saved_echo);
361 359
362 delete event_queue; 360 delete event_queue;
363 event_queue = NULL; 361 event_queue = NULL;
364 FLAG_trace_shutdown = saved_flag; 362 FLAG_trace_shutdown = saved_flag;
365 } 363 }
366 364
367 } // namespace dart 365 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/cpuinfo_macos.cc ('k') | runtime/vm/dart.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698