OLD | NEW |
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 Loading... |
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 return Object.assign({ |
| 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'}], |
| 70 }, opt_properties); |
| 71 } |
| 72 |
49 return { | 73 return { |
50 ClickMock: ClickMock, | 74 ClickMock: ClickMock, |
51 testVisible: testVisible, | 75 testVisible: testVisible, |
| 76 createExtensionInfo: createExtensionInfo, |
52 }; | 77 }; |
53 }); | 78 }); |
OLD | NEW |