Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: able to clear all overlays (#1536)
* feat: able to clear all overlays * feat: able to clear all overlays Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
- Loading branch information
1 parent
4f7a12e
commit 7b15c9a
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/flame/test/game/active_overlays_notifier_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import 'package:flame/game.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('ActiveOverlaysNotifier', () { | ||
test('can be constructed', () { | ||
expect(ActiveOverlaysNotifier(), isNotNull); | ||
}); | ||
|
||
late ActiveOverlaysNotifier notifier; | ||
|
||
setUp(() { | ||
notifier = ActiveOverlaysNotifier(); | ||
}); | ||
|
||
group('add', () { | ||
test('can add an overlay', () { | ||
final result = notifier.add('test'); | ||
|
||
expect(result, true); | ||
expect(notifier.isActive('test'), true); | ||
}); | ||
|
||
test('wont add same overlay', () { | ||
notifier.add('test'); | ||
final result = notifier.add('test'); | ||
|
||
expect(result, false); | ||
}); | ||
}); | ||
|
||
group('remove', () { | ||
test('can remove an overlay', () { | ||
notifier.add('test'); | ||
|
||
final result = notifier.remove('test'); | ||
|
||
expect(result, true); | ||
expect(notifier.isActive('test'), false); | ||
}); | ||
|
||
test('wont result in removal if there is nothing to remove', () { | ||
final result = notifier.remove('test'); | ||
|
||
expect(result, false); | ||
}); | ||
}); | ||
|
||
group('isActive', () { | ||
test('is true when overlay is active', () { | ||
notifier.add('test'); | ||
expect(notifier.isActive('test'), true); | ||
}); | ||
|
||
test('is false when overlay is active', () { | ||
expect(notifier.isActive('test'), false); | ||
}); | ||
}); | ||
|
||
group('clear', () { | ||
test('clears all overlays', () { | ||
notifier.add('test1'); | ||
notifier.add('test2'); | ||
|
||
notifier.clear(); | ||
|
||
expect(notifier.isActive('test1'), false); | ||
expect(notifier.isActive('test2'), false); | ||
}); | ||
}); | ||
}); | ||
} |