Basic framework

This commit is contained in:
2025-09-23 19:12:34 +00:00
parent 321f449433
commit e193efcd76
27 changed files with 1958 additions and 94 deletions

View File

@@ -0,0 +1,54 @@
import 'dart:io' show Platform;
import 'package:flutter_test/flutter_test.dart';
import 'package:fluttery/src/system/environment/environment_impl.dart';
import 'package:package_info_plus/package_info_plus.dart';
void main() {
setUp(() {
PackageInfo.setMockInitialValues(
appName: 'Test App',
packageName: 'com.example.testapp',
version: '1.2.3',
buildNumber: '42',
buildSignature: 'mock-signature',
installerStore: 'mock-store',
);
});
group('EnvironmentImpl', () {
test('defaults before loadPackageInfo()', () {
final env = EnvironmentImpl();
expect(env.appName, equals('Unknown'));
expect(env.packageName, equals('Unknown'));
expect(env.version, equals('0.0.0'));
expect(env.buildNumber, equals('0'));
});
test('loadPackageInfo() populates fields from PackageInfo', () async {
final env = EnvironmentImpl();
await env.loadPackageInfo();
expect(env.appName, equals('Test App'));
expect(env.packageName, equals('com.example.testapp'));
expect(env.version, equals('1.2.3'));
expect(env.buildNumber, equals('42'));
});
test('platform flags mirror dart:io Platform', () {
final env = EnvironmentImpl();
expect(env.isAndroid, equals(Platform.isAndroid));
expect(env.isIOS, equals(Platform.isIOS));
});
test('build mode flags reflect Flutter constants', () {
final env = EnvironmentImpl();
// In unit tests, this should typically be: debug=true, release/profile=false.
expect(env.isDebug, isTrue);
expect(env.isRelease, isFalse);
expect(env.isProfile, isFalse);
});
});
}