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

Unified Diff: samples/tests/samples/src/proxy/PromiseBasedTest.dart

Issue 10153005: unittest step 3 and 4: remove TestFramework.dart, make test.dart use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/tests/samples/src/proxy/MintMakerRpcTest.dart ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/tests/samples/src/proxy/PromiseBasedTest.dart
diff --git a/samples/tests/samples/src/proxy/PromiseBasedTest.dart b/samples/tests/samples/src/proxy/PromiseBasedTest.dart
index b9b17762537e8b4989a128090930771e91549f4b..53a184a28321dbf595e3ad2480e8bc924f0d84be 100644
--- a/samples/tests/samples/src/proxy/PromiseBasedTest.dart
+++ b/samples/tests/samples/src/proxy/PromiseBasedTest.dart
@@ -5,7 +5,7 @@
#library("PromiseBasedTest");
#import("dart:isolate");
#import("../../../../proxy/promise.dart");
-#import("../../../../../tests/isolate/src/TestFramework.dart");
+#import("../../../../../lib/unittest/unittest.dart");
class TestIsolate extends Isolate {
@@ -37,51 +37,47 @@ Future promiseToFuture(Promise p) {
return c.future;
}
-void test(TestExpectation expect) {
- Proxy proxy = new Proxy.forIsolate(new TestIsolate());
- proxy.send([42]); // Seed the isolate.
- Promise<int> result = new PromiseProxy<int>(proxy.call([87]));
- Completer completer = new Completer();
- expect.completes(promiseToFuture(result)).then((int value) {
- //print("expect 1: $value");
- Expect.equals(42 + 87, value);
- completer.complete(99);
- });
- expect.completes(completer.future).then((int value) {
- //print("expect 2: $value");
- Expect.equals(99, value);
- expect.succeeded();
+void main() {
+ test("promise based proxies", () {
+ Proxy proxy = new Proxy.forIsolate(new TestIsolate());
+ proxy.send([42]); // Seed the isolate.
+ Promise<int> result = new PromiseProxy<int>(proxy.call([87]));
+ Completer completer = new Completer();
+ result.then(expectAsync1((int value) {
+ //print("expect 1: $value");
+ Expect.equals(42 + 87, value);
+ completer.complete(99);
+ }));
+ completer.future.then(expectAsync1((int value) {
+ //print("expect 2: $value");
+ Expect.equals(99, value);
+ }));
});
-}
-void expandedTest(TestExpectation expect) {
- Proxy proxy = new Proxy.forIsolate(new TestIsolate());
- proxy.send([42]); // Seed the isolate.
- Promise<SendPort> sendCompleter = proxy.call([87]);
- Promise<int> result = new Promise<int>();
- ReceivePort receivePort = new ReceivePort();
- receivePort.receive((var msg, SendPort _) {
- receivePort.close();
- //print("test completer");
- result.complete(msg[0]);
- });
- sendCompleter.addCompleteHandler((SendPort port) {
- //print("test send");
- port.send([receivePort.toSendPort()], null);
- });
- Completer completer = new Completer();
- expect.completes(promiseToFuture(result)).then((int value) {
- //print("expect 1: $value");
- Expect.equals(42 + 87, value);
- completer.complete(99);
- });
- expect.completes(completer.future).then((int value) {
- //print("expect 2: $value");
- Expect.equals(99, value);
- expect.succeeded();
+ test("expanded test", () {
+ Proxy proxy = new Proxy.forIsolate(new TestIsolate());
+ proxy.send([42]); // Seed the isolate.
+ Promise<SendPort> sendCompleter = proxy.call([87]);
+ Promise<int> result = new Promise<int>();
+ ReceivePort receivePort = new ReceivePort();
+ receivePort.receive((var msg, SendPort _) {
+ receivePort.close();
+ //print("test completer");
+ result.complete(msg[0]);
+ });
+ sendCompleter.addCompleteHandler((SendPort port) {
+ //print("test send");
+ port.send([receivePort.toSendPort()], null);
+ });
+ Completer completer = new Completer();
+ promiseToFuture(result).then(expectAsync1((int value) {
+ //print("expect 1: $value");
+ Expect.equals(42 + 87, value);
+ completer.complete(99);
+ }));
+ completer.future.then(expectAsync1((int value) {
+ //print("expect 2: $value");
+ Expect.equals(99, value);
+ }));
});
}
-
-void main() {
- runTests([test, expandedTest]);
-}
« no previous file with comments | « samples/tests/samples/src/proxy/MintMakerRpcTest.dart ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698