Restructure some things
This commit is contained in:
parent
99f15fda36
commit
d4bbca6405
9 changed files with 174 additions and 81 deletions
11
test/testAlert.dart
Normal file
11
test/testAlert.dart
Normal file
|
@ -0,0 +1,11 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:libacflutter/tests/tester.dart';
|
||||
|
||||
void main() {
|
||||
test("Test a null alert callback", () async {
|
||||
runApp(WidgetTest(route: "/testalert0"));
|
||||
});
|
||||
}
|
|
@ -1,70 +1,14 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:libacflutter/Alert.dart';
|
||||
import 'package:libacflutter/Constants.dart';
|
||||
import 'package:libacflutter/Prompt.dart';
|
||||
import 'package:libacflutter/tests/tester.dart';
|
||||
|
||||
void main() {
|
||||
test("Test the input prompt", () async {
|
||||
runApp(WidgetTester(route: "/testprompt"));
|
||||
runApp(WidgetTest(route: "/testprompt"));
|
||||
});
|
||||
}
|
||||
|
||||
class WidgetTester extends StatelessWidget {
|
||||
String route;
|
||||
|
||||
WidgetTester({required this.route});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData.dark(),
|
||||
routes: {"/testprompt": (context) => TestPrompt()},
|
||||
home: TestPrompt(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestPrompt extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return TestPromptState();
|
||||
}
|
||||
}
|
||||
|
||||
class TestPromptState extends State<TestPrompt> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Input Prompt Test"),
|
||||
backgroundColor: LibACFlutterConstants.TITLEBAR_COLOR,
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
var reply = await showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (buildx) {
|
||||
return InputPrompt(
|
||||
title: "Test",
|
||||
prompt: "Enter a value",
|
||||
currentValue: "",
|
||||
type: InputPromptType.Text,
|
||||
);
|
||||
});
|
||||
|
||||
// Show a alert dialog with the reply content
|
||||
showAdaptiveDialog(
|
||||
context: context,
|
||||
builder: (buildx) {
|
||||
return Alert(title: "Test Result", body: reply);
|
||||
});
|
||||
},
|
||||
child: Text("Show prompt"))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue