OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 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. |
| 4 |
| 5 var QuickUnlockMode = chrome.quickUnlockPrivate.QuickUnlockMode; |
| 6 |
| 7 // Verifies that the valid password is accepted. This uses a fake authentication |
| 8 // backend. |
| 9 function checkValidPasswordTest() { |
| 10 chrome.quickUnlockPrivate.checkPassword('valid', onCheckPassword); |
| 11 |
| 12 function onCheckPassword(result) { |
| 13 chrome.test.assertTrue(result); |
| 14 chrome.test.succeed(); |
| 15 }; |
| 16 } |
| 17 |
| 18 // Verifies that the invalid password is rejected. This uses a fake |
| 19 // authentication backend. |
| 20 function checkInvalidPasswordTest() { |
| 21 chrome.quickUnlockPrivate.checkPassword('invalid', onCheckPassword); |
| 22 |
| 23 function onCheckPassword(result) { |
| 24 chrome.test.assertFalse(result); |
| 25 chrome.test.succeed(); |
| 26 }; |
| 27 } |
| 28 |
| 29 // Verifies that chrome.quickUnlockPrivate.getAvailableModes returns only PIN. |
| 30 function checkAvailableModes() { |
| 31 chrome.quickUnlockPrivate.getAvailableModes(onGetAvailableModes); |
| 32 |
| 33 function onGetAvailableModes(modes) { |
| 34 chrome.test.checkDeepEq(modes, [QuickUnlockMode.PIN]); |
| 35 chrome.test.succeed(); |
| 36 } |
| 37 } |
| 38 |
| 39 // Verifies that we can set the quick unlock mode to PIN, we can fetch that mode |
| 40 // using getActiveModes, and that we can clear the pin with setModes. |
| 41 function checkSetAndGetModes() { |
| 42 chrome.quickUnlockPrivate.setModes([QuickUnlockMode.PIN], ['111'], onModeSet); |
| 43 |
| 44 function onModeSet(result) { |
| 45 chrome.test.assertTrue(result); |
| 46 chrome.quickUnlockPrivate.getActiveModes(onGetActiveModesExpectPin); |
| 47 } |
| 48 |
| 49 function onGetActiveModesExpectPin(modes) { |
| 50 chrome.test.checkDeepEq(modes, [QuickUnlockMode.PIN]); |
| 51 chrome.quickUnlockPrivate.setModes([], [], onModeClear); |
| 52 } |
| 53 |
| 54 function onModeClear(result) { |
| 55 chrome.test.assertTrue(result); |
| 56 chrome.quickUnlockPrivate.getActiveModes(onGetActiveModesExpectNone); |
| 57 } |
| 58 |
| 59 function onGetActiveModesExpectNone(modes) { |
| 60 chrome.test.checkDeepEq(modes, []); |
| 61 chrome.test.succeed(); |
| 62 } |
| 63 } |
| 64 |
| 65 chrome.test.sendMessage('ready'); |
| 66 chrome.test.runTests( |
| 67 [checkValidPasswordTest, checkInvalidPasswordTest, checkAvailableModes, |
| 68 checkSetAndGetModes]); |
OLD | NEW |