tests: Add tests for homeserver picker

This commit is contained in:
Christian Pauly 2021-04-10 17:30:15 +02:00
parent f5f02c62d8
commit d4d2c88330
2 changed files with 23 additions and 4 deletions

View File

@ -41,18 +41,21 @@ void main() async {
runZonedGuarded(
() => runApp(PlatformInfos.isMobile
? AppLock(
builder: (args) => App(),
builder: (args) => FluffyChatApp(),
lockScreen: LockScreen(),
enabled: false,
)
: App()),
: FluffyChatApp()),
SentryController.captureException,
);
}
class App extends StatelessWidget {
class FluffyChatApp extends StatelessWidget {
final Widget test;
static final GlobalKey<AdaptivePageLayoutState> _apl =
GlobalKey<AdaptivePageLayoutState>();
const FluffyChatApp({Key key, this.test}) : super(key: key);
@override
Widget build(BuildContext context) {
return AdaptiveTheme(
@ -76,7 +79,9 @@ class App extends StatelessWidget {
builder: (context) => AdaptivePageLayout(
key: _apl,
safeAreaOnColumnView: false,
onGenerateRoute: FluffyRoutes(context).onGenerateRoute,
onGenerateRoute: test == null
? FluffyRoutes(context).onGenerateRoute
: (_) => ViewData(mainView: (_) => test),
dividerColor: Theme.of(context).dividerColor,
columnWidth: FluffyThemes.columnWidth,
dividerWidth: 1.0,

View File

@ -0,0 +1,14 @@
import 'package:fluffychat/controllers/homeserver_picker_controller.dart';
import 'package:fluffychat/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Test if the widget can be created', (WidgetTester tester) async {
await tester.pumpWidget(FluffyChatApp(test: HomeserverPicker()));
await tester.tap(find.byType(TextField));
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();
});
}