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