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

Unified Diff: mojo/dart/test/core_test.dart

Issue 834283003: Update Dart bindings to support updated MojoWait and MojoWaitMany APIs. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixed comment Created 5 years, 11 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 | « mojo/dart/embedder/mojo_natives.cc ('k') | mojo/public/dart/src/handle.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/dart/test/core_test.dart
diff --git a/mojo/dart/test/core_test.dart b/mojo/dart/test/core_test.dart
index f38269d65de0f7dd4e4cd8328b7350f669fc0af5..41ce93538c320d50677418dfa4de5424f64b598c 100644
--- a/mojo/dart/test/core_test.dart
+++ b/mojo/dart/test/core_test.dart
@@ -16,13 +16,14 @@ invalidHandleTest() {
Expect.isTrue(result.isInvalidArgument);
// Wait.
- result = invalidHandle.wait(MojoHandleSignals.READWRITE, 1000000);
- Expect.isTrue(result.isInvalidArgument);
+ MojoWaitResult mwr = invalidHandle.wait(MojoHandleSignals.READWRITE, 1000000);
+ Expect.isTrue(mwr.result.isInvalidArgument);
- int res = RawMojoHandle.waitMany([invalidHandle.h],
- [MojoHandleSignals.READWRITE],
- RawMojoHandle.DEADLINE_INDEFINITE);
- Expect.equals(res, MojoResult.kInvalidArgument);
+ MojoWaitManyResult mwmr = RawMojoHandle.waitMany(
+ [invalidHandle.h],
+ [MojoHandleSignals.READWRITE],
+ RawMojoHandle.DEADLINE_INDEFINITE);
+ Expect.isTrue(mwmr.result.isInvalidArgument);
// Message pipe.
MojoMessagePipe pipe = new MojoMessagePipe();
@@ -87,12 +88,12 @@ basicMessagePipeTest() {
Expect.isTrue(end1.handle.isValid);
// Not readable, yet.
- MojoResult result = end0.handle.wait(MojoHandleSignals.READABLE, 0);
- Expect.isTrue(result.isDeadlineExceeded);
+ MojoWaitResult mwr = end0.handle.wait(MojoHandleSignals.READABLE, 0);
+ Expect.isTrue(mwr.result.isDeadlineExceeded);
// Should be writable.
- result = end0.handle.wait(MojoHandleSignals.WRITABLE, 0);
- Expect.isTrue(result.isOk);
+ mwr = end0.handle.wait(MojoHandleSignals.WRITABLE, 0);
+ Expect.isTrue(mwr.result.isOk);
// Try to read.
ByteData data = new ByteData(10);
@@ -103,14 +104,14 @@ basicMessagePipeTest() {
String hello = "hello";
ByteData helloData =
new ByteData.view((new Uint8List.fromList(hello.codeUnits)).buffer);
- result = end1.write(helloData);
+ MojoResult result = end1.write(helloData);
Expect.isTrue(result.isOk);
// end0 should now be readable.
- int res = RawMojoHandle.waitMany([end0.handle.h],
+ MojoWaitManyResult mwmr = RawMojoHandle.waitMany([end0.handle.h],
[MojoHandleSignals.READABLE],
RawMojoHandle.DEADLINE_INDEFINITE);
- Expect.equals(res, MojoResult.kOk);
+ Expect.isTrue(mwmr.result.isOk);
// Read from end0.
MojoMessagePipeReadResult readResult = end0.read(data);
@@ -124,16 +125,16 @@ basicMessagePipeTest() {
Expect.equals(hello_result, "hello");
// end0 should no longer be readable.
- result = end0.handle.wait(MojoHandleSignals.READABLE, 10);
- Expect.isTrue(result.isDeadlineExceeded);
+ mwr = end0.handle.wait(MojoHandleSignals.READABLE, 10);
+ Expect.isTrue(mwr.result.isDeadlineExceeded);
// Close end0's handle.
result = end0.handle.close();
Expect.isTrue(result.isOk);
// end1 should no longer be readable or writable.
- result = end1.handle.wait(MojoHandleSignals.READWRITE, 1000);
- Expect.isTrue(result.isFailedPrecondition);
+ mwr = end1.handle.wait(MojoHandleSignals.READWRITE, 1000);
+ Expect.isTrue(mwr.result.isFailedPrecondition);
result = end1.handle.close();
Expect.isTrue(result.isOk);
@@ -153,12 +154,12 @@ basicDataPipeTest() {
Expect.isTrue(consumer.handle.isValid);
// Consumer should not be readable.
- MojoResult result = consumer.handle.wait(MojoHandleSignals.READABLE, 0);
- Expect.isTrue(result.isDeadlineExceeded);
+ MojoWaitResult mwr = consumer.handle.wait(MojoHandleSignals.READABLE, 0);
+ Expect.isTrue(mwr.result.isDeadlineExceeded);
// Producer should be writable.
- result = producer.handle.wait(MojoHandleSignals.WRITABLE, 0);
- Expect.isTrue(result.isOk);
+ mwr = producer.handle.wait(MojoHandleSignals.WRITABLE, 0);
+ Expect.isTrue(mwr.result.isOk);
// Try to read from consumer.
ByteData buffer = new ByteData(20);
@@ -180,10 +181,11 @@ basicDataPipeTest() {
Expect.equals(written, helloData.lengthInBytes);
// Now that we have written, the consumer should be readable.
- int res = RawMojoHandle.waitMany([consumer.handle.h],
- [MojoHandleSignals.READABLE],
- RawMojoHandle.DEADLINE_INDEFINITE);
- Expect.equals(res, MojoResult.kOk);
+ MojoWaitManyResult mwmr = RawMojoHandle.waitMany(
+ [consumer.handle.h],
+ [MojoHandleSignals.READABLE],
+ RawMojoHandle.DEADLINE_INDEFINITE);
+ Expect.isTrue(mwr.result.isOk);
// Do a two-phase write to the producer.
ByteData twoPhaseWrite = producer.beginWrite(
@@ -203,12 +205,12 @@ basicDataPipeTest() {
Expect.equals(read, 1);
// Close the producer.
- result = producer.handle.close();
+ MojoResult result = producer.handle.close();
Expect.isTrue(result.isOk);
// Consumer should still be readable.
- result = consumer.handle.wait(MojoHandleSignals.READABLE, 0);
- Expect.isTrue(result.isOk);
+ mwr = consumer.handle.wait(MojoHandleSignals.READABLE, 0);
+ Expect.isTrue(mwr.result.isOk);
// Get the number of remaining bytes.
int remaining = consumer.read(
« no previous file with comments | « mojo/dart/embedder/mojo_natives.cc ('k') | mojo/public/dart/src/handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698