1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | import 'package:flutter/material.dart'; |
6 | import 'package:flutter_api_samples/material/radio/radio.1.dart' as example; |
7 | import 'package:flutter_test/flutter_test.dart'; |
8 | |
9 | void main() { |
10 | testWidgets('Radio colors can be changed' , (WidgetTester tester) async { |
11 | await tester.pumpWidget(const example.RadioExampleApp()); |
12 | |
13 | expect(find.widgetWithText(AppBar, 'Radio Sample' ), findsOne); |
14 | expect(find.widgetWithText(ListTile, 'Fill color' ), findsOne); |
15 | expect(find.widgetWithText(ListTile, 'Background color' ), findsOne); |
16 | expect(find.widgetWithText(ListTile, 'Side' ), findsOne); |
17 | expect(find.widgetWithText(ListTile, 'Inner radius' ), findsOne); |
18 | |
19 | final Radio<example.RadioType> radioFillColor = tester.widget<Radio<example.RadioType>>( |
20 | find.byType(Radio<example.RadioType>).first, |
21 | ); |
22 | expect( |
23 | radioFillColor.fillColor!.resolve(const <WidgetState>{WidgetState.selected}), |
24 | Colors.deepPurple, |
25 | ); |
26 | expect(radioFillColor.fillColor!.resolve(const <WidgetState>{}), Colors.deepPurple.shade200); |
27 | |
28 | final Radio<example.RadioType> radioBackgroundColor = tester.widget<Radio<example.RadioType>>( |
29 | find.byType(Radio<example.RadioType>).at(1), |
30 | ); |
31 | expect( |
32 | radioBackgroundColor.backgroundColor!.resolve(const <WidgetState>{WidgetState.selected}), |
33 | Colors.greenAccent.withOpacity(0.5), |
34 | ); |
35 | expect( |
36 | radioBackgroundColor.backgroundColor!.resolve(const <WidgetState>{}), |
37 | Colors.grey.shade300.withOpacity(0.3), |
38 | ); |
39 | |
40 | final Radio<example.RadioType> radioSide = tester.widget<Radio<example.RadioType>>( |
41 | find.byType(Radio<example.RadioType>).at(2), |
42 | ); |
43 | expect( |
44 | (radioSide.side! as WidgetStateBorderSide).resolve(const <WidgetState>{WidgetState.selected}), |
45 | const BorderSide(color: Colors.red, width: 4, strokeAlign: BorderSide.strokeAlignCenter), |
46 | ); |
47 | expect( |
48 | (radioSide.side! as WidgetStateBorderSide).resolve(const <WidgetState>{}), |
49 | const BorderSide(color: Colors.grey, width: 1.5, strokeAlign: BorderSide.strokeAlignCenter), |
50 | ); |
51 | |
52 | final Radio<example.RadioType> radioInnerRadius = tester.widget<Radio<example.RadioType>>( |
53 | find.byType(Radio<example.RadioType>).last, |
54 | ); |
55 | expect(radioInnerRadius.innerRadius!.resolve(const <WidgetState>{WidgetState.selected}), 6); |
56 | }); |
57 | } |
58 | |