Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/test/data/webui/settings/startup_urls_page_test.js

Issue 2180823004: Migrate <cr-dialog> from PaperDialogBehavior to native <dialog>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('settings_startup_urls_page', function() { 5 cr.define('settings_startup_urls_page', function() {
6 /** 6 /**
7 * @constructor 7 * @constructor
8 * @implements {settings.StartupUrlsPageBrowserProxy} 8 * @implements {settings.StartupUrlsPageBrowserProxy}
9 * @extends {settings.TestBrowserProxy} 9 * @extends {settings.TestBrowserProxy}
10 */ 10 */
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 browserProxy = new TestStartupUrlsPageBrowserProxy(); 84 browserProxy = new TestStartupUrlsPageBrowserProxy();
85 settings.StartupUrlsPageBrowserProxyImpl.instance_ = browserProxy; 85 settings.StartupUrlsPageBrowserProxyImpl.instance_ = browserProxy;
86 PolymerTest.clearBody(); 86 PolymerTest.clearBody();
87 dialog = document.createElement('settings-startup-url-dialog'); 87 dialog = document.createElement('settings-startup-url-dialog');
88 }); 88 });
89 89
90 teardown(function() { dialog.remove(); }); 90 teardown(function() { dialog.remove(); });
91 91
92 test('Initialization_Add', function() { 92 test('Initialization_Add', function() {
93 document.body.appendChild(dialog); 93 document.body.appendChild(dialog);
94 assertTrue(dialog.$.dialog.opened); 94 assertTrue(dialog.$.dialog.open);
95 95
96 // Assert that the "Add" button is disabled. 96 // Assert that the "Add" button is disabled.
97 var actionButton = dialog.$.actionButton; 97 var actionButton = dialog.$.actionButton;
98 assertTrue(!!actionButton); 98 assertTrue(!!actionButton);
99 assertTrue(actionButton.disabled); 99 assertTrue(actionButton.disabled);
100 100
101 // Assert that the text field is empty. 101 // Assert that the text field is empty.
102 var inputElement = dialog.$.url; 102 var inputElement = dialog.$.url;
103 assertTrue(!!inputElement); 103 assertTrue(!!inputElement);
104 assertEquals('', inputElement.value); 104 assertEquals('', inputElement.value);
105 }); 105 });
106 106
107 test('Initialization_Edit', function() { 107 test('Initialization_Edit', function() {
108 dialog.model = createSampleUrlEntry(); 108 dialog.model = createSampleUrlEntry();
109 document.body.appendChild(dialog); 109 document.body.appendChild(dialog);
110 assertTrue(dialog.$.dialog.opened); 110 assertTrue(dialog.$.dialog.open);
111 111
112 // Assert that the "Edit" button is enabled. 112 // Assert that the "Edit" button is enabled.
113 var actionButton = dialog.$.actionButton; 113 var actionButton = dialog.$.actionButton;
114 assertTrue(!!actionButton); 114 assertTrue(!!actionButton);
115 assertFalse(actionButton.disabled); 115 assertFalse(actionButton.disabled);
116 // Assert that the text field is pre-populated. 116 // Assert that the text field is pre-populated.
117 var inputElement = dialog.$.url; 117 var inputElement = dialog.$.url;
118 assertTrue(!!inputElement); 118 assertTrue(!!inputElement);
119 assertEquals(dialog.model.url, inputElement.value); 119 assertEquals(dialog.model.url, inputElement.value);
120 }); 120 });
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 */ 154 */
155 function testProxyCalled(proxyMethodName) { 155 function testProxyCalled(proxyMethodName) {
156 var actionButton = dialog.$.actionButton; 156 var actionButton = dialog.$.actionButton;
157 actionButton.disabled = false; 157 actionButton.disabled = false;
158 158
159 // Test that the dialog remains open if the user somehow manages to submit 159 // Test that the dialog remains open if the user somehow manages to submit
160 // an invalid URL. 160 // an invalid URL.
161 browserProxy.setUrlValidity(false); 161 browserProxy.setUrlValidity(false);
162 MockInteractions.tap(actionButton); 162 MockInteractions.tap(actionButton);
163 return browserProxy.whenCalled(proxyMethodName).then(function() { 163 return browserProxy.whenCalled(proxyMethodName).then(function() {
164 assertTrue(dialog.$.dialog.opened); 164 assertTrue(dialog.$.dialog.open);
165 165
166 // Test that dialog is closed if the user submits a valid URL. 166 // Test that dialog is closed if the user submits a valid URL.
167 browserProxy.setUrlValidity(true); 167 browserProxy.setUrlValidity(true);
168 browserProxy.resetResolver(proxyMethodName); 168 browserProxy.resetResolver(proxyMethodName);
169 MockInteractions.tap(actionButton); 169 MockInteractions.tap(actionButton);
170 return browserProxy.whenCalled(proxyMethodName); 170 return browserProxy.whenCalled(proxyMethodName);
171 }).then(function() { 171 }).then(function() {
172 assertFalse(dialog.$.dialog.opened); 172 assertFalse(dialog.$.dialog.open);
173 }); 173 });
174 } 174 }
175 175
176 test('AddStartupPage', function() { 176 test('AddStartupPage', function() {
177 document.body.appendChild(dialog); 177 document.body.appendChild(dialog);
178 return testProxyCalled('addStartupPage'); 178 return testProxyCalled('addStartupPage');
179 }); 179 });
180 180
181 test('EditStartupPage', function() { 181 test('EditStartupPage', function() {
182 dialog.model = createSampleUrlEntry(); 182 dialog.model = createSampleUrlEntry();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 test('MenuOptions_Remove', function() { 267 test('MenuOptions_Remove', function() {
268 var removeButton = element.shadowRoot.querySelector('#remove') 268 var removeButton = element.shadowRoot.querySelector('#remove')
269 MockInteractions.tap(removeButton); 269 MockInteractions.tap(removeButton);
270 return browserProxy.whenCalled('removeStartupPage').then( 270 return browserProxy.whenCalled('removeStartupPage').then(
271 function(modelIndex) { 271 function(modelIndex) {
272 assertEquals(element.model.modelIndex, modelIndex); 272 assertEquals(element.model.modelIndex, modelIndex);
273 }); 273 });
274 }); 274 });
275 }); 275 });
276 }); 276 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698