| 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 session() { | 7 function session() { |
| 8 function onConfirmCode(sessionId, status, confirmationInfo) { | 8 function onSessionEstablished(sessionId, status, pairingTypes) { |
| 9 chrome.test.assertEq("success", status); | 9 chrome.test.assertEq("success", status); |
| 10 chrome.test.assertEq("1234", confirmationInfo.code); | 10 chrome.test.assertEq(["embeddedCode"], pairingTypes); |
| 11 chrome.test.assertEq("displayCode", confirmationInfo.type); | |
| 12 | |
| 13 chrome.gcdPrivate.sendMessage(sessionId, "/privet/ping", {}, | 11 chrome.gcdPrivate.sendMessage(sessionId, "/privet/ping", {}, |
| 14 onMessageSentFail); | 12 onMessageSentFail); |
| 15 | 13 chrome.gcdPrivate.startPairing(sessionId, "embeddedCode", |
| 16 chrome.gcdPrivate.confirmCode(sessionId, | 14 onPairingStarted.bind(null, sessionId)); |
| 17 "1234", | |
| 18 onSessionEstablished.bind(null, | |
| 19 sessionId)); | |
| 20 } | 15 } |
| 21 | 16 |
| 22 function onSessionEstablished(sessionId, status) { | 17 function onPairingStarted(sessionId, status) { |
| 23 chrome.test.assertEq("success", status); | 18 chrome.test.assertEq("success", status); |
| 19 chrome.gcdPrivate.sendMessage(sessionId, "/privet/ping", {}, |
| 20 onMessageSentFail); |
| 21 chrome.gcdPrivate.confirmCode(sessionId, "1234", |
| 22 onCodeConfirmed.bind(null, sessionId)); |
| 23 } |
| 24 | 24 |
| 25 function onCodeConfirmed(sessionId, status) { |
| 26 chrome.test.assertEq("success", status); |
| 25 chrome.gcdPrivate.sendMessage(sessionId, "/privet/ping", {}, | 27 chrome.gcdPrivate.sendMessage(sessionId, "/privet/ping", {}, |
| 26 onMessageSent); | 28 onMessageSent); |
| 27 } | 29 } |
| 28 | 30 |
| 29 function onMessageSentFail(status, output) { | 31 function onMessageSentFail(status, output) { |
| 30 chrome.test.assertEq("sessionError", status); | 32 chrome.test.assertEq("sessionError", status); |
| 31 } | 33 } |
| 32 | 34 |
| 33 function onMessageSent(status, output) { | 35 function onMessageSent(status, output) { |
| 34 chrome.test.assertEq("success", status); | 36 chrome.test.assertEq("success", status); |
| 35 chrome.test.assertEq("pong", output.response); | 37 chrome.test.assertEq("pong", output.response); |
| 36 | |
| 37 chrome.test.notifyPass(); | 38 chrome.test.notifyPass(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 chrome.gcdPrivate.establishSession("1.2.3.4", 9090, onConfirmCode); | 41 chrome.gcdPrivate.establishSession("1.2.3.4", 9090, onSessionEstablished); |
| 41 } | 42 } |
| 42 ]); | 43 ]); |
| 43 }; | 44 }; |
| OLD | NEW |