<commit_before>// Copyright (c) 2019, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';

import 'package:dart_services/src/common.dart';
import 'package:dart_services/src/flutter_web.dart';
import 'package:test/test.dart';

void main() => defineTests();

void defineTests() {
  group('FlutterWebManager', () {
    FlutterWebManager flutterWebManager;

    setUp(() {
      flutterWebManager = FlutterWebManager(sdkPath);
    });

    tearDown(() {
      flutterWebManager.dispose();
    });

    test('inited', () {
      expect(flutterWebManager.projectDirectory.existsSync(), isTrue);
      File file = File(flutterWebManager.packagesFilePath);
      expect(file.existsSync(), isTrue);
    });

    test('usesFlutterWeb', () {
      expect(flutterWebManager.usesFlutterWeb({''}), isFalse);
      expect(flutterWebManager.usesFlutterWeb({'dart:html'}), isFalse);
      expect(flutterWebManager.usesFlutterWeb({'package:flutter_web'}), isTrue);
      expect(
          flutterWebManager.usesFlutterWeb({'package:flutter_web/'}), isTrue);
    });

    test('getUnsupportedImport', () {
      expect(flutterWebManager.getUnsupportedImport({'dart:html'}), isNull);
      expect(flutterWebManager.getUnsupportedImport({'package:flutter_web/'}),
          isNull);
      expect(flutterWebManager.getUnsupportedImport({'package:path'}),
          equals('package:path'));
      expect(flutterWebManager.getUnsupportedImport({'foo.dart'}),
          equals('foo.dart'));
    });
  });

  group('FlutterWebManager package:flutter_web inited', () {
    FlutterWebManager flutterWebManager;

    setUpAll(() async {
      flutterWebManager = FlutterWebManager(sdkPath);
      await flutterWebManager.initFlutterWeb();
    });

    tearDownAll(() {
      flutterWebManager.dispose();
    });

    test('packagesFilePath', () {
      String packagesPath = flutterWebManager.packagesFilePath;
      expect(packagesPath, isNotEmpty);

      File file = File(packagesPath);
      List<String> lines = file.readAsLinesSync();
      expect(lines, anyElement(startsWith('flutter_web:file://')));
    });

    test('summaryFilePath', () {
      String summaryFilePath = flutterWebManager.summaryFilePath;
      expect(summaryFilePath, isNotEmpty);

      File file = File(summaryFilePath);
      expect(file.existsSync(), isTrue);
    });
    // TODO(devoncarew): Unskip as soon as the travis bots can provision
    // package:flutter_web.
  }, skip: true);
}<commit_msg>Unskip Flutter Web tests (#424)<commit_after>// Copyright (c) 2019, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';

import 'package:dart_services/src/common.dart';
import 'package:dart_services/src/flutter_web.dart';
import 'package:test/test.dart';

void main() => defineTests();

void defineTests() {
  group('FlutterWebManager', () {
    FlutterWebManager flutterWebManager;

    setUp(() {
      flutterWebManager = FlutterWebManager(sdkPath);
    });

    tearDown(() {
      flutterWebManager.dispose();
    });

    test('inited', () {
      expect(flutterWebManager.projectDirectory.existsSync(), isTrue);
      File file = File(flutterWebManager.packagesFilePath);
      expect(file.existsSync(), isTrue);
    });

    test('usesFlutterWeb', () {
      expect(flutterWebManager.usesFlutterWeb({''}), isFalse);
      expect(flutterWebManager.usesFlutterWeb({'dart:html'}), isFalse);
      expect(flutterWebManager.usesFlutterWeb({'package:flutter_web'}), isTrue);
      expect(
          flutterWebManager.usesFlutterWeb({'package:flutter_web/'}), isTrue);
    });

    test('getUnsupportedImport', () {
      expect(flutterWebManager.getUnsupportedImport({'dart:html'}), isNull);
      expect(flutterWebManager.getUnsupportedImport({'package:flutter_web/'}),
          isNull);
      expect(flutterWebManager.getUnsupportedImport({'package:path'}),
          equals('package:path'));
      expect(flutterWebManager.getUnsupportedImport({'foo.dart'}),
          equals('foo.dart'));
    });
  });

  group('FlutterWebManager package:flutter_web inited', () {
    FlutterWebManager flutterWebManager;

    setUpAll(() async {
      flutterWebManager = FlutterWebManager(sdkPath);
      await flutterWebManager.initFlutterWeb();
    });

    tearDownAll(() {
      flutterWebManager.dispose();
    });

    test('packagesFilePath', () {
      String packagesPath = flutterWebManager.packagesFilePath;
      expect(packagesPath, isNotEmpty);

      File file = File(packagesPath);
      List<String> lines = file.readAsLinesSync();
      expect(lines, anyElement(startsWith('flutter_web:file://')));
    });

    test('summaryFilePath', () {
      String summaryFilePath = flutterWebManager.summaryFilePath;
      expect(summaryFilePath, isNotEmpty);

      File file = File(summaryFilePath);
      expect(file.existsSync(), isTrue);
    });
  });
}
{'fraction_non_alphanumeric': 0.13909994155464642, 'fraction_numerical': 0.002142996298460939, 'mean_word_length': 3.9412897016361885, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6314434', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1526, 'n_words': 263}