|
1 /* |
|
2 * Copyright 2012, Mozilla Foundation and contributors |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 'use strict'; |
|
18 // <INJECTED SOURCE:START> |
|
19 |
|
20 // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT |
|
21 // DO NOT EDIT IT DIRECTLY |
|
22 |
|
23 var exports = {}; |
|
24 |
|
25 var TEST_URI = "data:text/html;charset=utf-8,<p id='gcli-input'>gcli-testContext.js</p>"; |
|
26 |
|
27 function test() { |
|
28 return Task.spawn(function() { |
|
29 let options = yield helpers.openTab(TEST_URI); |
|
30 yield helpers.openToolbar(options); |
|
31 gcli.addItems(mockCommands.items); |
|
32 |
|
33 yield helpers.runTests(options, exports); |
|
34 |
|
35 gcli.removeItems(mockCommands.items); |
|
36 yield helpers.closeToolbar(options); |
|
37 yield helpers.closeTab(options); |
|
38 }).then(finish, helpers.handleError); |
|
39 } |
|
40 |
|
41 // <INJECTED SOURCE:END> |
|
42 |
|
43 // var helpers = require('./helpers'); |
|
44 |
|
45 exports.testBaseline = function(options) { |
|
46 return helpers.audit(options, [ |
|
47 // These 3 establish a baseline for comparison when we have used the |
|
48 // context command |
|
49 { |
|
50 setup: 'ext', |
|
51 check: { |
|
52 input: 'ext', |
|
53 hints: ' -> context', |
|
54 markup: 'III', |
|
55 message: '', |
|
56 predictions: [ 'context', 'tsn ext', 'tsn exte', 'tsn exten', 'tsn extend' ], |
|
57 unassigned: [ ], |
|
58 } |
|
59 }, |
|
60 { |
|
61 setup: 'ext test', |
|
62 check: { |
|
63 input: 'ext test', |
|
64 hints: '', |
|
65 markup: 'IIIVEEEE', |
|
66 status: 'ERROR', |
|
67 message: 'Too many arguments', |
|
68 unassigned: [ ' test' ], |
|
69 } |
|
70 }, |
|
71 { |
|
72 setup: 'tsn', |
|
73 check: { |
|
74 input: 'tsn', |
|
75 hints: ' deep down nested cmd', |
|
76 markup: 'III', |
|
77 cursor: 3, |
|
78 current: '__command', |
|
79 status: 'ERROR', |
|
80 predictionsContains: [ 'tsn deep down nested cmd', 'tsn ext', 'tsn exte' ], |
|
81 args: { |
|
82 command: { name: 'tsn' }, |
|
83 } |
|
84 } |
|
85 } |
|
86 ]); |
|
87 }; |
|
88 |
|
89 exports.testContext = function(options) { |
|
90 return helpers.audit(options, [ |
|
91 // Use the 'tsn' context |
|
92 { |
|
93 setup: 'context tsn', |
|
94 check: { |
|
95 input: 'context tsn', |
|
96 hints: ' deep down nested cmd', |
|
97 markup: 'VVVVVVVVVVV', |
|
98 message: '', |
|
99 predictionsContains: [ 'tsn deep down nested cmd', 'tsn ext', 'tsn exte' ], |
|
100 args: { |
|
101 command: { name: 'context' }, |
|
102 prefix: { |
|
103 value: options.requisition.canon.getCommand('tsn'), |
|
104 status: 'VALID', |
|
105 message: '' |
|
106 } |
|
107 } |
|
108 }, |
|
109 exec: { |
|
110 output: 'Using tsn as a command prefix' |
|
111 } |
|
112 }, |
|
113 // For comparison with earlier |
|
114 { |
|
115 setup: 'ext', |
|
116 check: { |
|
117 input: 'ext', |
|
118 hints: ' <text>', |
|
119 markup: 'VVV', |
|
120 predictions: [ 'tsn ext', 'tsn exte', 'tsn exten', 'tsn extend' ], |
|
121 args: { |
|
122 command: { name: 'tsn ext' }, |
|
123 text: { |
|
124 value: undefined, |
|
125 arg: '', |
|
126 status: 'INCOMPLETE' |
|
127 } |
|
128 } |
|
129 } |
|
130 }, |
|
131 { |
|
132 setup: 'ext test', |
|
133 check: { |
|
134 input: 'ext test', |
|
135 hints: '', |
|
136 markup: 'VVVVVVVV', |
|
137 args: { |
|
138 command: { name: 'tsn ext' }, |
|
139 text: { |
|
140 value: 'test', |
|
141 arg: ' test', |
|
142 status: 'VALID', |
|
143 message: '' |
|
144 } |
|
145 } |
|
146 }, |
|
147 exec: { |
|
148 output: 'Exec: tsnExt text=test' |
|
149 } |
|
150 }, |
|
151 { |
|
152 setup: 'tsn', |
|
153 check: { |
|
154 input: 'tsn', |
|
155 hints: ' deep down nested cmd', |
|
156 markup: 'III', |
|
157 message: '', |
|
158 predictionsContains: [ 'tsn deep down nested cmd', 'tsn ext', 'tsn exte' ], |
|
159 args: { |
|
160 command: { name: 'tsn' }, |
|
161 } |
|
162 } |
|
163 }, |
|
164 // Does it actually work? |
|
165 { |
|
166 setup: 'tsb true', |
|
167 check: { |
|
168 input: 'tsb true', |
|
169 hints: '', |
|
170 markup: 'VVVVVVVV', |
|
171 options: [ 'true' ], |
|
172 message: '', |
|
173 predictions: [ 'true' ], |
|
174 unassigned: [ ], |
|
175 args: { |
|
176 command: { name: 'tsb' }, |
|
177 toggle: { value: true, arg: ' true', status: 'VALID', message: '' } |
|
178 } |
|
179 } |
|
180 }, |
|
181 { |
|
182 // Bug 866710 - GCLI should allow argument merging for non-string parameters |
|
183 setup: 'context tsn ext', |
|
184 skip: true |
|
185 }, |
|
186 { |
|
187 setup: 'context "tsn ext"', |
|
188 check: { |
|
189 input: 'context "tsn ext"', |
|
190 hints: '', |
|
191 markup: 'VVVVVVVVVVVVVVVVV', |
|
192 message: '', |
|
193 predictions: [ 'tsn ext', 'tsn exte', 'tsn exten', 'tsn extend' ], |
|
194 unassigned: [ ], |
|
195 args: { |
|
196 command: { name: 'context' }, |
|
197 prefix: { |
|
198 value: options.requisition.canon.getCommand('tsn ext'), |
|
199 status: 'VALID', |
|
200 message: '' |
|
201 } |
|
202 } |
|
203 }, |
|
204 exec: { |
|
205 output: 'Can\'t use \'tsn ext\' as a prefix because it is not a parent command.', |
|
206 error: true |
|
207 } |
|
208 }, |
|
209 /* |
|
210 { |
|
211 setup: 'context "tsn deep"', |
|
212 check: { |
|
213 input: 'context "tsn deep"', |
|
214 hints: '', |
|
215 markup: 'VVVVVVVVVVVVVVVVVV', |
|
216 status: 'ERROR', |
|
217 message: '', |
|
218 predictions: [ 'tsn deep' ], |
|
219 unassigned: [ ], |
|
220 args: { |
|
221 command: { name: 'context' }, |
|
222 prefix: { |
|
223 value: options.requisition.canon.getCommand('tsn deep'), |
|
224 status: 'VALID', |
|
225 message: '' |
|
226 } |
|
227 } |
|
228 }, |
|
229 exec: { |
|
230 output: '' |
|
231 } |
|
232 }, |
|
233 */ |
|
234 { |
|
235 setup: 'context', |
|
236 check: { |
|
237 input: 'context', |
|
238 hints: ' [prefix]', |
|
239 markup: 'VVVVVVV', |
|
240 status: 'VALID', |
|
241 unassigned: [ ], |
|
242 args: { |
|
243 command: { name: 'context' }, |
|
244 prefix: { value: undefined, arg: '', status: 'VALID', message: '' }, |
|
245 } |
|
246 }, |
|
247 exec: { |
|
248 output: 'Command prefix is unset', |
|
249 type: 'string', |
|
250 error: false |
|
251 } |
|
252 } |
|
253 ]); |
|
254 }; |