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

Unified Diff: mojo/public/js/core_unittests.js

Issue 795593004: Update mojo sdk to rev cc531b32182099a5a034a99daff35ed5d38a61c8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More workarounds for MSVC Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/js/core.js ('k') | mojo/public/js/router.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/js/core_unittests.js
diff --git a/mojo/public/js/core_unittests.js b/mojo/public/js/core_unittests.js
index eaeaa4f74aeb9ada6e199bb3408fb89fcec1d8ff..0f7b3ff0290297b5af332c58d8c6bcf456eb51b6 100644
--- a/mojo/public/js/core_unittests.js
+++ b/mojo/public/js/core_unittests.js
@@ -7,6 +7,13 @@ define([
"mojo/public/js/core",
"gc",
], function(expect, core, gc) {
+
+ var HANDLE_SIGNAL_READWRITABLE = core.HANDLE_SIGNAL_WRITABLE |
+ core.HANDLE_SIGNAL_READABLE;
+ var HANDLE_SIGNAL_ALL = core.HANDLE_SIGNAL_WRITABLE |
+ core.HANDLE_SIGNAL_READABLE |
+ core.HANDLE_SIGNAL_PEER_CLOSED;
+
runWithMessagePipe(testNop);
runWithMessagePipe(testReadAndWriteMessage);
runWithMessagePipeWithOptions(testNop);
@@ -15,6 +22,8 @@ define([
runWithDataPipe(testReadAndWriteDataPipe);
runWithDataPipeWithOptions(testNop);
runWithDataPipeWithOptions(testReadAndWriteDataPipe);
+ runWithMessagePipe(testIsHandleMessagePipe);
+ runWithDataPipe(testIsHandleDataPipe);
gc.collectGarbage(); // should not crash
this.result = "PASS";
@@ -68,6 +77,36 @@ define([
}
function testReadAndWriteMessage(pipe) {
+ var wait = core.waitMany([], [], 0);
+ expect(wait.result).toBe(core.RESULT_INVALID_ARGUMENT);
+ expect(wait.index).toBe(null);
+ expect(wait.signalsState).toBe(null);
+
+ wait = core.wait(pipe.handle0, core.HANDLE_SIGNAL_READABLE, 0);
+ expect(wait.result).toBe(core.RESULT_DEADLINE_EXCEEDED);
+ expect(wait.signalsState.satisfiedSignals).toBe(
+ core.HANDLE_SIGNAL_WRITABLE);
+ expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
+
+ wait = core.waitMany(
+ [pipe.handle0, pipe.handle1],
+ [core.HANDLE_SIGNAL_READABLE,core.HANDLE_SIGNAL_READABLE],
+ 0);
+ expect(wait.result).toBe(core.RESULT_DEADLINE_EXCEEDED);
+ expect(wait.index).toBe(null);
+ expect(wait.signalsState[0].satisfiedSignals).toBe(
+ core.HANDLE_SIGNAL_WRITABLE);
+ expect(wait.signalsState[0].satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
+ expect(wait.signalsState[1].satisfiedSignals).toBe(
+ core.HANDLE_SIGNAL_WRITABLE);
+ expect(wait.signalsState[1].satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
+
+ wait = core.wait(pipe.handle0, core.HANDLE_SIGNAL_WRITABLE, 0);
+ expect(wait.result).toBe(core.RESULT_OK);
+ expect(wait.signalsState.satisfiedSignals).toBe(
+ core.HANDLE_SIGNAL_WRITABLE);
+ expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
+
var senderData = new Uint8Array(42);
for (var i = 0; i < senderData.length; ++i) {
senderData[i] = i * i;
@@ -79,6 +118,19 @@ define([
expect(result).toBe(core.RESULT_OK);
+ wait = core.waitMany(
+ [pipe.handle0, pipe.handle1],
+ [core.HANDLE_SIGNAL_WRITABLE,core.HANDLE_SIGNAL_WRITABLE],
+ 0);
+ expect(wait.result).toBe(core.RESULT_OK);
+ expect(wait.index).toBe(0);
+ expect(wait.signalsState[0].satisfiedSignals).toBe(
+ core.HANDLE_SIGNAL_WRITABLE);
+ expect(wait.signalsState[0].satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
+ expect(wait.signalsState[1].satisfiedSignals).toBe(
+ HANDLE_SIGNAL_READWRITABLE);
+ expect(wait.signalsState[1].satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
+
var read = core.readMessage(
pipe.handle1, core.READ_MESSAGE_FLAG_NONE);
@@ -125,4 +177,21 @@ define([
expect(memory[i]).toBe((i * i) & 0xFF);
}
+ function testIsHandleMessagePipe(pipe) {
+ expect(core.isHandle(123).toBeFalsy);
+ expect(core.isHandle("123").toBeFalsy);
+ expect(core.isHandle({}).toBeFalsy);
+ expect(core.isHandle([]).toBeFalsy);
+ expect(core.isHandle(undefined).toBeFalsy);
+ expect(core.isHandle(pipe).toBeFalsy);
+ expect(core.isHandle(pipe.handle0)).toBeTruthy();
+ expect(core.isHandle(pipe.handle1)).toBeTruthy();
+ expect(core.isHandle(null)).toBeTruthy();
+ }
+
+ function testIsHandleDataPipe(pipe) {
+ expect(core.isHandle(pipe.consumerHandle)).toBeTruthy();
+ expect(core.isHandle(pipe.producerHandle)).toBeTruthy();
+ }
+
});
« no previous file with comments | « mojo/public/js/core.js ('k') | mojo/public/js/router.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698