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

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

Issue 2230513003: [MD settings] setup site settings menus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review changes 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
« no previous file with comments | « chrome/browser/resources/settings/site_settings/site_list.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** @fileoverview Suite of tests for site-list. */ 5 /** @fileoverview Suite of tests for site-list. */
6 cr.define('site_list', function() { 6 cr.define('site_list', function() {
7 function registerTests() { 7 function registerTests() {
8 suite('SiteList', function() { 8 suite('SiteList', function() {
9 /** 9 /**
10 * A site list element created before each test. 10 * A site list element created before each test.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Initialize a site-list before each test. 261 // Initialize a site-list before each test.
262 setup(function() { 262 setup(function() {
263 browserProxy = new TestSiteSettingsPrefsBrowserProxy(); 263 browserProxy = new TestSiteSettingsPrefsBrowserProxy();
264 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy; 264 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = browserProxy;
265 PolymerTest.clearBody(); 265 PolymerTest.clearBody();
266 testElement = document.createElement('settings-site-list'); 266 testElement = document.createElement('settings-site-list');
267 document.body.appendChild(testElement); 267 document.body.appendChild(testElement);
268 }); 268 });
269 269
270 /** 270 /**
271 * Fetch the non-hidden menu items from the list.
272 * @param {!HTMLElement} parentElement
273 */
274 function getMenuItems(listContainer) {
275 return listContainer.children[0].querySelectorAll(
276 'paper-menu-button paper-item:not([hidden])');
277 }
278
279 /**
271 * Asserts the menu looks as expected. 280 * Asserts the menu looks as expected.
272 * @param {Array<string>} items The items expected to show in the menu. 281 * @param {Array<string>} items The items expected to show in the menu.
273 * @param {!HTMLElement} parentElement The parent node to start looking 282 * @param {!HTMLElement} parentElement The parent node to start looking
274 * in. 283 * in.
275 */ 284 */
276 function assertMenu(items, parentElement) { 285 function assertMenu(items, parentElement) {
277 var listItem = parentElement.$.listContainer.children[0]; 286 var menuItems = getMenuItems(parentElement.$.listContainer);
278 var menuItems = listItem.querySelectorAll(
279 'paper-menu-button paper-item:not([hidden])');
280 assertEquals(items.length, menuItems.length); 287 assertEquals(items.length, menuItems.length);
281 for (var i = 0; i < items.length; i++) 288 for (var i = 0; i < items.length; i++)
282 assertEquals(items[i], menuItems[i].textContent.trim()); 289 assertEquals(items[i], menuItems[i].textContent.trim());
283 } 290 }
284 291
285 /** 292 /**
286 * Configures the test element for a particular category. 293 * Configures the test element for a particular category.
287 * @param {settings.ContentSettingsTypes} category The category to setup. 294 * @param {settings.ContentSettingsTypes} category The category to setup.
288 * @param {settings.PermissionValues} subtype Type of list to use. 295 * @param {settings.PermissionValues} subtype Type of list to use.
289 * @param {Array<dictionary>} prefs The prefs to use. 296 * @param {Array<dictionary>} prefs The prefs to use.
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 641
635 test('Mixed schemes (present and absent)', function() { 642 test('Mixed schemes (present and absent)', function() {
636 // Prefs: One item with scheme and one without. 643 // Prefs: One item with scheme and one without.
637 setupCategory(settings.ContentSettingsTypes.GEOLOCATION, 644 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
638 settings.PermissionValues.ALLOW, prefsMixedSchemes); 645 settings.PermissionValues.ALLOW, prefsMixedSchemes);
639 return browserProxy.whenCalled('getExceptionList').then( 646 return browserProxy.whenCalled('getExceptionList').then(
640 function(contentType) { 647 function(contentType) {
641 // No further checks needed. If this fails, it will hang the test. 648 // No further checks needed. If this fails, it will hang the test.
642 }); 649 });
643 }); 650 });
651
652 test('Select menu item', function() {
653 // Test for error:
654 // "Cannot read property 'origin' of undefined"
655 // which occurs if the menu hasn't been fully setup prior to selecting a
656 // menu item.
tommycli 2016/08/11 21:53:10 I think the comment needs an update.
dschuyler 2016/08/11 22:40:14 Done.
657 setupCategory(settings.ContentSettingsTypes.GEOLOCATION,
658 settings.PermissionValues.ALLOW, prefs);
659 return browserProxy.whenCalled('getExceptionList').then(function(
660 contentType) {
661 Polymer.dom.flush();
662 var menuItems = getMenuItems(testElement.$.listContainer);
663 assertTrue(!!menuItems);
664 MockInteractions.tap(menuItems[0]);
tommycli 2016/08/11 21:53:10 After the tap, return browserProxy.whenCalled('res
dschuyler 2016/08/11 22:40:14 Done.
665 });
666 });
644 }); 667 });
645 } 668 }
646 return { 669 return {
647 registerTests: registerTests, 670 registerTests: registerTests,
648 }; 671 };
649 }); 672 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/site_settings/site_list.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698