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

Side by Side Diff: mojo/public/js/tests/core_unittest.js

Issue 2741033003: Mojo EDK: Introduce MojoQueryHandleSignalsState API (Closed)
Patch Set: fix stupid bad DCHECK Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « mojo/public/js/core.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 define([ 5 define([
6 "gin/test/expect", 6 "gin/test/expect",
7 "mojo/public/js/core", 7 "mojo/public/js/core",
8 "gc", 8 "gc",
9 ], function(expect, core, gc) { 9 ], function(expect, core, gc) {
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 expect(sharedBuffer.result).toBe(core.RESULT_OK); 82 expect(sharedBuffer.result).toBe(core.RESULT_OK);
83 expect(core.isHandle(sharedBuffer.handle)).toBeTruthy(); 83 expect(core.isHandle(sharedBuffer.handle)).toBeTruthy();
84 84
85 test(sharedBuffer, buffer_size); 85 test(sharedBuffer, buffer_size);
86 } 86 }
87 87
88 function testNop(pipe) { 88 function testNop(pipe) {
89 } 89 }
90 90
91 function testReadAndWriteMessage(pipe) { 91 function testReadAndWriteMessage(pipe) {
92 var wait = core.waitMany([], [], 0); 92 var state0 = core.queryHandleSignalsState(pipe.handle0);
93 expect(wait.result).toBe(core.RESULT_INVALID_ARGUMENT); 93 expect(state0.result).toBe(core.RESULT_OK);
94 expect(wait.index).toBe(null); 94 expect(state0.satisfiedSignals).toBe(core.HANDLE_SIGNAL_WRITABLE);
95 expect(wait.signalsState).toBe(null); 95 expect(state0.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
96 96
97 wait = core.wait(pipe.handle0, core.HANDLE_SIGNAL_READABLE, 0); 97 var state1 = core.queryHandleSignalsState(pipe.handle1);
98 expect(wait.result).toBe(core.RESULT_DEADLINE_EXCEEDED); 98 expect(state1.result).toBe(core.RESULT_OK);
99 expect(wait.signalsState.satisfiedSignals).toBe( 99 expect(state1.satisfiedSignals).toBe(core.HANDLE_SIGNAL_WRITABLE);
100 core.HANDLE_SIGNAL_WRITABLE); 100 expect(state1.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
101 expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
102
103 wait = core.waitMany(
104 [pipe.handle0, pipe.handle1],
105 [core.HANDLE_SIGNAL_READABLE,core.HANDLE_SIGNAL_READABLE],
106 0);
107 expect(wait.result).toBe(core.RESULT_DEADLINE_EXCEEDED);
108 expect(wait.index).toBe(null);
109 expect(wait.signalsState[0].satisfiedSignals).toBe(
110 core.HANDLE_SIGNAL_WRITABLE);
111 expect(wait.signalsState[0].satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
112 expect(wait.signalsState[1].satisfiedSignals).toBe(
113 core.HANDLE_SIGNAL_WRITABLE);
114 expect(wait.signalsState[1].satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
115
116 wait = core.wait(pipe.handle0, core.HANDLE_SIGNAL_WRITABLE, 0);
117 expect(wait.result).toBe(core.RESULT_OK);
118 expect(wait.signalsState.satisfiedSignals).toBe(
119 core.HANDLE_SIGNAL_WRITABLE);
120 expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
121 101
122 var senderData = new Uint8Array(42); 102 var senderData = new Uint8Array(42);
123 for (var i = 0; i < senderData.length; ++i) { 103 for (var i = 0; i < senderData.length; ++i) {
124 senderData[i] = i * i; 104 senderData[i] = i * i;
125 } 105 }
126 106
127 var result = core.writeMessage( 107 var result = core.writeMessage(
128 pipe.handle0, senderData, [], 108 pipe.handle0, senderData, [],
129 core.WRITE_MESSAGE_FLAG_NONE); 109 core.WRITE_MESSAGE_FLAG_NONE);
130 110
131 expect(result).toBe(core.RESULT_OK); 111 expect(result).toBe(core.RESULT_OK);
132 112
133 wait = core.wait(pipe.handle0, core.HANDLE_SIGNAL_WRITABLE, 0); 113 state0 = core.queryHandleSignalsState(pipe.handle0);
134 expect(wait.result).toBe(core.RESULT_OK); 114 expect(state0.result).toBe(core.RESULT_OK);
135 expect(wait.signalsState.satisfiedSignals).toBe( 115 expect(state0.satisfiedSignals).toBe(core.HANDLE_SIGNAL_WRITABLE);
136 core.HANDLE_SIGNAL_WRITABLE); 116 expect(state0.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
137 expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
138 117
139 wait = core.wait(pipe.handle1, core.HANDLE_SIGNAL_READABLE, 118 var wait = core.wait(pipe.handle1, core.HANDLE_SIGNAL_READABLE,
140 core.DEADLINE_INDEFINITE); 119 core.DEADLINE_INDEFINITE);
141 expect(wait.result).toBe(core.RESULT_OK); 120 expect(wait.result).toBe(core.RESULT_OK);
142 expect(wait.signalsState.satisfiedSignals).toBe(HANDLE_SIGNAL_READWRITABLE); 121 expect(wait.signalsState.satisfiedSignals).toBe(HANDLE_SIGNAL_READWRITABLE);
143 expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL); 122 expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
144 123
145 var read = core.readMessage(pipe.handle1, core.READ_MESSAGE_FLAG_NONE); 124 var read = core.readMessage(pipe.handle1, core.READ_MESSAGE_FLAG_NONE);
146 125
147 expect(read.result).toBe(core.RESULT_OK); 126 expect(read.result).toBe(core.RESULT_OK);
148 expect(read.buffer.byteLength).toBe(42); 127 expect(read.buffer.byteLength).toBe(42);
149 expect(read.handles.length).toBe(0); 128 expect(read.handles.length).toBe(0);
150 129
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 216 }
238 217
239 expect(core.unmapBuffer(mappedBuffer0.buffer)).toBe(core.RESULT_OK); 218 expect(core.unmapBuffer(mappedBuffer0.buffer)).toBe(core.RESULT_OK);
240 expect(core.unmapBuffer(mappedBuffer1.buffer)).toBe(core.RESULT_OK); 219 expect(core.unmapBuffer(mappedBuffer1.buffer)).toBe(core.RESULT_OK);
241 220
242 expect(core.close(dupedBufferHandle.handle)).toBe(core.RESULT_OK); 221 expect(core.close(dupedBufferHandle.handle)).toBe(core.RESULT_OK);
243 expect(core.close(sharedBuffer.handle)).toBe(core.RESULT_OK); 222 expect(core.close(sharedBuffer.handle)).toBe(core.RESULT_OK);
244 } 223 }
245 224
246 }); 225 });
OLDNEW
« no previous file with comments | « mojo/public/js/core.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698