Skip to content

Commit

Permalink
flutter: add dockregistry tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsergio committed Dec 8, 2024
1 parent a4cbba6 commit 9886877
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/flutter/dart/test/models/dockregistry_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2024 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 'package:flutter_test/flutter_test.dart';
import 'package:KDDockWidgets/KDDockWidgets.dart';
import 'package:KDDockWidgets/private/Bindings.dart';

void main() {
test('Dockregistry', () {
final dr = DockRegistry.instance;
expect(dr.dockItems.isEmpty, true);
expect(dr.floatingItems.isEmpty, true);

final dock = DockItem(uniqueName: "dw1");

expect(dr.dockItems.length, 1);
expect(dr.floatingItems.isEmpty, true);

final fw = FloatingItem();
fw.dropArea.addDockItem(dock, Location.LocationOnTop);
expect(dr.dockItems.length, 1);
expect(dr.floatingItems.isEmpty, false);
expect(fw.dropArea.groups.length, 1);
expect(dr.dockItems.length, 1);
expect(dr.floatingItems.length, 1);

fw.dropArea.groups.first.titlebar.onCloseClicked();
expect(dr.dockItems.length, 1); // dock items are persistent
expect(dr.floatingItems.isEmpty, true); // discarded when empty
expect(fw.dropArea.groups.isEmpty, true);

final dock2 = DockItem(uniqueName: "dw2");

final fw2 = FloatingItem();
fw2.dropArea.addDockItem(dock2, Location.LocationOnTop);
expect(dr.floatingItems.length, 1);
fw2.dropArea.removeDockItem(fw2.dropArea.groups.first.currentDockItem!);
expect(dr.floatingItems.isEmpty, true);
});
}

0 comments on commit 9886877

Please sign in to comment.