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