device_test.dart 21 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
import 'dart:async';

7
import 'package:fake_async/fake_async.dart';
8
import 'package:flutter_tools/src/base/io.dart';
9
import 'package:flutter_tools/src/base/logger.dart';
10
import 'package:flutter_tools/src/base/terminal.dart';
11
import 'package:flutter_tools/src/base/user_messages.dart';
12
import 'package:flutter_tools/src/build_info.dart';
13
import 'package:flutter_tools/src/device.dart';
14
import 'package:flutter_tools/src/project.dart';
15
import 'package:test/fake.dart';
16

17
import '../src/common.dart';
18
import '../src/fake_devices.dart';
19

20
void main() {
21
  group('DeviceManager', () {
22
    testWithoutContext('getDevices', () async {
23 24 25 26
      final FakeDevice device1 = FakeDevice('Nexus 5', '0553790d0a4e726f');
      final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
      final FakeDevice device3 = FakeDevice('iPod touch', '82564b38861a9a5');
      final List<Device> devices = <Device>[device1, device2, device3];
27 28 29 30 31 32 33

      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );

34
      expect(await deviceManager.getDevices(), devices);
35
    });
36

37
    testWithoutContext('getDeviceById exact matcher', () async {
38 39 40
      final FakeDevice device1 = FakeDevice('Nexus 5', '0553790d0a4e726f');
      final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
      final FakeDevice device3 = FakeDevice('iPod touch', '82564b38861a9a5');
41
      final List<Device> devices = <Device>[device1, device2, device3];
42
      final BufferLogger logger = BufferLogger.test();
43 44 45 46 47 48 49 50 51

      // Include different device discoveries:
      // 1. One that never completes to prove the first exact match is
      // returned quickly.
      // 2. One that throws, to prove matches can return when some succeed
      // and others fail.
      // 3. A device discoverer that succeeds.
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
52 53 54 55
        deviceDiscoveryOverrides: <DeviceDiscovery>[
          ThrowingPollingDeviceDiscovery(),
          LongPollingDeviceDiscovery(),
        ],
56 57
        logger: logger,
        terminal: Terminal.test(),
58
      );
59

60
      Future<void> expectDevice(String id, List<Device> expected) async {
61
        expect(await deviceManager.getDevicesById(id), expected);
62
      }
63
      await expectDevice('01abfc49119c410e', <Device>[device2]);
64
      expect(logger.traceText, contains('Ignored error discovering 01abfc49119c410e'));
65
      await expectDevice('Nexus 5X', <Device>[device2]);
66
      expect(logger.traceText, contains('Ignored error discovering Nexus 5X'));
67
      await expectDevice('0553790d0a4e726f', <Device>[device1]);
68 69 70
      expect(logger.traceText, contains('Ignored error discovering 0553790d0a4e726f'));
    });

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
    testWithoutContext('getDeviceById exact matcher with well known ID', () async {
      final FakeDevice device1 = FakeDevice('Windows', 'windows');
      final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
      final FakeDevice device3 = FakeDevice('iPod touch', '82564b38861a9a5');
      final List<Device> devices = <Device>[device1, device2, device3];
      final BufferLogger logger = BufferLogger.test();

      // Because the well known ID will match, no other device discovery will run.
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        deviceDiscoveryOverrides: <DeviceDiscovery>[
          ThrowingPollingDeviceDiscovery(),
          LongPollingDeviceDiscovery(),
        ],
        logger: logger,
        terminal: Terminal.test(),
        wellKnownId: 'windows',
      );

      Future<void> expectDevice(String id, List<Device> expected) async {
        deviceManager.specifiedDeviceId = id;
        expect(await deviceManager.getDevicesById(id), expected);
      }
      await expectDevice('windows', <Device>[device1]);
      expect(logger.traceText, isEmpty);
    });

