OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // net/tools/testserver/testserver.py is picky about the format of what it | 5 // net/tools/testserver/testserver.py is picky about the format of what it |
6 // calls its "echo" messages. One might go so far as to mutter to oneself that | 6 // calls its "echo" messages. One might go so far as to mutter to oneself that |
7 // it isn't an echo server at all. | 7 // it isn't an echo server at all. |
8 // | 8 // |
9 // The response is based on the request but obfuscated using a random key. | 9 // The response is based on the request but obfuscated using a random key. |
10 const request = "0100000005320000005hello"; | 10 const request = "0100000005320000005hello"; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 } | 227 } |
228 | 228 |
229 function onServerSocketCreate(socketInfo) { | 229 function onServerSocketCreate(socketInfo) { |
230 socketId = socketInfo.socketId; | 230 socketId = socketInfo.socketId; |
231 socket.listen(socketId, address, port, onListen); | 231 socket.listen(socketId, address, port, onListen); |
232 } | 232 } |
233 | 233 |
234 socket.create('tcp', {}, onServerSocketCreate); | 234 socket.create('tcp', {}, onServerSocketCreate); |
235 }; | 235 }; |
236 | 236 |
237 | |
mmenke
2013/04/12 21:07:41
nit: Remove extra blank line.
Bei Zhang
2013/04/15 22:30:26
Done.
| |
237 var onMessageReply = function(message) { | 238 var onMessageReply = function(message) { |
238 var parts = message.split(":"); | 239 var parts = message.split(":"); |
239 test_type = parts[0]; | 240 var test_type = parts[0]; |
240 address = parts[1]; | 241 address = parts[1]; |
241 port = parseInt(parts[2]); | 242 port = parseInt(parts[2]); |
242 console.log("Running tests, protocol " + protocol + ", echo server " + | 243 console.log("Running tests, protocol " + protocol + ", echo server " + |
243 address + ":" + port); | 244 address + ":" + port); |
244 if (test_type == 'tcp_server') { | 245 if (test_type == 'tcp_server') { |
245 chrome.test.runTests([ testSocketListening ]); | 246 chrome.test.runTests([ testSocketListening ]); |
247 } else if (test_type == 'multicast') { | |
248 console.log("Running multicast tests"); | |
249 chrome.test.runTests([ testMulticast ]); | |
246 } else { | 250 } else { |
247 protocol = test_type; | 251 protocol = test_type; |
248 chrome.test.runTests([ testSocketCreation, testSending ]); | 252 chrome.test.runTests([ testSocketCreation, testSending ]); |
249 } | 253 } |
250 }; | 254 }; |
251 | 255 |
252 // Find out which protocol we're supposed to test, and which echo server we | 256 // Find out which protocol we're supposed to test, and which echo server we |
253 // should be using, then kick off the tests. | 257 // should be using, then kick off the tests. |
254 chrome.test.sendMessage("info_please", onMessageReply); | 258 chrome.test.sendMessage("info_please", onMessageReply); |
OLD | NEW |