flutter/examples/api/test/material/carousel/carousel.0_test.dart
Qun Cheng 844eb2fe76
Create CarouselView widget - Part 2 (#149775)
This PR is to create `Carousel.weighted` so the size of each carousel item is based on a list of weights. While scrolling, item sizes are changing dynamically based on the scrolling progress.

https://github.com/flutter/flutter/assets/36861262/181472b0-6f8b-48e7-b191-ab5f7c88c0c8
2024-07-17 19:56:01 +00:00

46 lines
1.7 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/material/carousel/carousel.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
// The app being tested loads images via HTTP which the test
// framework defeats by default.
setUpAll(() {
HttpOverrides.global = null;
});
testWidgets('Carousel Smoke Test', (WidgetTester tester) async {
await tester.pumpWidget(
const example.CarouselExampleApp(),
);
expect(find.widgetWithText(example.HeroLayoutCard, 'Through the Pane'), findsOneWidget);
final Finder firstCarousel = find.byType(CarouselView).first;
await tester.drag(firstCarousel, const Offset(150, 0));
await tester.pumpAndSettle();
expect(find.widgetWithText(example.HeroLayoutCard, 'The Flow'), findsOneWidget);
await tester.drag(firstCarousel, const Offset(0, -200));
await tester.pumpAndSettle();
expect(find.widgetWithText(CarouselView, 'Cameras'), findsOneWidget);
expect(find.widgetWithText(CarouselView, 'Lighting'), findsOneWidget);
expect(find.widgetWithText(CarouselView, 'Climate'), findsOneWidget);
expect(find.widgetWithText(CarouselView, 'Wifi'), findsOneWidget);
await tester.drag(find.widgetWithText(CarouselView, 'Cameras'), const Offset(0, -200));
await tester.pumpAndSettle();
expect(find.text('Uncontained layout'), findsOneWidget);
expect(find.widgetWithText(CarouselView, 'Show 0'), findsOneWidget);
expect(find.widgetWithText(CarouselView, 'Show 1'), findsOneWidget);
});
}