98
    testWithoutContext('getDeviceById prefix matcher', () async {
99 100 101 102
      final FakeDevice device1 = FakeDevice('Nexus 5', '0553790d0a4e726f');
      final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
      final FakeDevice device3 = FakeDevice('iPod touch', '82564b38861a9a5');
      final List<Device> devices = <Device>[device1, device2, device3];
103
      final BufferLogger logger = BufferLogger.test();
104 105 106 107 108 109 110

      // Include different device discoveries:
      // 1. One that throws, to prove matches can return when some succeed
      // and others fail.
      // 2. A device discoverer that succeeds.
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
111 112 113
        deviceDiscoveryOverrides: <DeviceDiscovery>[
          ThrowingPollingDeviceDiscovery(),
        ],
114 115
        logger: logger,
        terminal: Terminal.test(),
116 117 118 119 120
      );

      Future<void> expectDevice(String id, List<Device> expected) async {
        expect(await deviceManager.getDevicesById(id), expected);
      }
121
      await expectDevice('Nexus 5', <Device>[device1]);
122
      expect(logger.traceText, contains('Ignored error discovering Nexus 5'));
123
      await expectDevice('0553790', <Device>[device1]);
124
      expect(logger.traceText, contains('Ignored error discovering 0553790'));
125
      await expectDevice('Nexus', <Device>[device1, device2]);
126
      expect(logger.traceText, contains('Ignored error discovering Nexus'));
127
    });
128

129
    testWithoutContext('getAllConnectedDevices caches', () async {
130
      final FakeDevice device1 = FakeDevice('Nexus 5', '0553790d0a4e726f');
131 132 133 134 135
      final TestDeviceManager deviceManager = TestDeviceManager(
        <Device>[device1],
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
136 137
      expect(await deviceManager.getAllConnectedDevices(), <Device>[device1]);

138
      final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
139 140 141 142
      deviceManager.resetDevices(<Device>[device2]);
      expect(await deviceManager.getAllConnectedDevices(), <Device>[device1]);
    });

143
    testWithoutContext('refreshAllConnectedDevices does not cache', () async {
144
      final FakeDevice device1 = FakeDevice('Nexus 5', '0553790d0a4e726f');
145 146 147 148 149
      final TestDeviceManager deviceManager = TestDeviceManager(
        <Device>[device1],
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
150 151
      expect(await deviceManager.refreshAllConnectedDevices(), <Device>[device1]);

152
      final FakeDevice device2 = FakeDevice('Nexus 5X', '01abfc49119c410e');
153 154 155
      deviceManager.resetDevices(<Device>[device2]);
      expect(await deviceManager.refreshAllConnectedDevices(), <Device>[device2]);
    });
156
  });
157

158 159 160 161 162
  testWithoutContext('PollingDeviceDiscovery startPolling', () {
    FakeAsync().run((FakeAsync time) {
      final FakePollingDeviceDiscovery pollingDeviceDiscovery = FakePollingDeviceDiscovery();
      pollingDeviceDiscovery.startPolling();
      time.elapse(const Duration(milliseconds: 4001));
163

164 165 166
      // First check should use the default polling timeout
      // to quickly populate the list.
      expect(pollingDeviceDiscovery.lastPollingTimeout, isNull);
167

168
      time.elapse(const Duration(milliseconds: 4001));
169

170 171 172
      // Subsequent polling should be much longer.
      expect(pollingDeviceDiscovery.lastPollingTimeout, const Duration(seconds: 30));
      pollingDeviceDiscovery.stopPolling();
173
    });
174 175
  });

176
  group('Filter devices', () {
177 178 179 180 181
    final FakeDevice ephemeralOne = FakeDevice('ephemeralOne', 'ephemeralOne');
    final FakeDevice ephemeralTwo = FakeDevice('ephemeralTwo', 'ephemeralTwo');
    final FakeDevice nonEphemeralOne = FakeDevice('nonEphemeralOne', 'nonEphemeralOne', ephemeral: false);
    final FakeDevice nonEphemeralTwo = FakeDevice('nonEphemeralTwo', 'nonEphemeralTwo', ephemeral: false);
    final FakeDevice unsupported = FakeDevice('unsupported', 'unsupported', isSupported: false);
182 183 184 185 186 187
    final FakeDevice webDevice = FakeDevice('webby', 'webby')
      ..targetPlatform = Future<TargetPlatform>.value(TargetPlatform.web_javascript);
    final FakeDevice fuchsiaDevice = FakeDevice('fuchsiay', 'fuchsiay')
      ..targetPlatform = Future<TargetPlatform>.value(TargetPlatform.fuchsia_x64);

    testWithoutContext('chooses ephemeral device', () async {
188
      final List<Device> devices = <Device>[
189
        ephemeralOne,
190 191 192 193 194
        nonEphemeralOne,
        nonEphemeralTwo,
        unsupported,
      ];

195 196 197 198 199 200
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
201

202
      expect(filtered.single, ephemeralOne);
203 204
    });

205
    testWithoutContext('choose first non-ephemeral device', () async {
206 207 208 209
      final List<Device> devices = <Device>[
        nonEphemeralOne,
        nonEphemeralTwo,
      ];
210 211
      final FakeTerminal terminal = FakeTerminal()
        ..setPrompt(<String>['1', '2', 'q', 'Q'], '1');
212

213 214 215
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
216
        terminal: terminal,
217 218
      );
      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
219 220 221 222 223 224

      expect(filtered, <Device>[
        nonEphemeralOne
      ]);
    });

225
    testWithoutContext('choose second non-ephemeral device', () async {
226 227 228 229
      final List<Device> devices = <Device>[
        nonEphemeralOne,
        nonEphemeralTwo,
      ];
230 231
      final FakeTerminal terminal = FakeTerminal()
        ..setPrompt(<String>['1', '2', 'q', 'Q'], '2');
232

233 234 235
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
236
        terminal: terminal,
237 238
      );
      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
239 240 241 242 243 244

      expect(filtered, <Device>[
        nonEphemeralTwo
      ]);
    });

