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 'dart:io';
6
7import 'package:flutter/material.dart';
8import 'package:flutter_api_samples/material/carousel/carousel.0.dart' as example;
9import 'package:flutter_test/flutter_test.dart';
10
11void main() {
12 // The app being tested loads images via HTTP which the test
13 // framework defeats by default.
14 setUpAll(() {
15 HttpOverrides.global = null;
16 });
17
18 testWidgets('Carousel Smoke Test', (WidgetTester tester) async {
19 await tester.pumpWidget(const example.CarouselExampleApp());
20
21 expect(find.widgetWithText(example.HeroLayoutCard, 'Through the Pane'), findsOneWidget);
22 final Finder firstCarousel = find.byType(CarouselView).first;
23 await tester.drag(firstCarousel, const Offset(150, 0));
24 await tester.pumpAndSettle();
25 expect(find.widgetWithText(example.HeroLayoutCard, 'The Flow'), findsOneWidget);
26
27 await tester.drag(firstCarousel, const Offset(0, -200));
28 await tester.pumpAndSettle();
29
30 expect(find.widgetWithText(CarouselView, 'Cameras'), findsOneWidget);
31 expect(find.widgetWithText(CarouselView, 'Lighting'), findsOneWidget);
32 expect(find.widgetWithText(CarouselView, 'Climate'), findsOneWidget);
33 expect(find.widgetWithText(CarouselView, 'Wifi'), findsOneWidget);
34
35 await tester.drag(find.widgetWithText(CarouselView, 'Cameras'), const Offset(0, -200));
36 await tester.pumpAndSettle();
37
38 expect(find.text('Uncontained layout'), findsOneWidget);
39 expect(find.widgetWithText(CarouselView, 'Show 0'), findsOneWidget);
40 expect(find.widgetWithText(CarouselView, 'Show 1'), findsOneWidget);
41 });
42}
43

Provided by KDAB

Privacy Policy
Learn more about Flutter for embedded and desktop on industrialflutter.com