Skip to content

Commit

Permalink
flutter: minor improvements to the test
Browse files Browse the repository at this point in the history
Remove 1 dock widget, added guest widget.
Testing if image diff works.
  • Loading branch information
iamsergio committed Dec 9, 2024
1 parent 6c81e9f commit 3b64fd5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 15 deletions.
24 changes: 9 additions & 15 deletions tests/flutter/integration_test/ui_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import 'dart:ui';

import 'package:KDDockWidgets/KDDockWidgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:KDDockWidgets/widgets/DropAreaWidget.dart';
import 'package:integration_test/integration_test.dart';
import 'package:kddockwidgets_integration_tests/MyWidget.dart';

import 'package:kddockwidgets_integration_tests/utils.dart';

Expand Down Expand Up @@ -67,19 +69,12 @@ class MyApp extends StatelessWidget {

void main() async {
testWidgets('Basic test', (WidgetTester tester) async {
final dock1 =
DockItem(uniqueName: "dw1", guestWidget: Container(color: Colors.cyan));
final dock2 =
DockItem(uniqueName: "dw2", guestWidget: Container(color: Colors.cyan));
final dock3 =
DockItem(uniqueName: "dw3", guestWidget: Container(color: Colors.cyan));

final dock11 = DockItem(
uniqueName: "dw11", guestWidget: Container(color: Colors.cyan));
final dock12 = DockItem(
uniqueName: "dw12", guestWidget: Container(color: Colors.cyan));
final dock13 = DockItem(
uniqueName: "dw13", guestWidget: Container(color: Colors.cyan));
final dock1 = DockItem(uniqueName: "dw1", guestWidget: MyWidget());
final dock2 = DockItem(uniqueName: "dw2", guestWidget: MyWidget());
final dock3 = DockItem(uniqueName: "dw3", guestWidget: MyWidget());

final dock11 = DockItem(uniqueName: "dw11", guestWidget: MyWidget());
final dock12 = DockItem(uniqueName: "dw12", guestWidget: MyWidget());

final dropArea = DropArea();
dropArea.addDockItem(dock1, Location.LocationOnTop);
Expand All @@ -88,7 +83,6 @@ void main() async {
group.addDockWidget(dock3);
group.addDockWidget(dock11);
group.addDockWidget(dock12);
group.addDockWidget(dock13);

dropArea.setLayoutSize(700, 700);
final dropAreaWidget = DropAreaWidget(dropArea);
Expand Down
45 changes: 45 additions & 0 deletions tests/flutter/lib/MyWidget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
Author: Sérgio Martins <[email protected]>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <[email protected]> for commercial licensing options.
*/
import 'dart:io';

import 'package:flutter/material.dart';

// ignore: must_be_immutable
class MyWidget extends StatelessWidget {
static int nextImageId = 0;
final int imageId;
MyWidget({super.key}) : imageId = nextImageId {
MyWidget.nextImageId++;
}

String imageName() {
switch (imageId % 2) {
case 0:
return 'assets/KDAB_bubble_fulcolor.png';
case 1:
return 'assets/KDAB_bubble_blue.png';
}

return 'assets/KDAB_bubble_fulcolor.png';
}

@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
padding: const EdgeInsets.all(40.0),
child: Image.file(
File(imageName()),
fit: BoxFit.contain,
),
);
}
}

0 comments on commit 3b64fd5

Please sign in to comment.