245
    testWithoutContext('choose first ephemeral device', () async {
246 247 248 249 250
      final List<Device> devices = <Device>[
        ephemeralOne,
        ephemeralTwo,
      ];

251 252
      final FakeTerminal terminal = FakeTerminal()
        ..setPrompt(<String>['1', '2', 'q', 'Q'], '1');
253

254 255 256
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
257
        terminal: terminal,
258 259
      );
      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
260 261 262 263 264 265

      expect(filtered, <Device>[
        ephemeralOne
      ]);
    });

266
    testWithoutContext('choose second ephemeral device', () async {
267 268 269 270
      final List<Device> devices = <Device>[
        ephemeralOne,
        ephemeralTwo,
      ];
271 272
      final FakeTerminal terminal = FakeTerminal()
        ..setPrompt(<String>['1', '2', 'q', 'Q'], '2');
273

274 275 276
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
277
        terminal: terminal,
278 279
      );
      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
280 281

      expect(filtered, <Device>[
282 283 284 285
        ephemeralTwo
      ]);
    });

286
    testWithoutContext('choose non-ephemeral device', () async {
287 288 289
      final List<Device> devices = <Device>[
        ephemeralOne,
        ephemeralTwo,
290 291
        nonEphemeralOne,
        nonEphemeralTwo,
292 293
      ];

294 295
      final FakeTerminal terminal = FakeTerminal()
        ..setPrompt(<String>['1', '2', '3', '4', 'q', 'Q'], '3');
296

297 298 299
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
300
        terminal: terminal,
301 302 303
      );

      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
304 305 306

      expect(filtered, <Device>[
        nonEphemeralOne
307 308
      ]);
    });
309

310
    testWithoutContext('exit from choose one of available devices', () async {
311 312 313 314 315
      final List<Device> devices = <Device>[
        ephemeralOne,
        ephemeralTwo,
      ];

316 317
      final FakeTerminal terminal = FakeTerminal()
        ..setPrompt(<String>['1', '2', 'q', 'Q'], 'q');
318 319 320 321

      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
322
        terminal: terminal,
323 324
      );
      await expectLater(
325
        () async => deviceManager.findTargetDevices(FakeFlutterProject()),
326
        throwsToolExit(),
327
      );
328 329
    });

330
    testWithoutContext('Removes a single unsupported device', () async {
331 332 333 334
      final List<Device> devices = <Device>[
        unsupported,
      ];

335 336 337 338 339 340
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
341 342 343 344

      expect(filtered, <Device>[]);
    });

345
    testWithoutContext('Does not remove an unsupported device if FlutterProject is null', () async {
346 347 348 349
      final List<Device> devices = <Device>[
        unsupported,
      ];

350 351 352 353 354
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
355 356 357 358 359
      final List<Device> filtered = await deviceManager.findTargetDevices(null);

      expect(filtered, <Device>[unsupported]);
    });

360
    testWithoutContext('Removes web and fuchsia from --all', () async {
361 362 363 364
      final List<Device> devices = <Device>[
        webDevice,
        fuchsiaDevice,
      ];
365 366 367 368 369
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
370 371
      deviceManager.specifiedDeviceId = 'all';

372
      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
373 374 375 376

      expect(filtered, <Device>[]);
    });

