@@ -27,6 +27,7 @@ import 'package:lichess_mobile/src/view/engine/engine_lines.dart';
2727import 'package:lichess_mobile/src/view/more/more_tab_screen.dart' ;
2828import 'package:lichess_mobile/src/widgets/bottom_bar.dart' ;
2929import 'package:lichess_mobile/src/widgets/pgn.dart' ;
30+ import 'package:lichess_mobile/src/widgets/pockets.dart' ;
3031import 'package:multistockfish/multistockfish.dart' ;
3132
3233import '../../model/engine/fake_stockfish.dart' ;
@@ -127,6 +128,8 @@ void main() {
127128
128129 await tester.pumpWidget (app);
129130
131+ expect (find.byType (PocketsMenu ), findsNothing);
132+
130133 await tester.tap (find.bySemanticsLabel ('Menu' ));
131134 await tester.pumpAndSettle (); // wait for menu to open
132135
@@ -146,16 +149,62 @@ void main() {
146149 expect (find.textContaining ('Atomic' ), findsNothing);
147150 expect (find.textContaining ('Horde' ), findsOneWidget);
148151 expect (find.textContaining ('Racing Kings' ), findsOneWidget);
149- expect (find.textContaining ('Crazyhouse' ), findsNothing );
152+ expect (find.textContaining ('Crazyhouse' ), findsOneWidget );
150153
151154 await tester.tap (find.textContaining ('Horde' ));
152155 await tester.pumpAndSettle (); // wait for dialog to close and new variant to be loaded
153156
157+ expect (find.byType (PocketsMenu ), findsNothing);
158+
154159 // Horde starting position should be loaded:
155160 expect (find.byKey (const ValueKey ('b5-whitepawn' )), findsOneWidget);
161+
162+ // Change to crazhouse, pockets should be displayed:
163+ await tester.tap (find.bySemanticsLabel ('Menu' ));
164+ await tester.pumpAndSettle (); // wait for menu to open
165+ await tester.tap (find.text ('Change variant' ));
166+ await tester.pumpAndSettle (); // wait for dialog to open
167+ await tester.tap (find.textContaining ('Crazyhouse' ));
168+ await tester.pumpAndSettle (); // wait for dialog to close and new variant to be loaded
169+
170+ // One for white, one for black
171+ expect (find.byType (PocketsMenu ), findsNWidgets (2 ));
156172 }
157173 });
158174 }
175+
176+ testWidgets ('Crazyhouse support DropMoves for both sides' , (tester) async {
177+ final app = await makeTestProviderScopeApp (
178+ tester,
179+ home: const AnalysisScreen (
180+ options: AnalysisOptions .standalone (
181+ id: StringId ('standalone' ),
182+ orientation: Side .white,
183+ pgn: '''
184+ [Variant "Crazyhouse"]
185+ [FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR[] w KQkq - 0 1"]
186+ 1. e4 d5 2. exd5 Qxd5
187+ ''' ,
188+ isComputerAnalysisAllowed: false ,
189+ variant: Variant .crazyhouse,
190+ ),
191+ ),
192+ );
193+
194+ await tester.pumpWidget (app);
195+
196+ expect (find.byType (PocketsMenu ), findsNWidgets (2 ));
197+
198+ await playDropMove (tester, Side .white, Role .pawn, 'a4' );
199+ expect (find.byKey (const ValueKey ('a4-whitepawn' )), findsOneWidget);
200+
201+ // Illegal drop move for black, should not be played
202+ await playDropMove (tester, Side .black, Role .queen, 'h5' );
203+ expect (find.byKey (const ValueKey ('h5-blackqueen' )), findsNothing);
204+
205+ await playDropMove (tester, Side .black, Role .pawn, 'h5' );
206+ expect (find.byKey (const ValueKey ('h5-blackpawn' )), findsOneWidget);
207+ });
159208 });
160209
161210 group ('Analysis Tree View' , () {
0 commit comments