Skip to content

Commit

Permalink
v2.5.3
Browse files Browse the repository at this point in the history
- `testUI`:
  - Fix `tearDownAll`, declared before `setUpAll` (before call to `spawnHybridUri`).

- `SpawnHybrid`: added field `finalizer`.
  • Loading branch information
gmpassos committed Mar 10, 2024
1 parent bc6bfba commit a113970
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2.5.3

- `testUI`:
- Fix `tearDownAll`, declared before `setUpAll` (before call to `spawnHybridUri`).

- `SpawnHybrid`: added field `finalizer`.

## 2.5.2

- `UIElementExtension`:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bones_ui.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class BonesUI {
static const String version = '2.5.2';
static const String version = '2.5.3';
}
52 changes: 35 additions & 17 deletions lib/src/bones_ui_test_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,11 @@ class SpawnHybrid {
/// Optional callback for the [StreamChannel] returned by [spawnHybridUri] spawn.
dynamic Function(StreamChannel? channel)? callback;

SpawnHybrid(this.uri, {this.message, this.callback});
/// Optional finalizer for the [StreamChannel] returned by [spawnHybridUri] spawn.
/// Called in teardown.
dynamic Function(StreamChannel? channel)? finalizer;

SpawnHybrid(this.uri, {this.message, this.callback, this.finalizer});

@override
String toString() {
Expand Down Expand Up @@ -420,17 +424,20 @@ Future<void> testMultipleUI(Map<String, FutureOr<void> Function()> testsMain,
print('testMultipleUI> shuflle(shuffleSeed: $shuffleSeed)');
}

print('testMultipleUI> tests:');
print('testMultipleUI:');
for (var e in testsMain.entries) {
var testPath = e.key;
print(' -- $testPath');
}

print('');

for (var e in entries) {
var testPath = e.key;
var main = e.value;
_testMultipleUIPath = testPath;
await main();
await Future.delayed(Duration(milliseconds: 100));
}
}

Expand Down Expand Up @@ -490,8 +497,34 @@ void _testUIImpl<U extends UIRoot>(
group(testUIName, () {
U? uiRoot;

StreamChannel? channel;

// Teardown needs to be added before call to `spawnHybridUri`,
// since `spawnHybridUri` will terminate the process with its
// own `addTearDown` beforehand:
tearDownAll(() async {
context.setTestWindowTitle('tearDown');

if (uiRoot != null) {
uiRoot!.close();
await testUISleep(ms: 100);
}

final finalizer = spawnHybrid?.finalizer;
if (finalizer != null) {
await finalizer(channel);
}

if (teardown != null) {
teardown(context);
}
});

setUpAll(() async {
if (testMultipleUIPath != null) {
print('');
print(
'--------------------------------------------------------------------------------');
print('[Bones_UI] testMultipleUI> path: $testMultipleUIPath');
}

Expand All @@ -503,8 +536,6 @@ void _testUIImpl<U extends UIRoot>(
await preSetup();
}

StreamChannel? channel;

if (spawnHybrid != null) {
context.setTestWindowTitle('spawnHybridUri: ${spawnHybrid.uri} ...');

Expand All @@ -528,19 +559,6 @@ void _testUIImpl<U extends UIRoot>(
}
});

tearDownAll(() async {
context.setTestWindowTitle('tearDown');

if (uiRoot != null) {
uiRoot!.close();
await testUISleep(ms: 100);
}

if (teardown != null) {
teardown(context);
}
});

setUp(() {
if (context.hasErrors) {
fail("ABORTING TEST: `testUI` with a previous error!");
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: bones_ui
description: Bones_UI - An intuitive and user-friendly Web User Interface framework for Dart.
version: 2.5.2
version: 2.5.3
homepage: https://github.com/Colossus-Services/bones_ui

environment:
Expand Down

0 comments on commit a113970

Please sign in to comment.