forked from firka/flutter
Cupertino examples improvements and clean up (#103044)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// 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 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_api_samples/cupertino/bottom_tab_bar/cupertino_tab_bar.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Can switch between tabs', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.CupertinoTabBarApp(),
|
||||
);
|
||||
|
||||
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
||||
expect(find.text('Content of tab 0'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Contacts'));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Content of tab 2'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
void main() {
|
||||
testWidgets('Has 4 CupertinoButton variants', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.CupertinoButtonApp(),
|
||||
);
|
||||
|
||||
expect(find.byType(CupertinoButton), findsNWidgets(4));
|
||||
|
||||
@@ -10,7 +10,7 @@ const Offset _kRowOffset = Offset(0.0, -50.0);
|
||||
void main() {
|
||||
testWidgets('Can change date, time and dateTime using CupertinoDatePicker', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.DatePickerApp(),
|
||||
);
|
||||
// Open the date picker.
|
||||
await tester.tap(find.text('10-26-2016'));
|
||||
|
||||
@@ -10,7 +10,7 @@ const Offset _kRowOffset = Offset(0.0, -50.0);
|
||||
void main() {
|
||||
testWidgets('Can pick a duration from CupertinoTimerPicker', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.TimerPickerApp(),
|
||||
);
|
||||
|
||||
// Launch the timer picker.
|
||||
|
||||
@@ -10,7 +10,7 @@ void main() {
|
||||
testWidgets('Perform an action on CupertinoActionSheet', (WidgetTester tester) async {
|
||||
const String actionText = 'Destructive Action';
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.ActionSheetApp(),
|
||||
);
|
||||
|
||||
// Launch the CupertinoActionSheet.
|
||||
|
||||
@@ -10,7 +10,7 @@ void main() {
|
||||
testWidgets('Perform an action on CupertinoAlertDialog', (WidgetTester tester) async {
|
||||
const String actionText = 'Yes';
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.AlertDialogApp(),
|
||||
);
|
||||
|
||||
// Launch the CupertinoAlertDialog.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// 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 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_api_samples/cupertino/nav_bar/cupertino_navigation_bar.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('CupertinoNavigationBar is semi transparent', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavBarApp(),
|
||||
);
|
||||
|
||||
final Finder navBarFinder = find.byType(CupertinoNavigationBar);
|
||||
expect(navBarFinder, findsOneWidget);
|
||||
final CupertinoNavigationBar cupertinoNavigationBar = tester.widget<CupertinoNavigationBar>(navBarFinder);
|
||||
expect(cupertinoNavigationBar.backgroundColor, CupertinoColors.systemGrey.withOpacity(0.5));
|
||||
});
|
||||
}
|
||||
@@ -11,7 +11,7 @@ const Offset dragUp = Offset(0.0, -150.0);
|
||||
void main() {
|
||||
testWidgets('Collapse and expand CupertinoSliverNavigationBar changes title position', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.SliverNavBarApp(),
|
||||
);
|
||||
|
||||
// Large title is visible and at lower position.
|
||||
@@ -25,7 +25,7 @@ void main() {
|
||||
|
||||
testWidgets('Middle widget is visible in both collapsed and expanded states', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.SliverNavBarApp(),
|
||||
);
|
||||
|
||||
// Navigate to a page that has both middle and large titles.
|
||||
@@ -48,7 +48,7 @@ void main() {
|
||||
|
||||
testWidgets('CupertinoSliverNavigationBar with previous route has back button', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.SliverNavBarApp(),
|
||||
);
|
||||
|
||||
// Navigate to a page that has back button
|
||||
|
||||
@@ -10,7 +10,7 @@ const Offset _kRowOffset = Offset(0.0, -50.0);
|
||||
void main() {
|
||||
testWidgets('Change selected fruit using CupertinoPicker', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.CupertinoPickerApp(),
|
||||
);
|
||||
|
||||
// Open the Cupertino picker.
|
||||
|
||||
@@ -8,12 +8,14 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
void main() {
|
||||
testWidgets('Can change a selected segmented control', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.SegmentControlApp(),
|
||||
);
|
||||
|
||||
expect(find.text('Selected Segment: midnight'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Cerulean'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Selected Segment: cerulean'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
void main() {
|
||||
testWidgets('Can change a selected segmented control', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.SegmentControlApp(),
|
||||
);
|
||||
|
||||
expect(find.text('Selected Segment: midnight'), findsOneWidget);
|
||||
|
||||
@@ -16,7 +16,7 @@ void main() {
|
||||
|
||||
testWidgets('Can change value using CupertinoSlider', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.CupertinoSliderApp(),
|
||||
);
|
||||
|
||||
// Check for the initial slider value.
|
||||
|
||||
@@ -2,15 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_api_samples/cupertino/text_field/cupertino_text_field.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('CupertinoTextField has initial text', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MyApp(),
|
||||
const example.CupertinoTextFieldApp(),
|
||||
);
|
||||
|
||||
expect(find.byType(CupertinoTextField), findsOneWidget);
|
||||
expect(find.text('initial text'), findsOneWidget);
|
||||
|
||||
await tester.enterText(find.byType(CupertinoTextField), 'new text');
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('new text'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user