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
5import 'package:flutter/cupertino.dart';
6import 'package:flutter_api_samples/cupertino/switch/cupertino_switch.0.dart' as example;
7import 'package:flutter_test/flutter_test.dart';
8
9void main() {
10 testWidgets('Toggling cupertino switch updates icon', (WidgetTester tester) async {
11 await tester.pumpWidget(const example.CupertinoSwitchApp());
12
13 final Finder switchFinder = find.byType(CupertinoSwitch);
14 CupertinoSwitch cupertinoSwitch = tester.widget<CupertinoSwitch>(switchFinder);
15 expect(cupertinoSwitch.value, true);
16
17 await tester.tap(switchFinder);
18 await tester.pumpAndSettle();
19 cupertinoSwitch = tester.widget<CupertinoSwitch>(switchFinder);
20 expect(cupertinoSwitch.value, false);
21 });
22}
23