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