Chromium Code Reviews| Index: chrome/test/data/webui/settings/passwords_and_forms_browsertest.js |
| diff --git a/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js b/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js |
| index b983bc103f6ffa95d17fb4daf0dc479a84f87e73..4b49adddd8d58f5c7ced8c797fc464713be479e0 100644 |
| --- a/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js |
| +++ b/chrome/test/data/webui/settings/passwords_and_forms_browsertest.js |
| @@ -223,7 +223,10 @@ PasswordsAndFormsBrowserTest.prototype = { |
| 'passwords_and_forms_page.html', |
| /** @override */ |
| - extraLibraries: PolymerTest.getLibraries(ROOT_PATH), |
| + extraLibraries: PolymerTest.getLibraries(ROOT_PATH).concat([ |
| + '../fake_chrome_event.js', |
| + 'fake_settings_private.js', |
| + ]), |
| /** @override */ |
| setUp: function() { |
| @@ -241,6 +244,11 @@ PasswordsAndFormsBrowserTest.prototype = { |
| AutofillManagerImpl.instance_ = this.autofillManager; |
| }, |
| + /** @override */ |
| + tearDown: function() { |
| + PolymerTest.clearBody(); |
| + }, |
| + |
| /** |
| * Creates a new passwords and forms element. |
| * @return {!Object} |
| @@ -253,6 +261,46 @@ PasswordsAndFormsBrowserTest.prototype = { |
| }, |
| /** |
| + * @pram {boolean} autofill Whether autofill is enabled or not. |
| + * @param {boolean} passwords Whether passwords are enable or not. |
|
Dan Beam
2016/07/07 00:05:01
enable -> enabled
hcarmona
2016/07/11 23:03:43
Done.
|
| + * @return {!Promise<!Element>} The |prefs| object. |
| + */ |
| + createPrefs(autofill, passwords) { |
|
Dan Beam
2016/07/07 00:05:01
nit: arguably don't use ES6 features yet (i.e. cre
hcarmona
2016/07/11 23:03:43
Done.
|
| + return new Promise(function(resolve) { |
| + CrSettingsPrefs.deferInitialization = true; |
| + var prefs = document.createElement('settings-prefs'); |
| + document.body.appendChild(prefs); |
| + prefs.initializeForTesting(new settings.FakeSettingsPrivate([ |
| + { |
| + key: 'autofill.enabled', |
| + type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| + value: autofill, |
| + }, |
| + { |
| + key: 'profile.password_manager_enabled', |
| + type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| + value: passwords, |
| + }, |
| + ])); |
| + |
| + CrSettingsPrefs.initialized.then(function() { |
| + resolve(prefs); |
| + }); |
| + }); |
| + }, |
| + |
| + /** |
| + * Cleans up prefs so tests can continue to run. |
| + * @param {!Element} prefs The prefs element. |
| + */ |
| + destroyPrefs(prefs) { |
| + console.log('destroying prefs'); |
|
Dan Beam
2016/07/07 00:05:01
nit: remove
hcarmona
2016/07/11 23:03:43
Done.
|
| + CrSettingsPrefs.resetForTesting(); |
| + CrSettingsPrefs.deferInitialization = false; |
| + prefs.resetForTesting(); |
| + }, |
| + |
| + /** |
| * Creates PasswordManagerExpectations with the values expected after first |
| * creating the element. |
| * @return {!PasswordManagerExpectations} |
| @@ -372,6 +420,32 @@ TEST_F('PasswordsAndFormsBrowserTest', 'uiTests', function() { |
| self.passwordManager.assertExpectations(self.basePasswordExpectations()); |
| self.autofillManager.assertExpectations(self.baseAutofillExpectations()); |
| }); |
| + |
| + test('testActionabilityNope', function() { |
| + return self.createPrefs(false, false).then(function(prefs) { |
| + var element = self.createPasswordsAndFormsElement(); |
| + element.prefs = prefs.prefs; |
| + Polymer.dom.flush(); |
| + |
| + assertFalse(element.$.autofillManagerButton.hasAttribute('actionable')); |
| + assertFalse(element.$.passwordManagerButton.hasAttribute('actionable')); |
| + |
| + self.destroyPrefs(prefs); |
| + }); |
| + }); |
| + |
| + test('testActionabilityYes', function() { |
| + return self.createPrefs(true, true).then(function(prefs) { |
| + var element = self.createPasswordsAndFormsElement(); |
| + element.prefs = prefs.prefs; |
| + Polymer.dom.flush(); |
| + |
| + assertTrue(element.$.autofillManagerButton.hasAttribute('actionable')); |
| + assertTrue(element.$.passwordManagerButton.hasAttribute('actionable')); |
| + |
| + self.destroyPrefs(prefs); |
| + }); |
| + }); |
| }); |
| mocha.run(); |