// Author: fruit.com.cn import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart'; void main() { testWidgets('should_use_one_shared_52px_center_toggle_style', (tester) async { await tester.pumpWidget( MaterialApp( home: Scaffold( body: Row( children: [ PlayerCenterToggle( key: const Key('test-center-toggle-a'), playing: false, onTap: () {}, ), PlayerCenterToggle( key: const Key('player-play-toggle'), playing: true, onTap: () {}, ), ], ), ), ), ); for (final key in const [ Key('test-center-toggle-a'), Key('player-play-toggle'), ]) { expect(tester.getSize(find.byKey(key)), const Size(52, 52)); final container = tester.widget( find.descendant(of: find.byKey(key), matching: find.byType(Container)), ); final decoration = container.decoration! as BoxDecoration; expect(decoration.color, const Color(0x80000000)); expect(decoration.shape, BoxShape.circle); final icon = tester.widget( find.descendant(of: find.byKey(key), matching: find.byType(Icon)), ); expect(icon.size, 26); } }); }