|
| 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/stepper/step_style.0.dart' as example; |
| 7 | +import 'package:flutter_test/flutter_test.dart'; |
| 8 | + |
| 9 | +void main() { |
| 10 | + testWidgets('StepStyle Smoke Test', (WidgetTester tester) async { |
| 11 | + await tester.pumpWidget( |
| 12 | + const example.StepStyleExampleApp(), |
| 13 | + ); |
| 14 | + |
| 15 | + expect(find.widgetWithText(AppBar, 'Step Style Example'), findsOneWidget); |
| 16 | + |
| 17 | + final Stepper stepper = tester.widget<Stepper>(find.byType(Stepper)); |
| 18 | + // Check that the stepper has the correct properties. |
| 19 | + expect(stepper.type, StepperType.horizontal); |
| 20 | + expect(stepper.stepIconHeight, 48); |
| 21 | + expect(stepper.stepIconWidth, 48); |
| 22 | + expect(stepper.stepIconMargin, EdgeInsets.zero); |
| 23 | + |
| 24 | + // Check that the first step has the correct properties. |
| 25 | + final Step firstStep = stepper.steps[0]; |
| 26 | + expect(firstStep.title, isA<SizedBox>()); |
| 27 | + expect(firstStep.content, isA<SizedBox>()); |
| 28 | + expect(firstStep.isActive, true); |
| 29 | + expect(firstStep.stepStyle?.connectorThickness, 10); |
| 30 | + expect(firstStep.stepStyle?.color, Colors.white); |
| 31 | + expect(firstStep.stepStyle?.connectorColor, Colors.red); |
| 32 | + expect(firstStep.stepStyle?.indexStyle?.color, Colors.black); |
| 33 | + expect(firstStep.stepStyle?.indexStyle?.fontSize, 20); |
| 34 | + expect(firstStep.stepStyle?.border, Border.all(width: 2)); |
| 35 | + |
| 36 | + // Check that the second step has the correct properties. |
| 37 | + final Step secondStep = stepper.steps[1]; |
| 38 | + expect(secondStep.title, isA<SizedBox>()); |
| 39 | + expect(secondStep.content, isA<SizedBox>()); |
| 40 | + expect(secondStep.isActive, true); |
| 41 | + expect(secondStep.stepStyle?.connectorThickness, 10); |
| 42 | + expect(secondStep.stepStyle?.connectorColor, Colors.orange); |
| 43 | + expect(secondStep.stepStyle?.gradient, const LinearGradient( |
| 44 | + colors: <Color>[ |
| 45 | + Colors.white, |
| 46 | + Colors.black, |
| 47 | + ], |
| 48 | + )); |
| 49 | + |
| 50 | + // Check that the third step has the correct properties. |
| 51 | + final Step thirdStep = stepper.steps[2]; |
| 52 | + expect(thirdStep.title, isA<SizedBox>()); |
| 53 | + expect(thirdStep.content, isA<SizedBox>()); |
| 54 | + expect(thirdStep.isActive, true); |
| 55 | + expect(thirdStep.stepStyle?.connectorThickness, 10); |
| 56 | + expect(thirdStep.stepStyle?.color, Colors.white); |
| 57 | + expect(thirdStep.stepStyle?.connectorColor, Colors.blue); |
| 58 | + expect(thirdStep.stepStyle?.indexStyle?.color, Colors.black); |
| 59 | + expect(thirdStep.stepStyle?.indexStyle?.fontSize, 20); |
| 60 | + expect(thirdStep.stepStyle?.border, Border.all(width: 2)); |
| 61 | + |
| 62 | + // Check that the fourth step has the correct properties. |
| 63 | + final Step fourthStep = stepper.steps[3]; |
| 64 | + expect(fourthStep.title, isA<SizedBox>()); |
| 65 | + expect(fourthStep.content, isA<SizedBox>()); |
| 66 | + expect(fourthStep.isActive, true); |
| 67 | + expect(fourthStep.stepStyle?.color, Colors.white); |
| 68 | + expect(fourthStep.stepStyle?.indexStyle?.color, Colors.black); |
| 69 | + expect(fourthStep.stepStyle?.indexStyle?.fontSize, 20); |
| 70 | + expect(fourthStep.stepStyle?.border, Border.all(width: 2)); |
| 71 | + }); |
| 72 | +} |
0 commit comments