Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test-flutter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
name: multi_packages_app_app
- dir: example/multi_packages_app/theme
name: multi_packages_app_theme
- dir: .
name: adaptive_test
defaults:
run:
working-directory: ${{ matrix.dir }}
Expand Down
12 changes: 6 additions & 6 deletions lib/adaptive_test.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export 'src/adaptive/adaptive_test.dart';
export 'src/adaptive/devices_data.dart';
export 'src/adaptive/widgets/adaptive_wrapper.dart';
export 'src/adaptive/window_configuration_tester.dart';
export 'src/adaptive/window_config.dart';
export 'src/adaptive/window_config_data/dynamic_island_data.dart';
export 'src/adaptive/window_config_data/punch_hole_data.dart';
export 'src/adaptive/window_config_data/system_nav_bar_data.dart'
show SystemNavBarData;
export 'src/adaptive/window_config_data/window_config_data.dart';
export 'src/adaptive/window_configuration_tester.dart';
export 'src/configuration.dart';
export 'src/helpers/await_images.dart';
export 'src/helpers/fonts_loader.dart';
export 'src/helpers/goldens_difference.dart';
export 'src/helpers/skip_test_extension.dart';
export 'src/adaptive/window_config_data/window_config_data.dart';
export 'src/adaptive/window_config_data/system_nav_bar_data.dart'
show SystemNavBarData;
export 'src/adaptive/window_config_data/punch_hole_data.dart';
export 'src/adaptive/window_config_data/dynamic_island_data.dart';
2 changes: 2 additions & 0 deletions lib/src/adaptive/devices_data.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: constant_identifier_names

import 'package:adaptive_test/src/adaptive/window_config_data/dynamic_island_data.dart';
import 'package:adaptive_test/src/adaptive/window_config_data/punch_hole_data.dart';
import 'package:adaptive_test/src/adaptive/window_config_data/system_nav_bar_data.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/adaptive/widgets/adaptive_wrapper.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:adaptive_test/src/adaptive/widgets/layers/hardware_layer.dart';
import 'package:adaptive_test/src/adaptive/widgets/layers/keyboard_layer.dart';
import 'package:adaptive_test/src/adaptive/widgets/layers/system_nav_bar_layer.dart';
import 'package:adaptive_test/src/adaptive/window_config_data/window_config_data.dart';
import 'package:adaptive_test/src/adaptive/window_config.dart';
import 'package:adaptive_test/src/adaptive/window_config_data/window_config_data.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
2 changes: 1 addition & 1 deletion lib/src/adaptive/widgets/layers/keyboard_layer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:adaptive_test/src/adaptive/window_configuration_tester.dart';
import 'package:adaptive_test/src/adaptive/window_config.dart';
import 'package:adaptive_test/src/adaptive/window_configuration_tester.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ThreeButtonSystemNavBarLayer extends StatelessWidget {
children: const [
Icons.arrow_back_ios_rounded,
Icons.circle,
Icons.square_rounded
Icons.square_rounded,
]
.map(
(iconData) => Icon(
Expand Down
3 changes: 2 additions & 1 deletion lib/src/adaptive/window_config_data/window_config_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class WindowConfigData extends Equatable {
/// This is null when the device has no notch.
final Size? notchSize;

/// Describe the size of the device physical screen top dynamic island in `dp`.
/// Describe the size of the device physical screen top dynamic island in
/// `dp`.
///
/// This is null when the device has no dynamic island.
final DynamicIslandData? dynamicIsland;
Expand Down
6 changes: 4 additions & 2 deletions lib/src/adaptive/window_configuration_tester.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ extension WidgetTesterWithConfigurableWindow on WidgetTester {
addTearDown(view.resetViewInsets);
}

/// Configure the tester window to represent an opened keyboard on the given device variant.
/// Configure the tester window to represent an opened keyboard on the given
/// device variant.
void configureOpenedKeyboardWindow(WindowConfigData windowConfig) {
view.viewInsets = windowConfig.viewInsets;
view.padding = windowConfig.padding.copyWith(bottom: 0);
}

/// Configure the tester window to represent a closed keyboard on the given device variant.
/// Configure the tester window to represent a closed keyboard on the given
/// device variant.
void configureClosedKeyboardWindow(WindowConfigData windowConfig) {
view.resetViewInsets();
view.padding = windowConfig.padding;
Expand Down
5 changes: 4 additions & 1 deletion lib/src/configuration.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: use_setters_to_change_properties

import 'package:adaptive_test/src/adaptive/window_config.dart';
import 'package:adaptive_test/src/adaptive/window_config_data/window_config_data.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -65,7 +67,8 @@ See: https://api.flutter.dev/flutter/flutter_test/flutter_test-library.html

/// Set the devices variant on which you want your test to run.
///
/// Eg [iPhone8], [iPhone13], [iPhone16],[iPhone16Dark], [iPadPro], [desktop], [pixel5], [pixel9].
/// Eg [iPhone8], [iPhone13], [iPhone16],[iPhone16Dark], [iPadPro],
/// [desktop], [pixel5], [pixel9].
void setDeviceVariants(Set<WindowConfigData> deviceConfigs) {
_deviceVariant = WindowVariant(deviceConfigs);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/helpers/fonts_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ Future<void> _loadFontsFromManifest(

FontLoader _createFontLoader(String fontFamily, List<_FontType> fontTypes) {
final fontLoader = FontLoader(fontFamily);
fontTypes.forEach(
(fontType) => fontLoader.addFont(rootBundle.load(fontType.asset)),
);
for (final fontType in fontTypes) {
fontLoader.addFont(rootBundle.load(fontType.asset));
}

return fontLoader;
}
Expand Down
5 changes: 4 additions & 1 deletion lib/src/helpers/goldens_difference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ void setupFileComparatorWithThreshold([
/// exceeded, marks the test as a failure.
class LocalFileComparatorWithThreshold extends LocalFileComparator {
LocalFileComparatorWithThreshold(super.testFile, this.threshold)
: assert(threshold >= 0 && threshold <= 1);
: assert(
threshold >= 0 && threshold <= 1,
'The threshold must be between 0 and 1 inclusive',
);

/// Threshold above which tests will be marked as failing.
/// Ranges from 0 to 1, both inclusive.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/helpers/skip_test_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ extension ShouldSkipAdaptiveTest on AdaptiveTestConfiguration {
/// runtime platform does not match the enforced platform, the test will be
/// skipped if [AdaptiveTestConfiguration.failTestOnWrongPlatform] is false.
///
/// This extension is used to determine if a test should be skipped based on the
/// [AdaptiveTestConfiguration.enforcedTestPlatform] and
/// This extension is used to determine if a test should be skipped based on
/// the [AdaptiveTestConfiguration.enforcedTestPlatform] and
/// [AdaptiveTestConfiguration.failTestOnWrongPlatform] values.
bool get shouldSkipTest {
final configuration = AdaptiveTestConfiguration.instance;
Expand Down
5 changes: 3 additions & 2 deletions lib/src/helpers/target_platform_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:developer';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:meta/meta.dart';

@internal
extension IsRuntimePlatform on TargetPlatform {
Expand All @@ -13,7 +12,9 @@ extension IsRuntimePlatform on TargetPlatform {
TargetPlatform.windows:
return;

default:
case TargetPlatform.android ||
TargetPlatform.iOS ||
TargetPlatform.fuchsia:
log('Tests are intended to be runned on linux, macOS or windows'
' platform. But you are running them on $name');
}
Expand Down
Loading