1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const
|
13 | fs = require('fs'),
|
14 | windowslib = require('..');
|
15 |
|
16 | describe('wptool', function () {
|
17 | it('namespace should be an object', function () {
|
18 | should(windowslib.wptool).be.an.Object;
|
19 | });
|
20 |
|
21 | it('should parse Windows 10 WinAppDeployCmd.exe device listing output', function (done) {
|
22 | this.timeout(1000);
|
23 | this.slow(500);
|
24 |
|
25 | var output = 'Windows App Deployment Tool\r\nVersion 10.0.0.0\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\n\r\nDiscovering devices...\r\nIP Address GUID Model/Name\r\n127.0.0.1 00000045-8aab-6667-0000-000000000000 Windows Phone 8\r\n10.120.68.150 00000015-b21e-0da9-0000-000000000000 Lumia 1520 (RM-940)\r\n10.120.70.172 00000000-0000-0000-0000-00155d619532 00155D619532\r\nDone.';
|
26 | var devices = windowslib.wptool.test.parseWinAppDeployCmdListing(output);
|
27 | should(devices).be.an.Array;
|
28 | should(devices.length).equal(3);
|
29 |
|
30 |
|
31 | devices.forEach(function (d) {
|
32 | should(d).be.an.Object;
|
33 | should(d).have.ownProperty('name');
|
34 | should(d).have.ownProperty('udid');
|
35 | should(d).have.ownProperty('index');
|
36 | should(d).have.ownProperty('wpsdk');
|
37 | should(d).have.ownProperty('ip');
|
38 |
|
39 | should(d.name).be.a.String;
|
40 | should(d.index).be.an.Integer;
|
41 | should(d.udid).be.a.String;
|
42 | should(d.ip).be.a.String;
|
43 | });
|
44 |
|
45 |
|
46 | should(devices[0].name).equal('Windows Phone 8');
|
47 | should(devices[0].index).equal(0);
|
48 | should(devices[0].udid).equal('00000045-8aab-6667-0000-000000000000');
|
49 | should(devices[0].ip).equal('127.0.0.1');
|
50 |
|
51 |
|
52 | should(devices[1].name).equal('Lumia 1520 (RM-940)');
|
53 | should(devices[1].index).equal(1);
|
54 | should(devices[1].udid).equal('00000015-b21e-0da9-0000-000000000000');
|
55 | should(devices[1].ip).equal('10.120.68.150');
|
56 |
|
57 |
|
58 | should(devices[2].name).equal('00155D619532');
|
59 | should(devices[2].index).equal(2);
|
60 | should(devices[2].udid).equal('00000000-0000-0000-0000-00155d619532');
|
61 | should(devices[2].ip).equal('10.120.70.172');
|
62 |
|
63 | done();
|
64 | });
|
65 |
|
66 | it('should parse Windows 8.1 AppDeployCmd.exe emulator listing output', function (done) {
|
67 | this.timeout(1000);
|
68 | this.slow(500);
|
69 |
|
70 | var wpsdk = '8.1',
|
71 | output = '\r\n' +
|
72 | 'Device Index Device Name\r\n' +
|
73 | '------------ -------------------------------\r\n' +
|
74 | ' 0 Device\r\n' +
|
75 | ' 1 Mobile Emulator 10.0.10586.0 WVGA 4 inch 512MB\r\n' +
|
76 | ' 2 Mobile Emulator 10.0.10586.0 WVGA 4 inch 1GB\r\n' +
|
77 | ' 3 Mobile Emulator 10.0.10586.0 WXGA 4.5 inch 1GB\r\n' +
|
78 | ' 4 Mobile Emulator 10.0.10586.0 720p 5 inch 1GB\r\n' +
|
79 | ' 5 Mobile Emulator 10.0.10586.0 1080p 6 inch 2GB\r\n' +
|
80 | ' 6 Mobile Emulator 10.0.10586.0 QHD 5.2 inch 3GB\r\n' +
|
81 | ' 7 Emulator 8.1 U1 WVGA 4 inch 512MB\r\n' +
|
82 | ' 8 Emulator 8.1 U1 WVGA 4 inch\r\n' +
|
83 | ' 9 Emulator 8.1 U1 WXGA 4.5 inch\r\n' +
|
84 | ' 10 Emulator 8.1 U1 720P 4.7 inch\r\n' +
|
85 | ' 11 Emulator 8.1 U1 1080P 5.5 inch\r\n' +
|
86 | ' 12 Emulator 8.1 U1 1080P 6 inch\r\n' +
|
87 | ' 13 Emulator 8.1 U1 qHD 5 inch\r\n' +
|
88 | ' 14 Emulator 8.1 WVGA 4 inch 512MB\r\n' +
|
89 | ' 15 Emulator 8.1 WVGA 4 inch\r\n' +
|
90 | ' 16 Emulator 8.1 WXGA 4.5 inch\r\n' +
|
91 | ' 17 Emulator 8.1 720P 4.7 inch\r\n' +
|
92 | ' 18 Emulator 8.1 1080P 5.5 inch\r\n' +
|
93 | ' 19 Emulator 8.1 1080P 6 inch\r\n' +
|
94 | 'Done.';
|
95 | var emulators = windowslib.wptool.test.parseAppDeployCmdListing(output, wpsdk);
|
96 | should(emulators).be.an.Array;
|
97 | should(emulators.length).equal(13);
|
98 |
|
99 |
|
100 | emulators.forEach(function (e) {
|
101 | should(e).be.an.Object;
|
102 | should(e).have.ownProperty('name');
|
103 | should(e).have.ownProperty('udid');
|
104 | should(e).have.ownProperty('index');
|
105 | should(e).have.ownProperty('wpsdk');
|
106 |
|
107 | should(e.name).be.a.String;
|
108 | should(e.name).not.equal('');
|
109 |
|
110 | should(e.index).be.an.Integer;
|
111 |
|
112 | should(e.wpsdk).equal(wpsdk);
|
113 | });
|
114 |
|
115 | done();
|
116 | });
|
117 |
|
118 | (process.platform === 'win32' ? it : it.skip)('should enumerate all Windows Phone devices and emulators', function (done) {
|
119 | this.timeout(5000);
|
120 | this.slow(4000);
|
121 |
|
122 | windowslib.wptool.enumerate(function (err, results) {
|
123 | if (err) {
|
124 | return done(err);
|
125 | }
|
126 |
|
127 | should(results).be.an.Object;
|
128 |
|
129 | function checkDevices(devs) {
|
130 | should(devs).be.an.Array;
|
131 |
|
132 | devs.forEach(function (d) {
|
133 | should(d).be.an.Object;
|
134 | should(d).have.ownProperty('name');
|
135 | should(d).have.ownProperty('udid');
|
136 | should(d).have.ownProperty('index');
|
137 | should(d).have.ownProperty('wpsdk');
|
138 |
|
139 | should(d.name).be.a.String;
|
140 | should(d.name).not.equal('');
|
141 |
|
142 | should(d.index).be.an.Integer;
|
143 | });
|
144 | }
|
145 |
|
146 | Object.keys(results).forEach(function (wpsdk) {
|
147 | should(results[wpsdk]).be.an.Object;
|
148 | should(results[wpsdk]).have.keys('devices', 'emulators');
|
149 |
|
150 | checkDevices(results[wpsdk].devices);
|
151 | checkDevices(results[wpsdk].emulators);
|
152 | });
|
153 |
|
154 | done();
|
155 | });
|
156 | });
|
157 |
|
158 | (process.platform === 'win32' ? it : it.skip)('should enumerate only 8.1 Windows Phone devices and emulators when supportedWindowsPhoneSDKVersions is 8.1', function (done) {
|
159 | this.timeout(5000);
|
160 | this.slow(4000);
|
161 |
|
162 | windowslib.wptool.enumerate({supportedWindowsPhoneSDKVersions: '8.1', bypassCache: true}, function (err, results) {
|
163 | if (err) {
|
164 | return done(err);
|
165 | }
|
166 |
|
167 | should(results).be.an.Object;
|
168 |
|
169 | function checkDevices(devs) {
|
170 | should(devs).be.an.Array;
|
171 |
|
172 | devs.forEach(function (d) {
|
173 | should(d).be.an.Object;
|
174 | should(d).have.ownProperty('name');
|
175 | should(d).have.ownProperty('udid');
|
176 | should(d).have.ownProperty('index');
|
177 | should(d).have.ownProperty('wpsdk');
|
178 |
|
179 | should(d.name).be.a.String;
|
180 | should(d.name).not.equal('');
|
181 |
|
182 | should(d.index).be.an.Integer;
|
183 | });
|
184 | }
|
185 |
|
186 | Object.keys(results).forEach(function (wpsdk) {
|
187 | should(wpsdk).not.equal('10.0')
|
188 | should(results[wpsdk]).be.an.Object;
|
189 | should(results[wpsdk]).have.keys('devices', 'emulators');
|
190 |
|
191 | checkDevices(results[wpsdk].devices);
|
192 | checkDevices(results[wpsdk].emulators);
|
193 | });
|
194 |
|
195 | done();
|
196 | });
|
197 | });
|
198 |
|
199 | (process.platform === 'win32' ? it : it.skip)('should enumerate only 10.0 Windows Phone devices and emulators when supportedWindowsPhoneSDKVersions is 10.0', function (done) {
|
200 | this.timeout(5000);
|
201 | this.slow(4000);
|
202 |
|
203 | windowslib.wptool.enumerate({supportedWindowsPhoneSDKVersions: '10.0', bypassCache: true}, function (err, results) {
|
204 | if (err) {
|
205 | return done(err);
|
206 | }
|
207 |
|
208 | should(results).be.an.Object;
|
209 |
|
210 | function checkDevices(devs) {
|
211 | should(devs).be.an.Array;
|
212 |
|
213 | devs.forEach(function (d) {
|
214 | should(d).be.an.Object;
|
215 | should(d).have.ownProperty('name');
|
216 | should(d).have.ownProperty('udid');
|
217 | should(d).have.ownProperty('index');
|
218 | should(d).have.ownProperty('wpsdk');
|
219 |
|
220 | should(d.name).be.a.String;
|
221 | should(d.name).not.equal('');
|
222 |
|
223 | should(d.index).be.an.Integer;
|
224 | });
|
225 | }
|
226 |
|
227 | Object.keys(results).forEach(function (wpsdk) {
|
228 | should(wpsdk).not.equal('8.1')
|
229 | should(results[wpsdk]).be.an.Object;
|
230 | should(results[wpsdk]).have.keys('devices', 'emulators');
|
231 |
|
232 | checkDevices(results[wpsdk].devices);
|
233 | checkDevices(results[wpsdk].emulators);
|
234 | });
|
235 |
|
236 | done();
|
237 | });
|
238 | });
|
239 |
|
240 | (process.platform === 'win32' ? it : it.skip)('should enumerate 8.1 and 10.0 Windows Phone devices and emulators when supportedWindowsPhoneSDKVersions is 8.1 and 10.0', function (done) {
|
241 | this.timeout(5000);
|
242 | this.slow(4000);
|
243 |
|
244 | windowslib.wptool.enumerate({supportedWindowsPhoneSDKVersions: '8.1 || 10.0', bypassCache: true}, function (err, results) {
|
245 | if (err) {
|
246 | return done(err);
|
247 | }
|
248 |
|
249 | should(results).be.an.Object;
|
250 |
|
251 | function checkDevices(devs) {
|
252 | should(devs).be.an.Array;
|
253 |
|
254 | devs.forEach(function (d) {
|
255 | should(d).be.an.Object;
|
256 | should(d).have.ownProperty('name');
|
257 | should(d).have.ownProperty('udid');
|
258 | should(d).have.ownProperty('index');
|
259 | should(d).have.ownProperty('wpsdk');
|
260 |
|
261 | should(d.name).be.a.String;
|
262 | should(d.name).not.equal('');
|
263 |
|
264 | should(d.index).be.an.Integer;
|
265 | });
|
266 | }
|
267 | should(results['8.1']).be.an.Object;
|
268 | should(results['10.0']).be.an.Object;
|
269 | Object.keys(results).forEach(function (wpsdk) {
|
270 | should(results[wpsdk]).be.an.Object;
|
271 | should(results[wpsdk]).have.keys('devices', 'emulators');
|
272 |
|
273 | checkDevices(results[wpsdk].devices);
|
274 | checkDevices(results[wpsdk].emulators);
|
275 | });
|
276 |
|
277 | done();
|
278 | });
|
279 | });
|
280 |
|
281 | it('should not connect to a device with a bad udid', function (done) {
|
282 | this.timeout(5000);
|
283 | this.slow(4000);
|
284 |
|
285 | windowslib.wptool.connect('bad udid', function (err) {
|
286 | if (err) {
|
287 | done();
|
288 | } else {
|
289 | done(new Error('Expected udid 100 to be invalid'));
|
290 | }
|
291 | }).on('error', function () {});
|
292 | });
|
293 |
|
294 | ((process.env.JENKINS || process.platform !== 'win32') ? it.skip : it)('should connect to a device with a valid udid', function (done) {
|
295 | this.timeout(10000);
|
296 | this.slow(9000);
|
297 |
|
298 | windowslib.wptool.connect('0', function (err) {
|
299 | done(err);
|
300 | }).on('error', function () {});
|
301 | });
|
302 | });
|