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

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

Issue 2750273002: Revert of Mojo EDK: Introduce MojoQueryHandleSignalsState API (Closed)
Patch Set: 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 state0 = core.queryHandleSignalsState(pipe.handle0); 92 var wait = core.waitMany([], [], 0);
93 expect(state0.result).toBe(core.RESULT_OK); 93 expect(wait.result).toBe(core.RESULT_INVALID_ARGUMENT);
94 expect(state0.satisfiedSignals).toBe(core.HANDLE_SIGNAL_WRITABLE); 94 expect(wait.index).toBe(null);
95 expect(state0.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL); 95 expect(wait.signalsState).toBe(null);
96 96
97 var state1 = core.queryHandleSignalsState(pipe.handle1); 97 wait = core.wait(pipe.handle0, core.HANDLE_SIGNAL_READABLE, 0);
98 expect(state1.result).toBe(core.RESULT_OK); 98 expect(wait.result).toBe(core.RESULT_DEADLINE_EXCEEDED);
99 expect(state1.satisfiedSignals).toBe(core.HANDLE_SIGNAL_WRITABLE); 99 expect(wait.signalsState.satisfiedSignals).toBe(
100 expect(state1.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL); 100 core.HANDLE_SIGNAL_WRITABLE);
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);
101 121
102 var senderData = new Uint8Array(42); 122 var senderData = new Uint8Array(42);
103 for (var i = 0; i < senderData.length; ++i) { 123 for (var i = 0; i < senderData.length; ++i) {
104 senderData[i] = i * i; 124 senderData[i] = i * i;
105 } 125 }
106 126
107 var result = core.writeMessage( 127 var result = core.writeMessage(
108 pipe.handle0, senderData, [], 128 pipe.handle0, senderData, [],
109 core.WRITE_MESSAGE_FLAG_NONE); 129 core.WRITE_MESSAGE_FLAG_NONE);
110 130
111 expect(result).toBe(core.RESULT_OK); 131 expect(result).toBe(core.RESULT_OK);
112 132
113 state0 = core.queryHandleSignalsState(pipe.handle0); 133 wait = core.wait(pipe.handle0, core.HANDLE_SIGNAL_WRITABLE, 0);
114 expect(state0.result).toBe(core.RESULT_OK); 134 expect(wait.result).toBe(core.RESULT_OK);
115 expect(state0.satisfiedSignals).toBe(core.HANDLE_SIGNAL_WRITABLE); 135 expect(wait.signalsState.satisfiedSignals).toBe(
116 expect(state0.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL); 136 core.HANDLE_SIGNAL_WRITABLE);
137 expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
117 138
118 var wait = core.wait(pipe.handle1, core.HANDLE_SIGNAL_READABLE, 139 wait = core.wait(pipe.handle1, core.HANDLE_SIGNAL_READABLE,
119 core.DEADLINE_INDEFINITE); 140 core.DEADLINE_INDEFINITE);
120 expect(wait.result).toBe(core.RESULT_OK); 141 expect(wait.result).toBe(core.RESULT_OK);
121 expect(wait.signalsState.satisfiedSignals).toBe(HANDLE_SIGNAL_READWRITABLE); 142 expect(wait.signalsState.satisfiedSignals).toBe(HANDLE_SIGNAL_READWRITABLE);
122 expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL); 143 expect(wait.signalsState.satisfiableSignals).toBe(HANDLE_SIGNAL_ALL);
123 144
124 var read = core.readMessage(pipe.handle1, core.READ_MESSAGE_FLAG_NONE); 145 var read = core.readMessage(pipe.handle1, core.READ_MESSAGE_FLAG_NONE);
125 146
126 expect(read.result).toBe(core.RESULT_OK); 147 expect(read.result).toBe(core.RESULT_OK);
127 expect(read.buffer.byteLength).toBe(42); 148 expect(read.buffer.byteLength).toBe(42);
128 expect(read.handles.length).toBe(0); 149 expect(read.handles.length).toBe(0);
129 150
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 237 }
217 238
218 expect(core.unmapBuffer(mappedBuffer0.buffer)).toBe(core.RESULT_OK); 239 expect(core.unmapBuffer(mappedBuffer0.buffer)).toBe(core.RESULT_OK);
219 expect(core.unmapBuffer(mappedBuffer1.buffer)).toBe(core.RESULT_OK); 240 expect(core.unmapBuffer(mappedBuffer1.buffer)).toBe(core.RESULT_OK);
220 241
221 expect(core.close(dupedBufferHandle.handle)).toBe(core.RESULT_OK); 242 expect(core.close(dupedBufferHandle.handle)).toBe(core.RESULT_OK);
222 expect(core.close(sharedBuffer.handle)).toBe(core.RESULT_OK); 243 expect(core.close(sharedBuffer.handle)).toBe(core.RESULT_OK);
223 } 244 }
224 245
225 }); 246 });
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