// Author: fruit.com.cn import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:fruitshorts/core/theme/app_colors.dart'; import 'package:fruitshorts/pages/player/widgets/player_center_toggle.dart'; void main() { testWidgets('should_use_one_shared_68px_translucent_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(68, 68)); // 圆形底改为半透明黑色,不再是完全透明或蓝色实底。 final container = tester.widget( find.descendant(of: find.byKey(key), matching: find.byType(Container)), ); final decoration = container.decoration! as BoxDecoration; expect(decoration.color, Colors.black26); expect(decoration.shape, BoxShape.circle); final icon = tester.widget( find.descendant(of: find.byKey(key), matching: find.byType(Icon)), ); expect(icon.size, 36); expect(icon.color, AppColors.onPrimary); expect(icon.shadows, isNotNull); expect(icon.shadows, isNotEmpty); } }); }