OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 /** | 5 /** |
6 * Fixture for startup pages WebUI tests. | 6 * Fixture for startup pages WebUI tests. |
7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
8 * @constructor | 8 * @constructor |
9 */ | 9 */ |
10 function StartupPageListWebUITest() {} | 10 function StartupPageListWebUITest() {} |
11 | 11 |
12 StartupPageListWebUITest.prototype = { | 12 StartupPageListWebUITest.prototype = { |
13 __proto__: testing.Test.prototype, | 13 __proto__: testing.Test.prototype, |
14 | 14 |
15 /** | 15 /** |
16 * Browse to the options page & call our preLoad(). | 16 * Browse to the options page & call our preLoad(). |
17 * @override | 17 * @override |
18 */ | 18 */ |
19 browsePreload: 'chrome://settings-frame/startup', | 19 browsePreload: 'chrome://settings-frame/startup', |
20 | 20 |
21 /** @override */ | 21 /** @override */ |
22 setUp: function() { | 22 setUp: function() { |
23 StartupOverlay.updateStartupPages(this.fakeStartupList); | 23 StartupOverlay.updateStartupPages(this.fakeStartupList); |
24 // 1 item for entering data, 1+ from |this.fakeStartupList|. | 24 // 1 item for entering data, 1+ from |this.fakeStartupList|. |
25 assertGE(this.getList().items.length, 2); | 25 assertGE(this.getList().items.length, 2); |
26 }, | 26 }, |
27 | 27 |
28 /** | 28 /** |
29 * Returns the list to be tested. | 29 * Returns the list to be tested. |
30 * @return {Element} | 30 * @return {Element} The start-up pages list. |
31 * @protected | 31 * @protected |
32 */ | 32 */ |
33 getList: function() { | 33 getList: function() { |
34 return $('startupPagesList'); | 34 return $('startupPagesList'); |
35 }, | 35 }, |
36 | 36 |
37 /** | 37 /** |
38 * Register a mock handler to ensure expectations are met and options pages | 38 * Register a mock handler to ensure expectations are met and options pages |
39 * behave correctly. | 39 * behave correctly. |
40 * @override | 40 * @override |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 * @param {string} type The text of data being set. | 96 * @param {string} type The text of data being set. |
97 * @param {*} val The data to set. Will be stringified. | 97 * @param {*} val The data to set. Will be stringified. |
98 */ | 98 */ |
99 setData: function(type, val) { | 99 setData: function(type, val) { |
100 this.data_[type] = String(val); | 100 this.data_[type] = String(val); |
101 }, | 101 }, |
102 | 102 |
103 /** | 103 /** |
104 * Gets data associated with this fake data transfer. | 104 * Gets data associated with this fake data transfer. |
105 * @param {string} type The type of data to get. | 105 * @param {string} type The type of data to get. |
106 * @returns {string} The requested type of data or '' if not set. | 106 * @return {string} The requested type of data or '' if not set. |
107 */ | 107 */ |
108 getData: function(type) { | 108 getData: function(type) { |
109 return this.data_[type] || ''; | 109 return this.data_[type] || ''; |
110 }, | 110 }, |
111 }; | 111 }; |
112 | 112 |
113 /** | 113 /** |
114 * Creates a fake bubbling, cancelable mouse event with a mock data transfer | 114 * Creates a fake bubbling, cancelable mouse event with a mock data transfer |
115 * installed. | 115 * installed. |
116 * @param {string} type A type of mouse event (e.g. 'drop'). | 116 * @param {string} type A type of mouse event (e.g. 'drop'). |
(...skipping 22 matching lines...) Expand all Loading... |
139 // TODO(dbeam): mock4js doesn't handle complex arguments well. Fix this. | 139 // TODO(dbeam): mock4js doesn't handle complex arguments well. Fix this. |
140 this.mockHandler.expects(once()).dragDropStartupPage([0, [1].join()]); | 140 this.mockHandler.expects(once()).dragDropStartupPage([0, [1].join()]); |
141 | 141 |
142 this.getList().selectionModel.selectedIndex = 1; | 142 this.getList().selectionModel.selectedIndex = 1; |
143 expectEquals(1, this.getList().selectionModel.selectedIndexes.length); | 143 expectEquals(1, this.getList().selectionModel.selectedIndexes.length); |
144 | 144 |
145 this.getList().items[0].dispatchEvent(createMouseEvent('drop')); | 145 this.getList().items[0].dispatchEvent(createMouseEvent('drop')); |
146 }); | 146 }); |
147 | 147 |
148 }()); | 148 }()); |
OLD | NEW |