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

Side by Side Diff: chrome/test/data/webui/extensions/extension_test_util.js

Issue 1447183005: [MD Extensions] Fix item sorting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 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 Common utilities for extension ui tests. */ 5 /** @fileoverview Common utilities for extension ui tests. */
6 cr.define('extension_test_util', function() { 6 cr.define('extension_test_util', function() {
7 /** 7 /**
8 * A mock to test that clicking on an element calls a specific method. 8 * A mock to test that clicking on an element calls a specific method.
9 * @constructor 9 * @constructor
10 */ 10 */
(...skipping 28 matching lines...) Expand all
39 */ 39 */
40 function testVisible(parentEl, selector, expectedVisible, opt_expected) { 40 function testVisible(parentEl, selector, expectedVisible, opt_expected) {
41 var element = parentEl.$$(selector); 41 var element = parentEl.$$(selector);
42 var rect = element ? element.getBoundingClientRect() : null; 42 var rect = element ? element.getBoundingClientRect() : null;
43 var isVisible = !!rect && rect.width * rect.height > 0; 43 var isVisible = !!rect && rect.width * rect.height > 0;
44 expectEquals(expectedVisible, isVisible, selector); 44 expectEquals(expectedVisible, isVisible, selector);
45 if (expectedVisible && opt_expected && element) 45 if (expectedVisible && opt_expected && element)
46 expectEquals(opt_expected, element.textContent, selector); 46 expectEquals(opt_expected, element.textContent, selector);
47 } 47 }
48 48
49 /**
50 * Creates an ExtensionInfo object.
51 * @param {Object=} opt_properties A set of properties that will be used on
52 * the resulting ExtensionInfo (otherwise defaults will be used).
53 * @return {chrome.developerPrivate.ExtensionInfo}
54 */
55 function createExtensionInfo(opt_properties) {
56 var id = opt_properties && opt_properties.hasOwnProperty('id') ?
57 opt_properties[id] : 'a'.repeat(32);
58 var baseUrl = 'chrome-extension://' + id + '/';
59 var data = {
60 description: 'This is an extension',
61 iconUrl: 'chrome://extension-icon/' + id + '/24/0',
62 id: id,
63 incognitoAccess: {isEnabled: true, isActive: false},
64 location: 'FROM_STORE',
65 name: 'Wonderful Extension',
66 state: 'ENABLED',
67 type: 'EXTENSION',
68 version: '2.0',
69 views: [{url: baseUrl + 'foo.html'}, {url: baseUrl + 'bar.html'}],
michaelpg 2015/11/18 09:08:46 not to nitpick, but if the caller passes {url: foo
Devlin 2015/11/18 17:16:59 It shouldn't be - views is the key on the object,
michaelpg 2015/11/18 20:01:17 Oh, baseUrl is generated from the id -- that was w
70 }
71 if (opt_properties) {
michaelpg 2015/11/18 09:08:46 Object.assign(data, opt_properties); // even work
Devlin 2015/11/18 17:17:00 Rad. Done.
72 Object.getOwnPropertyNames(opt_properties).forEach(function(name) {
73 data[name] = opt_properties[name];
74 });
75 }
76 return data;
77 }
78
49 return { 79 return {
50 ClickMock: ClickMock, 80 ClickMock: ClickMock,
51 testVisible: testVisible, 81 testVisible: testVisible,
82 createExtensionInfo: createExtensionInfo,
52 }; 83 };
53 }); 84 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698