377
    testWithoutContext('Removes unsupported devices from --all', () async {
378 379 380 381 382
      final List<Device> devices = <Device>[
        nonEphemeralOne,
        nonEphemeralTwo,
        unsupported,
      ];
383 384 385 386 387
      final DeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
388 389
      deviceManager.specifiedDeviceId = 'all';

390
      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
391 392 393 394 395 396

      expect(filtered, <Device>[
        nonEphemeralOne,
        nonEphemeralTwo,
      ]);
    });
397

398
    testWithoutContext('uses DeviceManager.isDeviceSupportedForProject instead of device.isSupportedForProject', () async {
399 400 401
      final List<Device> devices = <Device>[
        unsupported,
      ];
402 403 404 405 406
      final TestDeviceManager deviceManager = TestDeviceManager(
        devices,
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
407 408
      deviceManager.isAlwaysSupportedOverride = true;

409
      final List<Device> filtered = await deviceManager.findTargetDevices(FakeFlutterProject());
410 411 412 413 414

      expect(filtered, <Device>[
        unsupported,
      ]);
    });
415

416
    testWithoutContext('does not refresh device cache without a timeout', () async {
417 418 419
      final List<Device> devices = <Device>[
        ephemeralOne,
      ];
420 421
      final MockDeviceDiscovery deviceDiscovery = MockDeviceDiscovery()
        ..deviceValues = devices;
422

423 424 425
      final DeviceManager deviceManager = TestDeviceManager(
        <Device>[],
        deviceDiscoveryOverrides: <DeviceDiscovery>[
426
          deviceDiscovery
427 428 429 430
        ],
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
431 432
      deviceManager.specifiedDeviceId = ephemeralOne.id;
      final List<Device> filtered = await deviceManager.findTargetDevices(
433
        FakeFlutterProject(),
434 435 436
      );

      expect(filtered.single, ephemeralOne);
437 438
      expect(deviceDiscovery.devicesCalled, 1);
      expect(deviceDiscovery.discoverDevicesCalled, 0);
439 440
    });

441
    testWithoutContext('refreshes device cache with a timeout', () async {
442 443 444 445
      final List<Device> devices = <Device>[
        ephemeralOne,
      ];
      const Duration timeout = Duration(seconds: 2);
446 447
      final MockDeviceDiscovery deviceDiscovery = MockDeviceDiscovery()
        ..deviceValues = devices;
448

449 450 451
      final DeviceManager deviceManager = TestDeviceManager(
        <Device>[],
        deviceDiscoveryOverrides: <DeviceDiscovery>[
452
          deviceDiscovery
453 454 455 456
        ],
        logger: BufferLogger.test(),
        terminal: Terminal.test(),
      );
457 458
      deviceManager.specifiedDeviceId = ephemeralOne.id;
      final List<Device> filtered = await deviceManager.findTargetDevices(
459
        FakeFlutterProject(),
460 461 462 463
        timeout: timeout,
      );

      expect(filtered.single, ephemeralOne);
464 465
      expect(deviceDiscovery.devicesCalled, 1);
      expect(deviceDiscovery.discoverDevicesCalled, 1);
466
    });
467
  });
468

469
  group('JSON encode devices', () {
470
    testWithoutContext('Consistency of JSON representation', () async {
471 472 473 474 475 476 477 478
      expect(
        // This tests that fakeDevices is a list of tuples where "second" is the
        // correct JSON representation of the "first". Actual values are irrelevant
        await Future.wait(fakeDevices.map((FakeDeviceJsonData d) => d.dev.toJson())),
        fakeDevices.map((FakeDeviceJsonData d) => d.json)
      );
    });
  });
479 480

  testWithoutContext('computeDartVmFlags handles various combinations of Dart VM flags and null_assertions', () {
481
    expect(computeDartVmFlags(DebuggingOptions.enabled(BuildInfo.debug)), '');
482
    expect(computeDartVmFlags(DebuggingOptions.enabled(BuildInfo.debug, dartFlags: '--foo')), '--foo');
483
    expect(computeDartVmFlags(DebuggingOptions.enabled(BuildInfo.debug, nullAssertions: true)), '--null_assertions');
484 485
    expect(computeDartVmFlags(DebuggingOptions.enabled(BuildInfo.debug, dartFlags: '--foo', nullAssertions: true)), '--foo,--null_assertions');
  });
486
}
487

