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
3 // found in the LICENSE file.
7 function wifiMessage() {
8 var messagesNeeded = 3;
11 function onSessionEstablished(newSessionId) {
12 sessionId = newSessionId;
13 chrome.gcdPrivate.startPairing(sessionId, "embeddedCode",
17 function onPairingStarted(status) {
18 chrome.test.assertEq("success", status);
19 chrome.gcdPrivate.confirmCode(sessionId, "1234", onCodeConfirmed);
22 function onCodeConfirmed(status) {
23 chrome.test.assertEq("success", status);
24 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", {
27 }, onMessageSent.bind(null, "setupParseError"));
29 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", {
33 }, onMessageSent.bind(null, "setupParseError"));
35 chrome.gcdPrivate.sendMessage(sessionId, "/privet/v3/setup/start", {
39 }, onMessageSent.bind(null, "wifiPasswordError"));
42 function onMessageSent(expected_status, status, output) {
43 chrome.test.assertEq(expected_status, status);
45 console.log("Messages needed " + messagesNeeded);
47 if (messagesNeeded == 0) {
48 chrome.test.notifyPass();
52 chrome.gcdPrivate.establishSession("1.2.3.4", 9090, onSessionEstablished);