2021-06-23 15:35:23 +02:00
|
|
|
import 'package:matrix/encryption/utils/key_verification.dart';
|
2021-06-18 10:29:48 +02:00
|
|
|
import 'package:matrix/matrix.dart';
|
2021-06-23 15:35:23 +02:00
|
|
|
import 'package:matrix_api_lite/fake_matrix_api.dart';
|
2021-04-12 18:33:43 +02:00
|
|
|
|
2021-10-26 18:50:34 +02:00
|
|
|
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart';
|
|
|
|
|
2021-06-23 15:35:23 +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 {
|
2021-06-23 15:35:23 +02:00
|
|
|
final client = Client(
|
|
|
|
'FluffyChat Widget Tests',
|
|
|
|
httpClient: FakeMatrixApi(),
|
|
|
|
verificationMethods: {
|
|
|
|
KeyVerificationMethod.numbers,
|
|
|
|
KeyVerificationMethod.emoji,
|
|
|
|
},
|
|
|
|
importantStateEvents: <String>{
|
|
|
|
'im.ponies.room_emotes', // we want emotes to work properly
|
|
|
|
},
|
2021-07-23 18:39:18 +02:00
|
|
|
databaseBuilder: FlutterMatrixHiveStore.hiveDatabaseBuilder,
|
2021-06-23 15:35:23 +02:00
|
|
|
supportedLoginTypes: {
|
|
|
|
AuthenticationTypes.password,
|
|
|
|
AuthenticationTypes.sso
|
|
|
|
},
|
|
|
|
);
|
2022-01-29 12:35:03 +01:00
|
|
|
await client.checkHomeserver(homeserver);
|
2021-04-12 18:33:43 +02:00
|
|
|
if (loggedIn) {
|
|
|
|
await client.login(
|
2021-08-18 17:24:59 +02:00
|
|
|
LoginType.mLoginToken,
|
2021-04-12 18:33:43 +02:00
|
|
|
identifier: AuthenticationUserIdentifier(user: '@alice:example.invalid'),
|
|
|
|
password: '1234',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return client;
|
|
|
|
}
|