| Index: chrome/test/data/webui/settings/startup_urls_page_test.js
|
| diff --git a/chrome/test/data/webui/settings/startup_urls_page_test.js b/chrome/test/data/webui/settings/startup_urls_page_test.js
|
| index 54f98fabe1edc6f108e07e95604086a32bafc6af..53489dc68ef360a61157b52d1e856a449a5e3125 100644
|
| --- a/chrome/test/data/webui/settings/startup_urls_page_test.js
|
| +++ b/chrome/test/data/webui/settings/startup_urls_page_test.js
|
| @@ -11,6 +11,7 @@ cr.define('settings_startup_urls_page', function() {
|
| function TestStartupUrlsPageBrowserProxy() {
|
| settings.TestBrowserProxy.call(this, [
|
| 'addStartupPage',
|
| + 'editStartupPage',
|
| 'loadStartupPages',
|
| 'removeStartupPage',
|
| 'useCurrentPages',
|
| @@ -36,6 +37,12 @@ cr.define('settings_startup_urls_page', function() {
|
| },
|
|
|
| /** @override */
|
| + editStartupPage: function(modelIndex, url) {
|
| + this.methodCalled('editStartupPage', [modelIndex, url]);
|
| + return Promise.resolve(this.urlIsValid_);
|
| + },
|
| +
|
| + /** @override */
|
| loadStartupPages: function() {
|
| this.methodCalled('loadStartupPages');
|
| },
|
| @@ -78,21 +85,48 @@ cr.define('settings_startup_urls_page', function() {
|
| settings.StartupUrlsPageBrowserProxyImpl.instance_ = browserProxy;
|
| PolymerTest.clearBody();
|
| dialog = document.createElement('settings-startup-url-dialog');
|
| - document.body.appendChild(dialog);
|
| });
|
|
|
| teardown(function() { dialog.remove(); });
|
|
|
| + test('Initialization_Add', function() {
|
| + document.body.appendChild(dialog);
|
| + assertTrue(dialog.$.dialog.opened);
|
| +
|
| + // Assert that the "Add" button is disabled.
|
| + var actionButton = dialog.$.actionButton;
|
| + assertTrue(!!actionButton);
|
| + assertTrue(actionButton.disabled);
|
| +
|
| + // Assert that the text field is empty.
|
| + var inputElement = dialog.$.url;
|
| + assertTrue(!!inputElement);
|
| + assertEquals('', inputElement.value);
|
| + });
|
| +
|
| + test('Initialization_Edit', function() {
|
| + dialog.model = createSampleUrlEntry();
|
| + document.body.appendChild(dialog);
|
| + assertTrue(dialog.$.dialog.opened);
|
| +
|
| + // Assert that the "Edit" button is enabled.
|
| + var actionButton = dialog.$.actionButton;
|
| + assertTrue(!!actionButton);
|
| + assertFalse(actionButton.disabled);
|
| + // Assert that the text field is pre-populated.
|
| + var inputElement = dialog.$.url;
|
| + assertTrue(!!inputElement);
|
| + assertEquals(dialog.model.url, inputElement.value);
|
| + });
|
| +
|
| // Test that validation occurs as the user is typing, and that the action
|
| // button is updated accordingly.
|
| test('Validation', function() {
|
| - assertTrue(dialog.$.dialog.opened);
|
| - var addButton = dialog.$.add;
|
| - assertTrue(!!addButton);
|
| - assertTrue(addButton.disabled);
|
| + document.body.appendChild(dialog);
|
|
|
| + var actionButton = dialog.$.actionButton;
|
| + assertTrue(actionButton.disabled);
|
| var inputElement = dialog.$.url;
|
| - assertTrue(!!inputElement);
|
|
|
| var expectedUrl = "dummy-foo.com";
|
| inputElement.value = expectedUrl;
|
| @@ -101,7 +135,7 @@ cr.define('settings_startup_urls_page', function() {
|
|
|
| return browserProxy.whenCalled('validateStartupPage').then(function(url) {
|
| assertEquals(expectedUrl, url);
|
| - assertTrue(addButton.disabled);
|
| + assertTrue(actionButton.disabled);
|
|
|
| browserProxy.setUrlValidity(true);
|
| browserProxy.resetResolver('validateStartupPage');
|
| @@ -109,30 +143,45 @@ cr.define('settings_startup_urls_page', function() {
|
|
|
| return browserProxy.whenCalled('validateStartupPage');
|
| }).then(function() {
|
| - assertFalse(addButton.disabled);
|
| + assertFalse(actionButton.disabled);
|
| });
|
| });
|
|
|
| - test('AddStartupPage', function() {
|
| - assertTrue(dialog.$.dialog.opened);
|
| - var addButton = dialog.$.add;
|
| - addButton.disabled = false;
|
| + /**
|
| + * Tests that the appropritae browser proxy method is called when the action
|
| + * button is tapped.
|
| + * @param {string} proxyMethodName
|
| + */
|
| + function testProxyCalled(proxyMethodName) {
|
| + var actionButton = dialog.$.actionButton;
|
| + actionButton.disabled = false;
|
|
|
| // Test that the dialog remains open if the user somehow manages to submit
|
| // an invalid URL.
|
| browserProxy.setUrlValidity(false);
|
| - MockInteractions.tap(addButton);
|
| - return browserProxy.whenCalled('addStartupPage').then(function() {
|
| + MockInteractions.tap(actionButton);
|
| + return browserProxy.whenCalled(proxyMethodName).then(function() {
|
| assertTrue(dialog.$.dialog.opened);
|
|
|
| // Test that dialog is closed if the user submits a valid URL.
|
| browserProxy.setUrlValidity(true);
|
| - browserProxy.resetResolver('addStartupPage');
|
| - MockInteractions.tap(addButton);
|
| - return browserProxy.whenCalled('addStartupPage');
|
| + browserProxy.resetResolver(proxyMethodName);
|
| + MockInteractions.tap(actionButton);
|
| + return browserProxy.whenCalled(proxyMethodName);
|
| }).then(function() {
|
| assertFalse(dialog.$.dialog.opened);
|
| });
|
| + }
|
| +
|
| + test('AddStartupPage', function() {
|
| + document.body.appendChild(dialog);
|
| + return testProxyCalled('addStartupPage');
|
| + });
|
| +
|
| + test('EditStartupPage', function() {
|
| + dialog.model = createSampleUrlEntry();
|
| + document.body.appendChild(dialog);
|
| + return testProxyCalled('editStartupPage');
|
| });
|
| });
|
|
|
| @@ -173,6 +222,13 @@ cr.define('settings_startup_urls_page', function() {
|
| Polymer.dom.flush();
|
| assertTrue(!!page.$$('settings-startup-url-dialog'));
|
| });
|
| +
|
| + test('EditPage_OpensDialog', function() {
|
| + assertFalse(!!page.$$('settings-startup-url-dialog'));
|
| + page.fire(settings.EDIT_STARTUP_URL_EVENT, createSampleUrlEntry());
|
| + Polymer.dom.flush();
|
| + assertTrue(!!page.$$('settings-startup-url-dialog'));
|
| + });
|
| });
|
|
|
| /** @return {!StartupPageInfo} */
|
|
|