browser/devtools/commandline/test/browser_gcli_incomplete.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:0f1dbceafd02
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-testIncomplete.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 assert = require('../testharness/assert');
44 // var helpers = require('./helpers');
45
46 exports.testBasic = function(options) {
47 return helpers.audit(options, [
48 {
49 setup: 'tsu 2 extra',
50 check: {
51 args: {
52 num: { value: 2, type: 'Argument' }
53 }
54 },
55 post: function() {
56 var requisition = options.requisition;
57
58 assert.is(requisition._unassigned.length,
59 1,
60 'single unassigned: tsu 2 extra');
61 assert.is(requisition._unassigned[0].param.type.isIncompleteName,
62 false,
63 'unassigned.isIncompleteName: tsu 2 extra');
64 }
65 },
66 {
67 setup: 'tsu',
68 check: {
69 args: {
70 num: { value: undefined, type: 'BlankArgument' }
71 }
72 }
73 },
74 {
75 setup: 'tsg',
76 check: {
77 args: {
78 solo: { type: 'BlankArgument' },
79 txt1: { type: 'BlankArgument' },
80 bool: { type: 'BlankArgument' },
81 txt2: { type: 'BlankArgument' },
82 num: { type: 'BlankArgument' }
83 }
84 }
85 }
86 ]);
87 };
88
89 exports.testCompleted = function(options) {
90 return helpers.audit(options, [
91 {
92 setup: 'tsela<TAB>',
93 check: {
94 args: {
95 command: { name: 'tselarr', type: 'Argument' },
96 num: { type: 'BlankArgument' },
97 arr: { type: 'ArrayArgument' }
98 }
99 }
100 },
101 {
102 setup: 'tsn dif ',
103 check: {
104 input: 'tsn dif ',
105 hints: '<text>',
106 markup: 'VVVVVVVV',
107 cursor: 8,
108 status: 'ERROR',
109 args: {
110 command: { name: 'tsn dif', type: 'MergedArgument' },
111 text: { type: 'BlankArgument', status: 'INCOMPLETE' }
112 }
113 }
114 },
115 {
116 setup: 'tsn di<TAB>',
117 check: {
118 input: 'tsn dif ',
119 hints: '<text>',
120 markup: 'VVVVVVVV',
121 cursor: 8,
122 status: 'ERROR',
123 args: {
124 command: { name: 'tsn dif', type: 'Argument' },
125 text: { type: 'BlankArgument', status: 'INCOMPLETE' }
126 }
127 }
128 },
129 // The above 2 tests take different routes to 'tsn dif '.
130 // The results should be similar. The difference is in args.command.type.
131 {
132 setup: 'tsg -',
133 check: {
134 input: 'tsg -',
135 hints: '-txt1 <solo> [options]',
136 markup: 'VVVVI',
137 cursor: 5,
138 status: 'ERROR',
139 args: {
140 solo: { value: undefined, status: 'INCOMPLETE' },
141 txt1: { value: undefined, status: 'VALID' },
142 bool: { value: false, status: 'VALID' },
143 txt2: { value: undefined, status: 'VALID' },
144 num: { value: undefined, status: 'VALID' }
145 }
146 }
147 },
148 {
149 setup: 'tsg -<TAB>',
150 check: {
151 input: 'tsg --txt1 ',
152 hints: '<string> <solo> [options]',
153 markup: 'VVVVIIIIIIV',
154 cursor: 11,
155 status: 'ERROR',
156 args: {
157 solo: { value: undefined, status: 'INCOMPLETE' },
158 txt1: { value: undefined, status: 'INCOMPLETE' },
159 bool: { value: false, status: 'VALID' },
160 txt2: { value: undefined, status: 'VALID' },
161 num: { value: undefined, status: 'VALID' }
162 }
163 }
164 },
165 {
166 setup: 'tsg --txt1 fred',
167 check: {
168 input: 'tsg --txt1 fred',
169 hints: ' <solo> [options]',
170 markup: 'VVVVVVVVVVVVVVV',
171 status: 'ERROR',
172 args: {
173 solo: { value: undefined, status: 'INCOMPLETE' },
174 txt1: { value: 'fred', status: 'VALID' },
175 bool: { value: false, status: 'VALID' },
176 txt2: { value: undefined, status: 'VALID' },
177 num: { value: undefined, status: 'VALID' }
178 }
179 }
180 },
181 {
182 setup: 'tscook key value --path path --',
183 check: {
184 input: 'tscook key value --path path --',
185 hints: 'domain [options]',
186 markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVII',
187 status: 'ERROR',
188 args: {
189 key: { value: 'key', status: 'VALID' },
190 value: { value: 'value', status: 'VALID' },
191 path: { value: 'path', status: 'VALID' },
192 domain: { value: undefined, status: 'VALID' },
193 secure: { value: false, status: 'VALID' }
194 }
195 }
196 },
197 {
198 setup: 'tscook key value --path path --domain domain --',
199 check: {
200 input: 'tscook key value --path path --domain domain --',
201 hints: 'secure [options]',
202 markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVII',
203 status: 'ERROR',
204 args: {
205 key: { value: 'key', status: 'VALID' },
206 value: { value: 'value', status: 'VALID' },
207 path: { value: 'path', status: 'VALID' },
208 domain: { value: 'domain', status: 'VALID' },
209 secure: { value: false, status: 'VALID' }
210 }
211 }
212 }
213 ]);
214
215 };
216
217 exports.testCase = function(options) {
218 return helpers.audit(options, [
219 {
220 setup: 'tsg AA',
221 check: {
222 input: 'tsg AA',
223 hints: ' [options] -> aaa',
224 markup: 'VVVVII',
225 status: 'ERROR',
226 args: {
227 solo: { value: undefined, text: 'AA', status: 'INCOMPLETE' },
228 txt1: { value: undefined, status: 'VALID' },
229 bool: { value: false, status: 'VALID' },
230 txt2: { value: undefined, status: 'VALID' },
231 num: { value: undefined, status: 'VALID' }
232 }
233 }
234 }
235 ]);
236 };
237
238 exports.testIncomplete = function(options) {
239 return helpers.audit(options, [
240 {
241 setup: 'tsm a a -',
242 check: {
243 args: {
244 abc: { value: 'a', type: 'Argument' },
245 txt: { value: 'a', type: 'Argument' },
246 num: { value: undefined, arg: ' -', type: 'Argument', status: 'INCOMPLETE' }
247 }
248 }
249 },
250 {
251 setup: 'tsg -',
252 check: {
253 args: {
254 solo: { type: 'BlankArgument' },
255 txt1: { type: 'BlankArgument' },
256 bool: { type: 'BlankArgument' },
257 txt2: { type: 'BlankArgument' },
258 num: { type: 'BlankArgument' }
259 }
260 },
261 post: function() {
262 var requisition = options.requisition;
263
264 assert.is(requisition._unassigned[0],
265 requisition.getAssignmentAt(5),
266 'unassigned -');
267 assert.is(requisition._unassigned.length,
268 1,
269 'single unassigned - tsg -');
270 assert.is(requisition._unassigned[0].param.type.isIncompleteName,
271 true,
272 'unassigned.isIncompleteName: tsg -');
273 }
274 }
275 ]);
276 };
277
278 exports.testRepeated = function(options) {
279 return helpers.audit(options, [
280 {
281 setup: 'tscook key value --path jjj --path kkk',
282 check: {
283 input: 'tscook key value --path jjj --path kkk',
284 hints: ' [options]',
285 markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVEEEEEEVEEE',
286 cursor: 38,
287 current: '__unassigned',
288 status: 'ERROR',
289 options: [ ],
290 message: '',
291 predictions: [ ],
292 unassigned: [ ' --path', ' kkk' ],
293 args: {
294 command: { name: 'tscook' },
295 key: {
296 value: 'key',
297 arg: ' key',
298 status: 'VALID',
299 message: ''
300 },
301 value: {
302 value: 'value',
303 arg: ' value',
304 status: 'VALID',
305 message: ''
306 },
307 path: {
308 value: 'jjj',
309 arg: ' --path jjj',
310 status: 'VALID',
311 message: ''
312 },
313 domain: {
314 value: undefined,
315 arg: '',
316 status: 'VALID',
317 message: ''
318 },
319 secure: {
320 value: false,
321 arg: '',
322 status: 'VALID',
323 message: ''
324 },
325 }
326 }
327 }
328 ]);
329 };
330
331 exports.testHidden = function(options) {
332 return helpers.audit(options, [
333 {
334 setup: 'tshidde',
335 check: {
336 input: 'tshidde',
337 hints: ' -> tse',
338 status: 'ERROR'
339 }
340 },
341 {
342 setup: 'tshidden',
343 check: {
344 input: 'tshidden',
345 hints: ' [options]',
346 markup: 'VVVVVVVV',
347 status: 'VALID',
348 args: {
349 visible: { value: undefined, status: 'VALID' },
350 invisiblestring: { value: undefined, status: 'VALID' },
351 invisibleboolean: { value: false, status: 'VALID' }
352 }
353 }
354 },
355 {
356 setup: 'tshidden --vis',
357 check: {
358 input: 'tshidden --vis',
359 hints: 'ible [options]',
360 markup: 'VVVVVVVVVIIIII',
361 status: 'ERROR',
362 args: {
363 visible: { value: undefined, status: 'VALID' },
364 invisiblestring: { value: undefined, status: 'VALID' },
365 invisibleboolean: { value: false, status: 'VALID' }
366 }
367 }
368 },
369 {
370 setup: 'tshidden --invisiblestrin',
371 check: {
372 input: 'tshidden --invisiblestrin',
373 hints: ' [options]',
374 markup: 'VVVVVVVVVEEEEEEEEEEEEEEEE',
375 status: 'ERROR',
376 args: {
377 visible: { value: undefined, status: 'VALID' },
378 invisiblestring: { value: undefined, status: 'VALID' },
379 invisibleboolean: { value: false, status: 'VALID' }
380 }
381 }
382 },
383 {
384 setup: 'tshidden --invisiblestring',
385 check: {
386 input: 'tshidden --invisiblestring',
387 hints: ' <string> [options]',
388 markup: 'VVVVVVVVVIIIIIIIIIIIIIIIII',
389 status: 'ERROR',
390 args: {
391 visible: { value: undefined, status: 'VALID' },
392 invisiblestring: { value: undefined, status: 'INCOMPLETE' },
393 invisibleboolean: { value: false, status: 'VALID' }
394 }
395 }
396 },
397 {
398 setup: 'tshidden --invisiblestring x',
399 check: {
400 input: 'tshidden --invisiblestring x',
401 hints: ' [options]',
402 markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVV',
403 status: 'VALID',
404 args: {
405 visible: { value: undefined, status: 'VALID' },
406 invisiblestring: { value: 'x', status: 'VALID' },
407 invisibleboolean: { value: false, status: 'VALID' }
408 }
409 }
410 },
411 {
412 setup: 'tshidden --invisibleboolea',
413 check: {
414 input: 'tshidden --invisibleboolea',
415 hints: ' [options]',
416 markup: 'VVVVVVVVVEEEEEEEEEEEEEEEEE',
417 status: 'ERROR',
418 args: {
419 visible: { value: undefined, status: 'VALID' },
420 invisiblestring: { value: undefined, status: 'VALID' },
421 invisibleboolean: { value: false, status: 'VALID' }
422 }
423 }
424 },
425 {
426 setup: 'tshidden --invisibleboolean',
427 check: {
428 input: 'tshidden --invisibleboolean',
429 hints: ' [options]',
430 markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVV',
431 status: 'VALID',
432 args: {
433 visible: { value: undefined, status: 'VALID' },
434 invisiblestring: { value: undefined, status: 'VALID' },
435 invisibleboolean: { value: true, status: 'VALID' }
436 }
437 }
438 },
439 {
440 setup: 'tshidden --visible xxx',
441 check: {
442 input: 'tshidden --visible xxx',
443 markup: 'VVVVVVVVVVVVVVVVVVVVVV',
444 status: 'VALID',
445 hints: '',
446 args: {
447 visible: { value: 'xxx', status: 'VALID' },
448 invisiblestring: { value: undefined, status: 'VALID' },
449 invisibleboolean: { value: false, status: 'VALID' }
450 }
451 }
452 }
453 ]);
454 };

mercurial