fluffychat/test/utils/test_client.dart

39 lines
1.2 KiB
Dart
Raw Normal View History

2021-06-30 20:20:17 +02:00
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/flutter_famedly_sdk_hive_database.dart';
import 'package:matrix/encryption/utils/key_verification.dart';
import 'package:matrix/matrix.dart';
import 'package:matrix_api_lite/fake_matrix_api.dart';
2021-04-12 18:33:43 +02:00
Future<Client> prepareTestClient({
2021-04-12 18:33:43 +02:00
bool loggedIn = false,
String homeserver = 'https://fakeserver.notexisting',
String id = 'FluffyChat Widget Test',
}) async {
final client = Client(
'FluffyChat Widget Tests',
httpClient: FakeMatrixApi(),
enableE2eeRecovery: true,
verificationMethods: {
KeyVerificationMethod.numbers,
KeyVerificationMethod.emoji,
},
importantStateEvents: <String>{
'im.ponies.room_emotes', // we want emotes to work properly
},
databaseBuilder: FlutterFamedlySdkHiveDatabase.hiveDatabaseBuilder,
supportedLoginTypes: {
AuthenticationTypes.password,
AuthenticationTypes.sso
},
);
2021-04-12 18:33:43 +02:00
if (homeserver != null) {
await client.checkHomeserver(homeserver);
}
if (loggedIn) {
await client.login(
identifier: AuthenticationUserIdentifier(user: '@alice:example.invalid'),
password: '1234',
);
}
return client;
}