<commit_before>// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:flutter_tools/src/test/event_printer.dart';
import 'package:flutter_tools/src/test/test_device.dart';
import 'package:mockito/mockito.dart';

import '../../src/common.dart';

void main() {
  group(EventPrinter, () {
    final Uri observatoryUri = Uri.parse('http://localhost:1234');
    EventPrinter eventPrinter;
    StringBuffer output;

    setUp(() {
      output = StringBuffer();
      eventPrinter = EventPrinter(out: output);
    });

    testWithoutContext('handles a null parent', () {
      final _Device device = _Device();

      expect(() => eventPrinter.handleFinishedTest(device), returnsNormally);
      expect(() => eventPrinter.handleStartedDevice(observatoryUri), returnsNormally);
      expect(() => eventPrinter.handleTestCrashed(device), returnsNormally);
      expect(() => eventPrinter.handleTestTimedOut(device), returnsNormally);
    });

    group('handleStartedDevice', () {
      testWithoutContext('with non-null observatory', () {
        eventPrinter.handleStartedDevice(observatoryUri);

        expect(
          output.toString(),
          '\n'
          '[{"event":"test.startedProcess","params":{"observatoryUri":"http://localhost:1234"}}]'
          '\n',
        );
      });

      testWithoutContext('with null observatory', () {
        eventPrinter.handleStartedDevice(null);

        expect(
          output.toString(),
          '\n'
          '[{"event":"test.startedProcess","params":{"observatoryUri":null}}]'
          '\n',
        );
      });
    });
  });
}

class _Device extends Mock implements TestDevice {}<commit_msg>Remove mock from event_printer_test (#77757)<commit_after>// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.8

import 'package:flutter_tools/src/test/event_printer.dart';
import 'package:flutter_tools/src/test/test_device.dart';
import 'package:test/fake.dart';

import '../../src/common.dart';

void main() {
  group(EventPrinter, () {
    final Uri observatoryUri = Uri.parse('http://localhost:1234');
    EventPrinter eventPrinter;
    StringBuffer output;

    setUp(() {
      output = StringBuffer();
      eventPrinter = EventPrinter(out: output);
    });

    testWithoutContext('handles a null parent', () {
      final FakeDevice device = FakeDevice();

      expect(() => eventPrinter.handleFinishedTest(device), returnsNormally);
      expect(() => eventPrinter.handleStartedDevice(observatoryUri), returnsNormally);
      expect(() => eventPrinter.handleTestCrashed(device), returnsNormally);
      expect(() => eventPrinter.handleTestTimedOut(device), returnsNormally);
    });

    group('handleStartedDevice', () {
      testWithoutContext('with non-null observatory', () {
        eventPrinter.handleStartedDevice(observatoryUri);

        expect(
          output.toString(),
          '\n'
          '[{"event":"test.startedProcess","params":{"observatoryUri":"http://localhost:1234"}}]'
          '\n',
        );
      });

      testWithoutContext('with null observatory', () {
        eventPrinter.handleStartedDevice(null);

        expect(
          output.toString(),
          '\n'
          '[{"event":"test.startedProcess","params":{"observatoryUri":null}}]'
          '\n',
        );
      });
    });
  });
}

class FakeDevice extends Fake implements TestDevice {}
{'fraction_non_alphanumeric': 0.14858882125069175, 'fraction_numerical': 0.009131156613171001, 'mean_word_length': 3.179190751445087, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5452885', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1015, 'n_words': 204}