anchor.diff:            ],
           );
           await completer.future;
  -        verifyNever(portForwarder.forward(devicePort));
  +        expect(portForwarder.devicePort, null);
  +        expect(portForwarder.hostPort, 42);
   
           await expectLoggerInterruptEndsTask(task, logger);
           await loggerSubscription.cancel();
  
positive.code:       });
  
        testUsingContext('finds observatory port and forwards', () async {
          when(device.getLogReader(includePastLogs: anyNamed('includePastLogs')))
            .thenAnswer((_) {
              // Now that the reader is used, start writing messages to it.
              fakeLogReader.addLine('Foo');
              fakeLogReader.addLine('Observatory listening on http://127.0.0.1:$devicePort');
              return fakeLogReader;
            });
          testDeviceManager.addDevice(device);
          final Completer<void> completer = Completer<void>();
          final StreamSubscription<String> loggerSubscription = logger.stream.listen((String message) {
  
negative.code:     });
  
      testUsingContext('Catches service disappeared error', () async {
        final FakeAndroidDevice device = FakeAndroidDevice(id: '1')
          ..portForwarder = const NoOpDevicePortForwarder()
          ..onGetLogReader = () => NoOpDeviceLogReader('test');
        final FakeHotRunner hotRunner = FakeHotRunner();
        final FakeHotRunnerFactory hotRunnerFactory = FakeHotRunnerFactory()
          ..hotRunner = hotRunner;
        hotRunner.onAttach = (
          Completer<DebugConnectionInfo> connectionInfoCompleter,
          Completer<void> appStartedCompleter,
          bool allowExistingDdsInstance,
          bool enableDevTools,
        ) async {
          await null;
          throw vm_service.RPCError('flutter._listViews', RPCErrorCodes.kServiceDisappeared, '');
        };
  
        testDeviceManager.addDevice(device);
        testFileSystem.file('lib/main.dart').createSync();
  
        final AttachCommand command = AttachCommand(hotRunnerFactory: hotRunnerFactory);
        await expectLater(createTestCommandRunner(command).run(<String>[
          'attach',
        ]), throwsToolExit(message: 'Lost connection to device.'));
  