42 lines
1.6 KiB
Dart
42 lines
1.6 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/application/app.dart';
|
|
import 'package:pipelines_app/ui/adaptive/platform.dart';
|
|
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
|
|
|
void main() {
|
|
test('web uses Material on every host; native Apple uses Cupertino', () {
|
|
for (final platform in TargetPlatform.values) {
|
|
expect(prefersCupertino(web: true, platform: platform), isFalse);
|
|
expect(
|
|
prefersCupertino(web: false, platform: platform),
|
|
platform == TargetPlatform.iOS || platform == TargetPlatform.macOS,
|
|
);
|
|
}
|
|
});
|
|
|
|
for (final platform in [TargetPlatform.macOS, TargetPlatform.iOS]) {
|
|
testWidgets('app and themes select the right controls on $platform', (
|
|
tester,
|
|
) async {
|
|
debugDefaultTargetPlatformOverride = platform;
|
|
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
|
await tester.pumpWidget(const MyApp());
|
|
if (kIsWeb) {
|
|
expect(find.byType(MaterialApp), findsOneWidget);
|
|
expect(find.byType(CupertinoApp), findsNothing);
|
|
expect(appLightTheme().platform, TargetPlatform.android);
|
|
expect(appDarkTheme().platform, TargetPlatform.android);
|
|
} else {
|
|
expect(find.byType(CupertinoApp), findsOneWidget);
|
|
expect(appLightTheme().platform, platform);
|
|
expect(appDarkTheme().platform, platform);
|
|
}
|
|
await tester.pumpWidget(const SizedBox.shrink());
|
|
debugDefaultTargetPlatformOverride = null;
|
|
});
|
|
}
|
|
}
|