From cd6dacfe07c0fc333fb46e01e21bf889f117cdb2 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 6 Jan 2023 05:23:50 +0100 Subject: [PATCH] Add integration test (#275) * 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. --- .github/workflows/main.yml | 5 +- .../integration_test/window_manager_test.dart | 106 ++++++++++++++++++ example/pubspec.lock | 78 +++++++++++++ example/pubspec.yaml | 2 + 4 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 example/integration_test/window_manager_test.dart diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f5144f..8402c03 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,9 +17,10 @@ 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: @@ -27,9 +28,11 @@ jobs: - 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 diff --git a/example/integration_test/window_manager_test.dart b/example/integration_test/window_manager_test.dart new file mode 100644 index 0000000..764fc5f --- /dev/null +++ b/example/integration_test/window_manager_test.dart @@ -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 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().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()); + }); + + 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); + }); +} diff --git a/example/pubspec.lock b/example/pubspec.lock index 0e4a6fa..4293f5a 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -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: @@ -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: @@ -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: @@ -102,6 +138,13 @@ 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: @@ -109,6 +152,13 @@ packages: 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: @@ -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: @@ -177,6 +234,13 @@ 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: @@ -184,6 +248,20 @@ packages: 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: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index bfe5872..b294e9c 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -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