2017-09-26 12:48:52 +00:00
|
|
|
// Copyright 2017 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2018-05-30 14:51:25 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2018-05-21 00:52:33 +00:00
|
|
|
import 'package:file/file.dart';
|
|
|
|
import 'package:file/memory.dart';
|
|
|
|
import 'package:flutter_tools/src/base/file_system.dart';
|
2017-09-26 12:48:52 +00:00
|
|
|
import 'package:flutter_tools/src/cache.dart';
|
|
|
|
import 'package:flutter_tools/src/flutter_manifest.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
|
|
|
import 'src/common.dart';
|
|
|
|
import 'src/context.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
setUpAll(() {
|
|
|
|
Cache.flutterRoot = getFlutterRoot();
|
|
|
|
});
|
|
|
|
|
|
|
|
group('FlutterManifest', () {
|
2017-09-26 21:14:20 +00:00
|
|
|
testUsingContext('is empty when the pubspec.yaml file is empty', () async {
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString('');
|
|
|
|
expect(flutterManifest.isEmpty, true);
|
|
|
|
expect(flutterManifest.appName, '');
|
|
|
|
expect(flutterManifest.usesMaterialDesign, false);
|
|
|
|
expect(flutterManifest.fontsDescriptor, isEmpty);
|
|
|
|
expect(flutterManifest.fonts, isEmpty);
|
|
|
|
expect(flutterManifest.assets, isEmpty);
|
|
|
|
});
|
|
|
|
|
2017-09-26 12:48:52 +00:00
|
|
|
test('has no fonts or assets when the "flutter" section is empty', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
expect(flutterManifest, isNotNull);
|
2017-09-26 21:14:20 +00:00
|
|
|
expect(flutterManifest.isEmpty, false);
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(flutterManifest.appName, 'test');
|
|
|
|
expect(flutterManifest.usesMaterialDesign, false);
|
|
|
|
expect(flutterManifest.fontsDescriptor, isEmpty);
|
|
|
|
expect(flutterManifest.fonts, isEmpty);
|
|
|
|
expect(flutterManifest.assets, isEmpty);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('knows if material design is used', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
uses-material-design: true
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
expect(flutterManifest.usesMaterialDesign, true);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('has two assets', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
uses-material-design: true
|
|
|
|
assets:
|
|
|
|
- a/foo
|
|
|
|
- a/bar
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(flutterManifest.assets.length, 2);
|
|
|
|
expect(flutterManifest.assets[0], Uri.parse('a/foo'));
|
|
|
|
expect(flutterManifest.assets[1], Uri.parse('a/bar'));
|
2017-09-26 12:48:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('has one font family with one asset', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
uses-material-design: true
|
|
|
|
fonts:
|
|
|
|
- family: foo
|
|
|
|
fonts:
|
|
|
|
- asset: a/bar
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
|
|
|
|
expect(flutterManifest.fontsDescriptor.toString(), '[{fonts: [{asset: a/bar}], family: foo}]');
|
|
|
|
final List<Font> fonts = flutterManifest.fonts;
|
|
|
|
expect(fonts.length, 1);
|
|
|
|
final Font font = fonts[0];
|
2018-02-01 06:51:26 +00:00
|
|
|
const String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}]}';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(font.descriptor.toString(), fontDescriptor);
|
|
|
|
expect(font.familyName, 'foo');
|
|
|
|
final List<FontAsset> assets = font.fontAssets;
|
|
|
|
expect(assets.length, 1);
|
|
|
|
final FontAsset fontAsset = assets[0];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fontAsset.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fontAsset.weight, isNull);
|
|
|
|
expect(fontAsset.style, isNull);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('has one font family with a simple asset and one with weight', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
uses-material-design: true
|
|
|
|
fonts:
|
|
|
|
- family: foo
|
|
|
|
fonts:
|
|
|
|
- asset: a/bar
|
|
|
|
- asset: a/bar
|
|
|
|
weight: 400
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
|
2018-02-01 06:51:26 +00:00
|
|
|
const String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}], family: foo}]';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor);
|
|
|
|
final List<Font> fonts = flutterManifest.fonts;
|
|
|
|
expect(fonts.length, 1);
|
|
|
|
final Font font = fonts[0];
|
2018-02-01 06:51:26 +00:00
|
|
|
const String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, asset: a/bar}]}';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(font.descriptor.toString(), fontDescriptor);
|
|
|
|
expect(font.familyName, 'foo');
|
|
|
|
final List<FontAsset> assets = font.fontAssets;
|
|
|
|
expect(assets.length, 2);
|
|
|
|
final FontAsset fontAsset0 = assets[0];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fontAsset0.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fontAsset0.weight, isNull);
|
|
|
|
expect(fontAsset0.style, isNull);
|
|
|
|
final FontAsset fontAsset1 = assets[1];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fontAsset1.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fontAsset1.weight, 400);
|
|
|
|
expect(fontAsset1.style, isNull);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('has one font family with a simple asset and one with weight and style', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
uses-material-design: true
|
|
|
|
fonts:
|
|
|
|
- family: foo
|
|
|
|
fonts:
|
|
|
|
- asset: a/bar
|
|
|
|
- asset: a/bar
|
|
|
|
weight: 400
|
|
|
|
style: italic
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
|
2018-02-01 06:51:26 +00:00
|
|
|
const String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {style: italic, weight: 400, asset: a/bar}], family: foo}]';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor);
|
|
|
|
final List<Font> fonts = flutterManifest.fonts;
|
|
|
|
expect(fonts.length, 1);
|
|
|
|
final Font font = fonts[0];
|
2018-02-01 06:51:26 +00:00
|
|
|
const String fontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(font.descriptor.toString(), fontDescriptor);
|
|
|
|
expect(font.familyName, 'foo');
|
|
|
|
final List<FontAsset> assets = font.fontAssets;
|
|
|
|
expect(assets.length, 2);
|
|
|
|
final FontAsset fontAsset0 = assets[0];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fontAsset0.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fontAsset0.weight, isNull);
|
|
|
|
expect(fontAsset0.style, isNull);
|
|
|
|
final FontAsset fontAsset1 = assets[1];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fontAsset1.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fontAsset1.weight, 400);
|
|
|
|
expect(fontAsset1.style, 'italic');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('has two font families, each with one simple asset and one with weight and style', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
uses-material-design: true
|
|
|
|
fonts:
|
|
|
|
- family: foo
|
|
|
|
fonts:
|
|
|
|
- asset: a/bar
|
|
|
|
- asset: a/bar
|
|
|
|
weight: 400
|
|
|
|
style: italic
|
|
|
|
- family: bar
|
|
|
|
fonts:
|
|
|
|
- asset: a/baz
|
|
|
|
- weight: 400
|
|
|
|
asset: a/baz
|
|
|
|
style: italic
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
|
2018-03-14 05:24:49 +00:00
|
|
|
const String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {style: italic, weight: 400, asset: a/bar}], family: foo},'
|
2017-09-26 12:48:52 +00:00
|
|
|
' {fonts: [{asset: a/baz}, {style: italic, weight: 400, asset: a/baz}], family: bar}]';
|
|
|
|
expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor);
|
|
|
|
final List<Font> fonts = flutterManifest.fonts;
|
|
|
|
expect(fonts.length, 2);
|
|
|
|
|
|
|
|
final Font fooFont = fonts[0];
|
2018-02-01 06:51:26 +00:00
|
|
|
const String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fooFont.descriptor.toString(), barFontDescriptor);
|
|
|
|
expect(fooFont.familyName, 'foo');
|
|
|
|
final List<FontAsset> fooAassets = fooFont.fontAssets;
|
|
|
|
expect(fooAassets.length, 2);
|
|
|
|
final FontAsset fooFontAsset0 = fooAassets[0];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fooFontAsset0.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fooFontAsset0.weight, isNull);
|
|
|
|
expect(fooFontAsset0.style, isNull);
|
|
|
|
final FontAsset fooFontAsset1 = fooAassets[1];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fooFontAsset1.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fooFontAsset1.weight, 400);
|
|
|
|
expect(fooFontAsset1.style, 'italic');
|
|
|
|
|
|
|
|
final Font barFont = fonts[1];
|
2018-02-01 06:51:26 +00:00
|
|
|
const String fontDescriptor = '{family: bar, fonts: [{asset: a/baz}, {weight: 400, style: italic, asset: a/baz}]}';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(barFont.descriptor.toString(), fontDescriptor);
|
|
|
|
expect(barFont.familyName, 'bar');
|
|
|
|
final List<FontAsset> barAssets = barFont.fontAssets;
|
|
|
|
expect(barAssets.length, 2);
|
|
|
|
final FontAsset barFontAsset0 = barAssets[0];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(barFontAsset0.assetUri.path, 'a/baz');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(barFontAsset0.weight, isNull);
|
|
|
|
expect(barFontAsset0.style, isNull);
|
|
|
|
final FontAsset barFontAsset1 = barAssets[1];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(barFontAsset1.assetUri.path, 'a/baz');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(barFontAsset1.weight, 400);
|
|
|
|
expect(barFontAsset1.style, 'italic');
|
|
|
|
});
|
|
|
|
|
2018-03-07 05:36:03 +00:00
|
|
|
testUsingContext('has only one of two font families when one declaration is missing the "family" option', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
uses-material-design: true
|
|
|
|
fonts:
|
|
|
|
- family: foo
|
|
|
|
fonts:
|
|
|
|
- asset: a/bar
|
|
|
|
- asset: a/bar
|
|
|
|
weight: 400
|
|
|
|
style: italic
|
|
|
|
- fonts:
|
|
|
|
- asset: a/baz
|
|
|
|
- asset: a/baz
|
|
|
|
weight: 400
|
|
|
|
style: italic
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
|
|
|
|
|
2018-03-14 05:24:49 +00:00
|
|
|
const String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {style: italic, weight: 400, asset: a/bar}], family: foo},'
|
2017-09-26 12:48:52 +00:00
|
|
|
' {fonts: [{asset: a/baz}, {style: italic, weight: 400, asset: a/baz}]}]';
|
|
|
|
expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor);
|
|
|
|
final List<Font> fonts = flutterManifest.fonts;
|
|
|
|
expect(fonts.length, 1);
|
|
|
|
final Font fooFont = fonts[0];
|
2018-02-01 06:51:26 +00:00
|
|
|
const String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fooFont.descriptor.toString(), barFontDescriptor);
|
|
|
|
expect(fooFont.familyName, 'foo');
|
|
|
|
final List<FontAsset> fooAassets = fooFont.fontAssets;
|
|
|
|
expect(fooAassets.length, 2);
|
|
|
|
final FontAsset fooFontAsset0 = fooAassets[0];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fooFontAsset0.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fooFontAsset0.weight, isNull);
|
|
|
|
expect(fooFontAsset0.style, isNull);
|
|
|
|
final FontAsset fooFontAsset1 = fooAassets[1];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fooFontAsset1.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fooFontAsset1.weight, 400);
|
|
|
|
expect(fooFontAsset1.style, 'italic');
|
|
|
|
});
|
|
|
|
|
2018-03-07 05:36:03 +00:00
|
|
|
testUsingContext('has only one of two font families when one declaration is missing the "fonts" option', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
uses-material-design: true
|
|
|
|
fonts:
|
|
|
|
- family: foo
|
|
|
|
fonts:
|
|
|
|
- asset: a/bar
|
|
|
|
- asset: a/bar
|
|
|
|
weight: 400
|
|
|
|
style: italic
|
|
|
|
- family: bar
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
|
2018-03-14 05:24:49 +00:00
|
|
|
const String expectedFontsDescriptor = '[{fonts: [{asset: a/bar}, {style: italic, weight: 400, asset: a/bar}], family: foo},'
|
2017-09-26 12:48:52 +00:00
|
|
|
' {family: bar}]';
|
|
|
|
expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor);
|
|
|
|
final List<Font> fonts = flutterManifest.fonts;
|
|
|
|
expect(fonts.length, 1);
|
|
|
|
final Font fooFont = fonts[0];
|
2018-02-01 06:51:26 +00:00
|
|
|
const String barFontDescriptor = '{family: foo, fonts: [{asset: a/bar}, {weight: 400, style: italic, asset: a/bar}]}';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fooFont.descriptor.toString(), barFontDescriptor);
|
|
|
|
expect(fooFont.familyName, 'foo');
|
|
|
|
final List<FontAsset> fooAassets = fooFont.fontAssets;
|
|
|
|
expect(fooAassets.length, 2);
|
|
|
|
final FontAsset fooFontAsset0 = fooAassets[0];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fooFontAsset0.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fooFontAsset0.weight, isNull);
|
|
|
|
expect(fooFontAsset0.style, isNull);
|
|
|
|
final FontAsset fooFontAsset1 = fooAassets[1];
|
2018-01-24 21:16:23 +00:00
|
|
|
expect(fooFontAsset1.assetUri.path, 'a/bar');
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(fooFontAsset1.weight, 400);
|
|
|
|
expect(fooFontAsset1.style, 'italic');
|
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContext('has no font family when declaration is missing the "asset" option', () async {
|
2018-02-01 06:51:26 +00:00
|
|
|
const String manifest = '''
|
2017-09-26 12:48:52 +00:00
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
uses-material-design: true
|
|
|
|
fonts:
|
|
|
|
- family: foo
|
|
|
|
fonts:
|
|
|
|
- weight: 400
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
|
2018-02-01 06:51:26 +00:00
|
|
|
const String expectedFontsDescriptor = '[{fonts: [{weight: 400}], family: foo}]';
|
2017-09-26 12:48:52 +00:00
|
|
|
expect(flutterManifest.fontsDescriptor.toString(), expectedFontsDescriptor);
|
|
|
|
final List<Font> fonts = flutterManifest.fonts;
|
|
|
|
expect(fonts.length, 0);
|
|
|
|
});
|
2018-03-19 21:55:54 +00:00
|
|
|
|
|
|
|
test('allows a blank flutter section', () async {
|
|
|
|
const String manifest = '''
|
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
''';
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
expect(flutterManifest.isEmpty, false);
|
|
|
|
});
|
2018-05-30 14:51:25 +00:00
|
|
|
|
|
|
|
Future<void> checkManifestVersion({
|
|
|
|
String manifest,
|
|
|
|
String expectedAppVersion,
|
|
|
|
String expectedBuildName,
|
|
|
|
int expectedBuildNumber,
|
|
|
|
}) async {
|
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
|
|
|
expect(flutterManifest.appVersion, expectedAppVersion);
|
|
|
|
expect(flutterManifest.buildName, expectedBuildName);
|
|
|
|
expect(flutterManifest.buildNumber, expectedBuildNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
test('parses major.minor.patch+build version clause', () async {
|
|
|
|
const String manifest = '''
|
|
|
|
name: test
|
|
|
|
version: 1.0.0+2
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
''';
|
|
|
|
await checkManifestVersion(
|
|
|
|
manifest: manifest,
|
|
|
|
expectedAppVersion: '1.0.0+2',
|
|
|
|
expectedBuildName: '1.0.0',
|
|
|
|
expectedBuildNumber: 2,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('parses major.minor+build version clause', () async {
|
|
|
|
const String manifest = '''
|
|
|
|
name: test
|
|
|
|
version: 1.0+2
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
''';
|
|
|
|
await checkManifestVersion(
|
|
|
|
manifest: manifest,
|
|
|
|
expectedAppVersion: '1.0+2',
|
|
|
|
expectedBuildName: '1.0',
|
|
|
|
expectedBuildNumber: 2,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('parses major+build version clause', () async {
|
|
|
|
const String manifest = '''
|
|
|
|
name: test
|
|
|
|
version: 1+2
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
''';
|
|
|
|
await checkManifestVersion(
|
|
|
|
manifest: manifest,
|
|
|
|
expectedAppVersion: '1+2',
|
|
|
|
expectedBuildName: '1',
|
|
|
|
expectedBuildNumber: 2,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('parses major version clause', () async {
|
|
|
|
const String manifest = '''
|
|
|
|
name: test
|
|
|
|
version: 1
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
''';
|
|
|
|
await checkManifestVersion(
|
|
|
|
manifest: manifest,
|
|
|
|
expectedAppVersion: '1',
|
|
|
|
expectedBuildName: '1',
|
|
|
|
expectedBuildNumber: null,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('parses empty version clause', () async {
|
|
|
|
const String manifest = '''
|
|
|
|
name: test
|
|
|
|
version:
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
''';
|
|
|
|
await checkManifestVersion(
|
|
|
|
manifest: manifest,
|
|
|
|
expectedAppVersion: null,
|
|
|
|
expectedBuildName: null,
|
|
|
|
expectedBuildNumber: null,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
test('parses no version clause', () async {
|
|
|
|
const String manifest = '''
|
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
''';
|
|
|
|
await checkManifestVersion(
|
|
|
|
manifest: manifest,
|
|
|
|
expectedAppVersion: null,
|
|
|
|
expectedBuildName: null,
|
|
|
|
expectedBuildNumber: null,
|
|
|
|
);
|
|
|
|
});
|
2017-09-26 12:48:52 +00:00
|
|
|
});
|
2018-05-21 00:52:33 +00:00
|
|
|
|
|
|
|
group('FlutterManifest with MemoryFileSystem', () {
|
|
|
|
void assertSchemaIsReadable() async {
|
|
|
|
const String manifest = '''
|
|
|
|
name: test
|
|
|
|
dependencies:
|
|
|
|
flutter:
|
|
|
|
sdk: flutter
|
|
|
|
flutter:
|
|
|
|
''';
|
|
|
|
|
2018-05-30 14:51:25 +00:00
|
|
|
final FlutterManifest flutterManifest = await FlutterManifest.createFromString(manifest);
|
2018-05-21 00:52:33 +00:00
|
|
|
expect(flutterManifest.isEmpty, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeSchemaFile(FileSystem filesystem, String schemaData) {
|
|
|
|
final String schemaPath = buildSchemaPath(filesystem);
|
|
|
|
final File schemaFile = filesystem.file(schemaPath);
|
|
|
|
|
|
|
|
final String schemaDir = buildSchemaDir(filesystem);
|
|
|
|
|
|
|
|
filesystem.directory(schemaDir).createSync(recursive: true);
|
|
|
|
filesystem.file(schemaFile).writeAsStringSync(schemaData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void testUsingContextAndFs(String description, FileSystem filesystem,
|
|
|
|
dynamic testMethod()) {
|
|
|
|
const String schemaData = '{}';
|
|
|
|
|
|
|
|
testUsingContext(description,
|
|
|
|
() async {
|
|
|
|
writeSchemaFile( filesystem, schemaData);
|
|
|
|
testMethod();
|
|
|
|
},
|
|
|
|
overrides: <Type, Generator>{
|
|
|
|
FileSystem: () => filesystem,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
testUsingContext('Validate manifest on original fs', () async {
|
|
|
|
assertSchemaIsReadable();
|
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContextAndFs('Validate manifest on Posix FS',
|
|
|
|
new MemoryFileSystem(style: FileSystemStyle.posix), () async {
|
|
|
|
assertSchemaIsReadable();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
testUsingContextAndFs('Validate manifest on Windows FS',
|
|
|
|
new MemoryFileSystem(style: FileSystemStyle.windows), () async {
|
|
|
|
assertSchemaIsReadable();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-09-26 12:48:52 +00:00
|
|
|
}
|
2018-05-21 00:52:33 +00:00
|
|
|
|