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

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

Issue 2837703002: Change SettingsLanguagesPageBrowserTest to CrSettingsLanguagesPageTest (Closed)
Patch Set: rebase Created 3 years, 7 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('test_util', function() { 5 cr.define('test_util', function() {
6 /** 6 /**
7 * Observes an HTML attribute and fires a promise when it matches a given 7 * Observes an HTML attribute and fires a promise when it matches a given
8 * value. 8 * value.
9 * @param {!HTMLElement} target 9 * @param {!HTMLElement} target
10 * @param {string} attributeName 10 * @param {string} attributeName
(...skipping 23 matching lines...) Expand all
34 * @param {string} eventType 34 * @param {string} eventType
35 * @param {!HTMLElement} target 35 * @param {!HTMLElement} target
36 * @return {!Promise} A promise firing once the event occurs. 36 * @return {!Promise} A promise firing once the event occurs.
37 */ 37 */
38 function eventToPromise(eventType, target) { 38 function eventToPromise(eventType, target) {
39 return new Promise(function(resolve, reject) { 39 return new Promise(function(resolve, reject) {
40 target.addEventListener(eventType, resolve); 40 target.addEventListener(eventType, resolve);
41 }); 41 });
42 } 42 }
43 43
44 /**
45 * Data-binds two Polymer properties using the property-changed events and
46 * set/notifyPath API. Useful for testing components which would normally be
47 * used together.
48 * @param {!HTMLElement} el1
49 * @param {!HTMLElement} el2
50 * @param {string} property
51 */
52 function fakeDataBind(el1, el2, property) {
53 var forwardChange = function(el, event) {
54 if (event.detail.hasOwnProperty('path'))
55 el.notifyPath(event.detail.path, event.detail.value);
56 else
57 el.set(property, event.detail.value);
58 };
59 // Add the listeners symmetrically. Polymer will prevent recursion.
60 el1.addEventListener(property + '-changed', forwardChange.bind(null, el2));
61 el2.addEventListener(property + '-changed', forwardChange.bind(null, el1));
62 }
63
44 return { 64 return {
45 eventToPromise: eventToPromise, 65 eventToPromise: eventToPromise,
66 fakeDataBind: fakeDataBind,
46 whenAttributeIs: whenAttributeIs, 67 whenAttributeIs: whenAttributeIs,
47 }; 68 };
48 }); 69 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/settings/test_languages_browser_proxy.js ('k') | ui/webui/resources/cr_elements/shared_vars_css.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698