Skip to content

Commit

Permalink
Add integration test (#275)
Browse files Browse the repository at this point in the history
* Add integration test

* CI: run integration test

* Rename integration tests

It's better to test setters in separate test methods to make it possible
to skip them per platform depending on how we are able to make them work
on each platform or not.
  • Loading branch information
jpnurmi committed Jan 6, 2023
1 parent b705925 commit cd6dacf
Show file tree
Hide file tree
Showing 4 changed files with 190 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ jobs:
- uses: subosito/flutter-action@v2
- run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev libappindicator3-dev
sudo apt-get install -y ninja-build libgtk-3-dev libappindicator3-dev xvfb
- run: flutter config --enable-linux-desktop
- run: cd example && flutter build linux -v
- run: cd example && xvfb-run -a flutter test integration_test -v
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
- run: flutter config --enable-macos-desktop
- run: cd example && flutter build macos -v
- run: cd example && flutter test integration_test -v
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
- run: cd example && flutter build windows -v
- run: cd example && flutter test integration_test -v
106 changes: 106 additions & 0 deletions example/integration_test/window_manager_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import 'dart:io';
import 'dart:ui';

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:window_manager/window_manager.dart';

Future<void> main() async {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
await windowManager.ensureInitialized();
await windowManager.waitUntilReadyToShow(
WindowOptions(
size: Size(640, 480),
title: 'window_manager_test',
),
() async {
await windowManager.show();
await windowManager.focus();
},
);

testWidgets('getBounds', (tester) async {
expect(await windowManager.getBounds(),
isA<Rect>().having((r) => r.size, 'size', Size(640, 480)));
});

testWidgets('isAlwaysOnBottom', (tester) async {
expect(await windowManager.isAlwaysOnBottom(), isFalse);
}, skip: Platform.isMacOS || Platform.isWindows);

testWidgets('isAlwaysOnTop', (tester) async {
expect(await windowManager.isAlwaysOnTop(), isFalse);
});

testWidgets('isClosable', (tester) async {
expect(await windowManager.isClosable(), isTrue);
});

testWidgets('isFocused', (tester) async {
expect(await windowManager.isFocused(), isTrue);
});

testWidgets('isFullScreen', (tester) async {
expect(await windowManager.isFullScreen(), isFalse);
});

testWidgets('hasShadow', (tester) async {
expect(await windowManager.hasShadow(), isTrue);
}, skip: Platform.isLinux);

testWidgets('isMaximizable', (tester) async {
expect(await windowManager.isMaximizable(), isTrue);
}, skip: Platform.isMacOS);

testWidgets('isMaximized', (tester) async {
expect(await windowManager.isMaximized(), isFalse);
});

testWidgets('isMinimizable', (tester) async {
expect(await windowManager.isMinimizable(), isTrue);
}, skip: Platform.isMacOS);

testWidgets('isMinimized', (tester) async {
expect(await windowManager.isMinimized(), isFalse);
});

testWidgets('isMovable', (tester) async {
expect(await windowManager.isMovable(), isTrue);
}, skip: Platform.isLinux || Platform.isWindows);

testWidgets('getOpacity', (tester) async {
expect(await windowManager.getOpacity(), 1.0);
});

testWidgets('getPosition', (tester) async {
expect(await windowManager.getPosition(), isA<Offset>());
});

testWidgets('isPreventClose', (tester) async {
expect(await windowManager.isPreventClose(), isFalse);
});

testWidgets('isResizable', (tester) async {
expect(await windowManager.isResizable(), isTrue);
});

testWidgets('getSize', (tester) async {
expect(await windowManager.getSize(), Size(640, 480));
});

testWidgets('isSkipTaskbar', (tester) async {
expect(await windowManager.isSkipTaskbar(), isFalse);
}, skip: Platform.isWindows);

testWidgets('getTitle', (tester) async {
expect(await windowManager.getTitle(), 'window_manager_test');
});

testWidgets('getTitleBarHeight', (tester) async {
expect(await windowManager.getTitleBarHeight(), isNonNegative);
});

testWidgets('isVisible', (tester) async {
expect(await windowManager.isVisible(), isTrue);
});
}
78 changes: 78 additions & 0 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -43,6 +50,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -57,16 +71,38 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_driver:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
fuchsia_remote_debug_protocol:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
integration_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -102,13 +138,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
preference_list:
dependency: "direct main"
description:
name: preference_list
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.4"
screen_retriever:
dependency: transitive
description:
Expand Down Expand Up @@ -156,6 +206,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
sync_http:
dependency: transitive
description:
name: sync_http
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1"
term_glyph:
dependency: transitive
description:
Expand All @@ -177,13 +234,34 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.9"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
vm_service:
dependency: transitive
description:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "9.0.0"
webdriver:
dependency: transitive
description:
name: webdriver
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
window_manager:
dependency: "direct main"
description:
Expand Down
2 changes: 2 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down

0 comments on commit cd6dacf

Please sign in to comment.