| Index: chrome/test/data/extensions/api_test/quick_unlock_private/apiTests/background.js
|
| diff --git a/chrome/test/data/extensions/api_test/quick_unlock_private/apiTests/background.js b/chrome/test/data/extensions/api_test/quick_unlock_private/apiTests/background.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9f8b4957923c337d70148a42954ed6171bfeaf84
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/api_test/quick_unlock_private/apiTests/background.js
|
| @@ -0,0 +1,68 @@
|
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +var QuickUnlockMode = chrome.quickUnlockPrivate.QuickUnlockMode;
|
| +
|
| +// Verifies that the valid password is accepted. This uses a fake authentication
|
| +// backend.
|
| +function checkValidPasswordTest() {
|
| + chrome.quickUnlockPrivate.checkPassword('valid', onCheckPassword);
|
| +
|
| + function onCheckPassword(result) {
|
| + chrome.test.assertTrue(result);
|
| + chrome.test.succeed();
|
| + };
|
| +}
|
| +
|
| +// Verifies that the invalid password is rejected. This uses a fake
|
| +// authentication backend.
|
| +function checkInvalidPasswordTest() {
|
| + chrome.quickUnlockPrivate.checkPassword('invalid', onCheckPassword);
|
| +
|
| + function onCheckPassword(result) {
|
| + chrome.test.assertFalse(result);
|
| + chrome.test.succeed();
|
| + };
|
| +}
|
| +
|
| +// Verifies that chrome.quickUnlockPrivate.getAvailableModes returns only PIN.
|
| +function checkAvailableModes() {
|
| + chrome.quickUnlockPrivate.getAvailableModes(onGetAvailableModes);
|
| +
|
| + function onGetAvailableModes(modes) {
|
| + chrome.test.checkDeepEq(modes, [QuickUnlockMode.PIN]);
|
| + chrome.test.succeed();
|
| + }
|
| +}
|
| +
|
| +// Verifies that we can set the quick unlock mode to PIN, we can fetch that mode
|
| +// using getActiveModes, and that we can clear the pin with setModes.
|
| +function checkSetAndGetModes() {
|
| + chrome.quickUnlockPrivate.setModes([QuickUnlockMode.PIN], ['111'], onModeSet);
|
| +
|
| + function onModeSet(result) {
|
| + chrome.test.assertTrue(result);
|
| + chrome.quickUnlockPrivate.getActiveModes(onGetActiveModesExpectPin);
|
| + }
|
| +
|
| + function onGetActiveModesExpectPin(modes) {
|
| + chrome.test.checkDeepEq(modes, [QuickUnlockMode.PIN]);
|
| + chrome.quickUnlockPrivate.setModes([], [], onModeClear);
|
| + }
|
| +
|
| + function onModeClear(result) {
|
| + chrome.test.assertTrue(result);
|
| + chrome.quickUnlockPrivate.getActiveModes(onGetActiveModesExpectNone);
|
| + }
|
| +
|
| + function onGetActiveModesExpectNone(modes) {
|
| + chrome.test.checkDeepEq(modes, []);
|
| + chrome.test.succeed();
|
| + }
|
| +}
|
| +
|
| +chrome.test.sendMessage('ready');
|
| +chrome.test.runTests(
|
| + [checkValidPasswordTest, checkInvalidPasswordTest, checkAvailableModes,
|
| + checkSetAndGetModes]);
|
|
|