Chromium Code Reviews| Index: lib/unittest/shared.dart |
| diff --git a/lib/unittest/shared.dart b/lib/unittest/shared.dart |
| index 56923021565821db5392d78b712f11406aecee19..c51937b89d9086c9f202752846a8cb31750460f1 100644 |
| --- a/lib/unittest/shared.dart |
| +++ b/lib/unittest/shared.dart |
| @@ -2,6 +2,8 @@ |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
|
eub
2012/04/10 18:06:02
I know we don't have a convention, but I'd like to
Emily Fortuna
2012/04/10 18:14:12
+1
Siggi Cherem (dart-lang)
2012/04/10 21:40:18
Sounds like a good idea. In this particular case,
|
| +Configuration _config = null; |
|
eub
2012/04/10 18:06:02
(And what definitions the file expects to rely on
Siggi Cherem (dart-lang)
2012/04/10 21:40:18
Done.
|
| + |
| /** |
| * Description text of the current test group. If multiple groups are nested, |
| * this will contain all of their text concatenated. |
| @@ -17,9 +19,6 @@ List<TestCase> _tests; |
| */ |
| Function _testRunner; |
| -/** Whether this is run within dartium layout tests. */ |
| -bool _isLayoutTest = false; |
| - |
| /** Current test being executed. */ |
| int _currentTest = 0; |
| @@ -86,21 +85,6 @@ void asyncTest(String spec, int callbacks, TestFunction body) { |
| } |
| } |
| -void serialInvokeAsync(List closures) { |
| - final length = closures.length; |
| - if (length > 0) { |
| - int i = 0; |
| - void invokeNext() { |
| - closures[i](); |
| - i++; |
| - if (i < length) { |
| - window.setTimeout(invokeNext, 0); |
| - } |
| - } |
| - window.setTimeout(invokeNext, 0); |
| - } |
| -} |
| - |
| /** |
| * Creates a new named group of tests. Calls to group() or test() within the |
| * body of the function passed to this will inherit this group's description. |
| @@ -148,15 +132,24 @@ void callbackDone() { |
| } |
| } |
| -void forLayoutTests() { |
| - _isLayoutTest = true; |
| +/** Runs [callback] at the end of the event loop. */ |
| +_defer(void callback()) { |
| + // Exploit isolate ports as a platform-independent mechanism to queue a |
| + // message at the end of the event loop. |
| + // TODO(sigmund): expose this functionality somewhere in our libraries. |
| + final port = new ReceivePort(); |
| + port.receive((msg, reply) { |
| + callback(); |
| + port.close(); |
| + }); |
| + port.toSendPort().send(null, null); |
| } |
| /** Runs all queued tests, one at a time. */ |
| _runTests() { |
| - _platformStartTests(); |
| + _config.onStart(); |
| - _platformDefer(() { |
| + _defer(() { |
| assert (_currentTest == 0); |
| _testRunner(); |
| }); |
| @@ -226,7 +219,7 @@ _completeTests() { |
| } |
| } |
| - _platformCompleteTests(testsPassed_, testsFailed_, testsErrors_); |
| + _config.onDone(testsPassed_, testsFailed_, testsErrors_, _tests); |
| } |
| String _fullSpec(String spec) { |
| @@ -245,11 +238,16 @@ _ensureInitialized() { |
| _state = _READY; |
| _testRunner = _nextBatch; |
| - _platformInitialize(); |
| + if (_config == null) { |
| + // TODO(sigmund): make this [new Configuration], set configuration |
| + // for each platform in test.dart |
| + _config = new PlatformConfiguration(); |
| + } |
| + _config.onInit(); |
| // Immediately queue the suite up. It will run after a timeout (i.e. after |
| // main() has returned). |
| - _platformDefer(_runTests); |
| + _defer(_runTests); |
| } |
| /** |