488
class TestDeviceManager extends DeviceManager {
489 490
  TestDeviceManager(
    List<Device> allDevices, {
491 492 493 494 495 496 497
    List<DeviceDiscovery>? deviceDiscoveryOverrides,
    required Logger logger,
    required Terminal terminal,
    String? wellKnownId,
  }) : _fakeDeviceDiscoverer = FakePollingDeviceDiscovery(),
       _deviceDiscoverers = <DeviceDiscovery>[],
       super(logger: logger, terminal: terminal, userMessages: UserMessages()) {
498 499 500
    if (wellKnownId != null) {
      _fakeDeviceDiscoverer.wellKnownIds.add(wellKnownId);
    }
501 502 503 504
    _deviceDiscoverers.add(_fakeDeviceDiscoverer);
    if (deviceDiscoveryOverrides != null) {
      _deviceDiscoverers.addAll(deviceDiscoveryOverrides);
    }
505 506 507
    resetDevices(allDevices);
  }
  @override
508
  List<DeviceDiscovery> get deviceDiscoverers => _deviceDiscoverers;
509 510
  final List<DeviceDiscovery> _deviceDiscoverers;
  final FakePollingDeviceDiscovery _fakeDeviceDiscoverer;
511

512
  void resetDevices(List<Device> allDevices) {
513
    _fakeDeviceDiscoverer.setDevices(allDevices);
514
  }
515

516
  bool? isAlwaysSupportedOverride;
517 518

  @override
519
  bool isDeviceSupportedForProject(Device device, FlutterProject? flutterProject) {
520
    if (isAlwaysSupportedOverride != null) {
521
      return isAlwaysSupportedOverride!;
522 523 524
    }
    return super.isDeviceSupportedForProject(device, flutterProject);
  }
525 526
}

527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
class MockDeviceDiscovery extends Fake implements DeviceDiscovery {
  int devicesCalled = 0;
  int discoverDevicesCalled = 0;

  @override
  bool supportsPlatform = true;

  List<Device> deviceValues = <Device>[];

  @override
  Future<List<Device>> get devices async {
    devicesCalled += 1;
    return deviceValues;
  }

  @override
543
  Future<List<Device>> discoverDevices({Duration? timeout}) async {
544 545 546
    discoverDevicesCalled += 1;
    return deviceValues;
  }
547 548 549

  @override
  List<String> get wellKnownIds => <String>[];
550 551
}

552
class FakeFlutterProject extends Fake implements FlutterProject { }
553 554 555 556 557 558 559

class LongPollingDeviceDiscovery extends PollingDeviceDiscovery {
  LongPollingDeviceDiscovery() : super('forever');

  final Completer<List<Device>> _completer = Completer<List<Device>>();

  @override
560
  Future<List<Device>> pollingGetDevices({ Duration? timeout }) async {
561 562 563 564 565
    return _completer.future;
  }

  @override
  Future<void> stopPolling() async {
566
    _completer.complete(<Device>[]);
567 568 569 570
  }

  @override
  Future<void> dispose() async {
571
    _completer.complete(<Device>[]);
572 573 574 575 576 577 578
  }

  @override
  bool get supportsPlatform => true;

  @override
  bool get canListAnything => true;
579 580 581

  @override
  final List<String> wellKnownIds = <String>[];
582 583 584 585 586 587
}

class ThrowingPollingDeviceDiscovery extends PollingDeviceDiscovery {
  ThrowingPollingDeviceDiscovery() : super('throw');

  @override
588
  Future<List<Device>> pollingGetDevices({ Duration? timeout }) async {
589 590 591 592 593 594 595 596
    throw const ProcessException('fake-discovery', <String>[]);
  }

  @override
  bool get supportsPlatform => true;

  @override
  bool get canListAnything => true;
597 598 599

  @override
  List<String> get wellKnownIds => <String>[];
600
}
601 602 603 604 605 606 607 608 609 610 611 612 613

class FakeTerminal extends Fake implements Terminal {
  @override
  bool stdinHasTerminal = true;

  @override
  bool usesTerminalUi = true;

  void setPrompt(List<String> characters, String result) {
    _nextPrompt = characters;
    _nextResult = result;
  }

614 615
  List<String>? _nextPrompt;
  late String _nextResult;
616 617 618 619

  @override
  Future<String> promptForCharInput(
    List<String> acceptedCharacters, {
620 621 622
    Logger? logger,
    String? prompt,
    int? defaultChoiceIndex,
623 624 625 626 627 628
    bool displayAcceptedCharacters = true,
  }) async {
    expect(acceptedCharacters, _nextPrompt);
    return _nextResult;
  }
}