Add Material 3 Dialog examples and update existing Dialog examples (#101508)
This commit is contained in:
30
examples/api/test/material/dialog/alert_dialog.0_test.dart
Normal file
30
examples/api/test/material/dialog/alert_dialog.0_test.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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/material.dart';
|
||||
import 'package:flutter_api_samples/material/dialog/alert_dialog.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Show Alert dialog', (WidgetTester tester) async {
|
||||
const String dialogTitle = 'AlertDialog Title';
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: example.MyApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
|
||||
await tester.tap(find.widgetWithText(TextButton, 'Show Dialog'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('OK'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
});
|
||||
}
|
||||
30
examples/api/test/material/dialog/alert_dialog.1_test.dart
Normal file
30
examples/api/test/material/dialog/alert_dialog.1_test.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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/material.dart';
|
||||
import 'package:flutter_api_samples/material/dialog/alert_dialog.1.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Show Alert dialog', (WidgetTester tester) async {
|
||||
const String dialogTitle = 'AlertDialog Title';
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: example.MyApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
|
||||
await tester.tap(find.widgetWithText(TextButton, 'Show Dialog'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('OK'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
});
|
||||
}
|
||||
30
examples/api/test/material/dialog/show_dialog.0_test.dart
Normal file
30
examples/api/test/material/dialog/show_dialog.0_test.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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/material.dart';
|
||||
import 'package:flutter_api_samples/material/dialog/show_dialog.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Show dialog', (WidgetTester tester) async {
|
||||
const String dialogTitle = 'Basic dialog title';
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: example.MyApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
|
||||
await tester.tap(find.widgetWithText(OutlinedButton, 'Open Dialog'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Enable'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
});
|
||||
}
|
||||
30
examples/api/test/material/dialog/show_dialog.1_test.dart
Normal file
30
examples/api/test/material/dialog/show_dialog.1_test.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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/material.dart';
|
||||
import 'package:flutter_api_samples/material/dialog/show_dialog.1.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Show dialog', (WidgetTester tester) async {
|
||||
const String dialogTitle = 'Basic dialog title';
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: example.MyApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
|
||||
await tester.tap(find.widgetWithText(OutlinedButton, 'Open Dialog'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Enable'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
});
|
||||
}
|
||||
30
examples/api/test/material/dialog/show_dialog.2_test.dart
Normal file
30
examples/api/test/material/dialog/show_dialog.2_test.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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/material.dart';
|
||||
import 'package:flutter_api_samples/material/dialog/show_dialog.2.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Show dialog', (WidgetTester tester) async {
|
||||
const String dialogTitle = 'Basic dialog title';
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: example.MyApp(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
|
||||
await tester.tap(find.widgetWithText(OutlinedButton, 'Open Dialog'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Enable'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(dialogTitle), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user