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

Side by Side Diff: mojo/public/js/connector.js

Issue 1511783002: Mojo JS bindings: fix the unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « mojo/mojo_edk_tests.gyp ('k') | mojo/public/js/core_unittests.js » ('j') | 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("mojo/public/js/connector", [ 5 define("mojo/public/js/connector", [
6 "mojo/public/js/buffer", 6 "mojo/public/js/buffer",
7 "mojo/public/js/codec", 7 "mojo/public/js/codec",
8 "mojo/public/js/core", 8 "mojo/public/js/core",
9 "mojo/public/js/support", 9 "mojo/public/js/support",
10 ], function(buffer, codec, core, support) { 10 ], function(buffer, codec, core, support) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 var messageBuffer = new buffer.Buffer(read.buffer); 104 var messageBuffer = new buffer.Buffer(read.buffer);
105 var message = new codec.Message(messageBuffer, read.handles); 105 var message = new codec.Message(messageBuffer, read.handles);
106 if (this.incomingReceiver_) { 106 if (this.incomingReceiver_) {
107 this.incomingReceiver_.accept(message); 107 this.incomingReceiver_.accept(message);
108 } 108 }
109 } 109 }
110 }; 110 };
111 111
112 // The TestConnector subclass is only intended to be used in unit tests. It 112 // The TestConnector subclass is only intended to be used in unit tests. It
113 // enables delivering a message to the pipe's handle without an async wait. 113 // doesn't automatically listen for input messages. Instead, you need to
114 114 // call waitForNextMessage to block and wait for the next incoming message.
115 function TestConnector(handle) { 115 function TestConnector(handle) {
116 Connector.call(this, handle); 116 Connector.call(this, handle);
117 } 117 }
118 118
119 TestConnector.prototype = Object.create(Connector.prototype); 119 TestConnector.prototype = Object.create(Connector.prototype);
120 120
121 TestConnector.prototype.waitToReadMore_ = function() { 121 TestConnector.prototype.waitToReadMore_ = function() {
122 }; 122 }
123 123
124 TestConnector.prototype.deliverMessage = function() { 124 TestConnector.prototype.waitForNextMessage = function() {
125 this.readMore_(core.RESULT_OK); 125 var wait = core.wait(this.handle_, core.HANDLE_SIGNAL_READABLE,
126 core.DEADLINE_INDEFINITE);
127 this.readMore_(wait.result);
126 } 128 }
127 129
128 var exports = {}; 130 var exports = {};
129 exports.Connector = Connector; 131 exports.Connector = Connector;
130 exports.TestConnector = TestConnector; 132 exports.TestConnector = TestConnector;
131 return exports; 133 return exports;
132 }); 134 });
OLDNEW
« no previous file with comments | « mojo/mojo_edk_tests.gyp ('k') | mojo/public/js/core_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698