Chromium Code Reviews| Index: chrome/browser/ui/webui/options/managed_user_set_passphrase_browsertest.js |
| diff --git a/chrome/browser/ui/webui/options/managed_user_set_passphrase_browsertest.js b/chrome/browser/ui/webui/options/managed_user_set_passphrase_browsertest.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1737b6b0782d528bb1c6c9169d0d96748f012ba3 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/options/managed_user_set_passphrase_browsertest.js |
| @@ -0,0 +1,103 @@ |
| +// Copyright (c) 2013 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. |
| + |
| +// The include does not fit in a 80 character line. Therefore we split it up. |
| +var includeLine = '#include "chrome/browser/ui/webui/options/'; |
|
Bernhard Bauer
2013/02/05 13:34:44
You could concatenate the strings directly instead
Adrian Kuegel
2013/02/05 14:56:45
Done.
|
| +includeLine += 'managed_user_set_passphrase_test.h"'; |
| +GEN(includeLine); |
| + |
| +/** |
| + * Test fixture for managed user set passphrase WebUI testing. |
| + * @constructor |
| + * @extends {testing.Test} |
| + */ |
| +function ManagedUserSetPassphraseTest() {} |
| + |
| +ManagedUserSetPassphraseTest.prototype = { |
| + __proto__: testing.Test.prototype, |
| + |
| + /** |
| + * Browse to the managed user settings page . |
| + */ |
| + browsePreload: 'chrome://settings-frame/managedUser', |
| + |
| + /** @override */ |
| + typedefCppFixture: 'ManagedUserSetPassphraseTest', |
| + |
| + /** @inheritDoc */ |
| + preLoad: function() { |
| + this.makeAndRegisterMockHandler(['setPassphrase']); |
| + }, |
| + |
| + /** |
| + * Clicks the "Set passphrase" button. |
| + */ |
| + setPassphrase: function() { |
| + var setPassphraseButton = ManagedUserSettings.getPassphraseButton(); |
| + assertNotEquals(null, setPassphraseButton); |
| + setPassphraseButton.click(); |
| + }, |
| + |
| + /** |
| + * Enters a passphrase. |
| + */ |
| + enterPassphrase: function(passphrase) { |
| + var passphraseInput = ManagedUserSetPassphraseOverlay.getPassphraseInput(); |
| + assertNotEquals(null, passphraseInput); |
| + passphraseInput.value = passphrase; |
| + }, |
| + |
| + /** |
| + * Confirms the passphrase. |
| + */ |
| + confirmPassphrase: function(passphrase) { |
| + var passphraseConfirmInput = |
| + ManagedUserSetPassphraseOverlay.getPassphraseConfirmInput(); |
| + assertNotEquals(null, passphraseConfirmInput); |
| + passphraseConfirmInput.value = passphrase; |
| + }, |
| + |
| + /** |
| + * Save the passphrase. |
| + */ |
| + savePassphrase: function() { |
| + var savePassphraseButton = |
| + ManagedUserSetPassphraseOverlay.getSavePassphraseButton(); |
| + assertNotEquals(null, savePassphraseButton); |
| + // This takes care of enabling the save passphrase button (if applicable). |
| + ManagedUserSetPassphraseOverlay.updateDisplay(); |
| + savePassphraseButton.click(); |
| + }, |
| +}; |
| + |
| +// Verify that the save passphrase flow works. |
| +TEST_F('ManagedUserSetPassphraseTest', 'SamePassphrase', |
| + function() { |
| + this.setPassphrase(); |
| + this.enterPassphrase('test_passphrase'); |
| + this.confirmPassphrase('test_passphrase'); |
| + this.mockHandler.expects(once()).setPassphrase(['test_passphrase']); |
| + this.savePassphrase(); |
| + }); |
| + |
| +// Verify that empty passphrase is not allowed. |
| +TEST_F('ManagedUserSetPassphraseTest', 'EmptyPassphrase', |
| + function() { |
| + this.setPassphrase(); |
| + this.enterPassphrase(''); |
| + this.confirmPassphrase(''); |
| + this.mockHandler.expects(never()).setPassphrase(ANYTHING); |
| + this.savePassphrase(); |
| + }); |
| + |
| +// Verify that the confirm passphrase input needs to contain the same |
| +// passphrase as the passphrase input. |
| +TEST_F('ManagedUserSetPassphraseTest', 'DifferentPassphrase', |
| + function() { |
| + this.setPassphrase(); |
| + this.enterPassphrase('test_passphrase'); |
| + this.confirmPassphrase('confirm_passphrase'); |
| + this.mockHandler.expects(never()).setPassphrase(ANYTHING); |
| + this.savePassphrase(); |
| + }); |