| OLD | NEW |
| 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 onload = function() { | 5 onload = function() { |
| 6 chrome.test.runTests([ | 6 chrome.test.runTests([ |
| 7 function wifiMessage() { | 7 function wifiMessage() { |
| 8 var messagesNeeded = 3; | 8 var messagesNeeded = 4; |
| 9 var sessionId = -1; | 9 var sessionId = -1; |
| 10 | 10 |
| 11 function onSessionEstablished(newSessionId) { | |
| 12 sessionId = newSessionId; | |
| 13 chrome.gcdPrivate.startPairing(sessionId, "embeddedCode", | |
| 14 onPairingStarted); | |
| 15 } | |
| 16 | |
| 17 function onPairingStarted(status) { | |
| 18 chrome.test.assertEq("success", status); | |
| 19 chrome.gcdPrivate.confirmCode(sessionId, "1234", onCodeConfirmed); | |
| 20 } | |
| 21 | |
| 22 function onCodeConfirmed(status) { | |
| 23 chrome.test.assertEq("success", status); | |
| 24 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", { | |
| 25 "wifi" : { | |
| 26 } | |
| 27 }, onMessageSent.bind(null, "setupParseError")); | |
| 28 | |
| 29 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", { | |
| 30 "wifi" : { | |
| 31 "passphrase": "Blah" | |
| 32 } | |
| 33 }, onMessageSent.bind(null, "setupParseError")); | |
| 34 | |
| 35 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", { | |
| 36 "wifi" : { | |
| 37 "ssid": "Blah" | |
| 38 } | |
| 39 }, onMessageSent.bind(null, "wifiPasswordError")); | |
| 40 } | |
| 41 | |
| 42 function onMessageSent(expected_status, status, output) { | 11 function onMessageSent(expected_status, status, output) { |
| 43 chrome.test.assertEq(expected_status, status); | 12 chrome.test.assertEq(expected_status, status); |
| 44 messagesNeeded--; | 13 messagesNeeded--; |
| 45 console.log("Messages needed " + messagesNeeded); | 14 console.log("Messages needed " + messagesNeeded); |
| 46 | 15 |
| 47 if (messagesNeeded == 0) { | 16 if (messagesNeeded == 0) { |
| 48 chrome.test.notifyPass(); | 17 chrome.test.notifyPass(); |
| 49 } | 18 } |
| 50 } | 19 }; |
| 51 | 20 |
| 52 chrome.gcdPrivate.establishSession("1.2.3.4", 9090, onSessionEstablished); | 21 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", { |
| 22 "wifi" : { |
| 23 } |
| 24 }, onMessageSent.bind(null, "setupParseError")); |
| 25 |
| 26 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", { |
| 27 "wifi" : { |
| 28 "passphrase": "Blah" |
| 29 } |
| 30 }, onMessageSent.bind(null, "setupParseError")); |
| 31 |
| 32 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", { |
| 33 "wifi" : { |
| 34 "ssid": "Blah" |
| 35 } |
| 36 }, onMessageSent.bind(null, "wifiPasswordError")); |
| 37 |
| 38 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", { |
| 39 "wifi": { |
| 40 "ssid": "Blah", |
| 41 "passphrase": "111" |
| 42 } |
| 43 }, onMessageSent.bind(null, "unknownSessionError")); |
| 53 } | 44 } |
| 54 ]); | 45 ]); |
| 55 }; | 46 }; |
| OLD | NEW |