Merge branch 'krille/add-tests' into 'master'
Add more tests See merge request famedly/famedlysdk!326
This commit is contained in:
commit
7dba429a7b
|
@ -1,6 +1,7 @@
|
||||||
import '../room.dart';
|
import '../room.dart';
|
||||||
|
|
||||||
abstract class MatrixLocalizations {
|
abstract class MatrixLocalizations {
|
||||||
|
const MatrixLocalizations();
|
||||||
String get emptyChat;
|
String get emptyChat;
|
||||||
|
|
||||||
String get invitedUsersOnly;
|
String get invitedUsersOnly;
|
||||||
|
@ -121,9 +122,8 @@ extension HistoryVisibilityDisplayString on HistoryVisibility {
|
||||||
return i18n.visibleForAllParticipants;
|
return i18n.visibleForAllParticipants;
|
||||||
case HistoryVisibility.world_readable:
|
case HistoryVisibility.world_readable:
|
||||||
return i18n.visibleForEveryone;
|
return i18n.visibleForEveryone;
|
||||||
default:
|
|
||||||
return toString().replaceAll('HistoryVisibility.', '');
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,9 +134,8 @@ extension GuestAccessDisplayString on GuestAccess {
|
||||||
return i18n.guestsCanJoin;
|
return i18n.guestsCanJoin;
|
||||||
case GuestAccess.forbidden:
|
case GuestAccess.forbidden:
|
||||||
return i18n.guestsAreForbidden;
|
return i18n.guestsAreForbidden;
|
||||||
default:
|
|
||||||
return toString().replaceAll('GuestAccess.', '');
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,6 @@ class OpenIdCredentials {
|
||||||
String matrixServerName;
|
String matrixServerName;
|
||||||
num expiresIn;
|
num expiresIn;
|
||||||
|
|
||||||
OpenIdCredentials(
|
|
||||||
{this.accessToken,
|
|
||||||
this.tokenType,
|
|
||||||
this.matrixServerName,
|
|
||||||
this.expiresIn});
|
|
||||||
|
|
||||||
OpenIdCredentials.fromJson(Map<String, dynamic> json) {
|
OpenIdCredentials.fromJson(Map<String, dynamic> json) {
|
||||||
accessToken = json['access_token'];
|
accessToken = json['access_token'];
|
||||||
tokenType = json['token_type'];
|
tokenType = json['token_type'];
|
||||||
|
|
|
@ -7,14 +7,6 @@ class PublicRoomsResponse {
|
||||||
final int totalRoomCountEstimate;
|
final int totalRoomCountEstimate;
|
||||||
Client client;
|
Client client;
|
||||||
|
|
||||||
PublicRoomsResponse({
|
|
||||||
this.publicRooms,
|
|
||||||
this.nextBatch,
|
|
||||||
this.prevBatch,
|
|
||||||
this.totalRoomCountEstimate,
|
|
||||||
this.client,
|
|
||||||
});
|
|
||||||
|
|
||||||
PublicRoomsResponse.fromJson(Map<String, dynamic> json, Client client)
|
PublicRoomsResponse.fromJson(Map<String, dynamic> json, Client client)
|
||||||
: nextBatch = json['next_batch'],
|
: nextBatch = json['next_batch'],
|
||||||
prevBatch = json['prev_batch'],
|
prevBatch = json['prev_batch'],
|
||||||
|
@ -42,18 +34,6 @@ class PublicRoomEntry {
|
||||||
|
|
||||||
Future<void> join() => client.joinRoomById(roomId);
|
Future<void> join() => client.joinRoomById(roomId);
|
||||||
|
|
||||||
PublicRoomEntry({
|
|
||||||
this.aliases,
|
|
||||||
this.avatarUrl,
|
|
||||||
this.guestCanJoin,
|
|
||||||
this.name,
|
|
||||||
this.numJoinedMembers,
|
|
||||||
this.roomId,
|
|
||||||
this.topic,
|
|
||||||
this.worldReadable,
|
|
||||||
this.client,
|
|
||||||
});
|
|
||||||
|
|
||||||
PublicRoomEntry.fromJson(Map<String, dynamic> json, Client client)
|
PublicRoomEntry.fromJson(Map<String, dynamic> json, Client client)
|
||||||
: aliases =
|
: aliases =
|
||||||
json.containsKey('aliases') ? json['aliases'].cast<String>() : [],
|
json.containsKey('aliases') ? json['aliases'].cast<String>() : [],
|
||||||
|
|
|
@ -8,16 +8,6 @@ class Pusher {
|
||||||
String lang;
|
String lang;
|
||||||
PusherData data;
|
PusherData data;
|
||||||
|
|
||||||
Pusher(
|
|
||||||
{this.pushkey,
|
|
||||||
this.kind,
|
|
||||||
this.appId,
|
|
||||||
this.appDisplayName,
|
|
||||||
this.deviceDisplayName,
|
|
||||||
this.profileTag,
|
|
||||||
this.lang,
|
|
||||||
this.data});
|
|
||||||
|
|
||||||
Pusher.fromJson(Map<String, dynamic> json) {
|
Pusher.fromJson(Map<String, dynamic> json) {
|
||||||
pushkey = json['pushkey'];
|
pushkey = json['pushkey'];
|
||||||
kind = json['kind'];
|
kind = json['kind'];
|
||||||
|
@ -49,8 +39,6 @@ class PusherData {
|
||||||
String url;
|
String url;
|
||||||
String format;
|
String format;
|
||||||
|
|
||||||
PusherData({this.url, this.format});
|
|
||||||
|
|
||||||
PusherData.fromJson(Map<String, dynamic> json) {
|
PusherData.fromJson(Map<String, dynamic> json) {
|
||||||
url = json['url'];
|
url = json['url'];
|
||||||
format = json['format'];
|
format = json['format'];
|
||||||
|
@ -58,8 +46,8 @@ class PusherData {
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final data = <String, dynamic>{};
|
final data = <String, dynamic>{};
|
||||||
data['url'] = url;
|
if (url != null) data['url'] = url;
|
||||||
data['format'] = format;
|
if (format != null) data['format'] = format;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ class WellKnownInformations {
|
||||||
MHomeserver mIdentityServer;
|
MHomeserver mIdentityServer;
|
||||||
Map<String, dynamic> content;
|
Map<String, dynamic> content;
|
||||||
|
|
||||||
WellKnownInformations({this.mHomeserver, this.mIdentityServer});
|
|
||||||
|
|
||||||
WellKnownInformations.fromJson(Map<String, dynamic> json) {
|
WellKnownInformations.fromJson(Map<String, dynamic> json) {
|
||||||
content = json;
|
content = json;
|
||||||
mHomeserver = json['m.homeserver'] != null
|
mHomeserver = json['m.homeserver'] != null
|
||||||
|
@ -19,8 +17,6 @@ class WellKnownInformations {
|
||||||
class MHomeserver {
|
class MHomeserver {
|
||||||
String baseUrl;
|
String baseUrl;
|
||||||
|
|
||||||
MHomeserver({this.baseUrl});
|
|
||||||
|
|
||||||
MHomeserver.fromJson(Map<String, dynamic> json) {
|
MHomeserver.fromJson(Map<String, dynamic> json) {
|
||||||
baseUrl = json['base_url'];
|
baseUrl = json['base_url'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,6 +411,12 @@ void main() {
|
||||||
expect(openId.tokenType, 'Bearer');
|
expect(openId.tokenType, 'Bearer');
|
||||||
expect(openId.matrixServerName, 'example.com');
|
expect(openId.matrixServerName, 'example.com');
|
||||||
expect(openId.expiresIn, 3600);
|
expect(openId.expiresIn, 3600);
|
||||||
|
expect(openId.toJson(), {
|
||||||
|
'access_token': 'SomeT0kenHere',
|
||||||
|
'token_type': 'Bearer',
|
||||||
|
'matrix_server_name': 'example.com',
|
||||||
|
'expires_in': 3600
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('createRoom', () async {
|
test('createRoom', () async {
|
||||||
|
|
213
test/matrix_default_localizations.dart
Normal file
213
test/matrix_default_localizations.dart
Normal file
|
@ -0,0 +1,213 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Zender & Kurtz GbR.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Christian Pauly <krille@famedly.com>
|
||||||
|
* Marcel Radzio <mtrnord@famedly.com>
|
||||||
|
*
|
||||||
|
* This file is part of famedlysdk.
|
||||||
|
*
|
||||||
|
* famedlysdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* famedlysdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
|
||||||
|
class MatrixDefaultLocalizations extends MatrixLocalizations {
|
||||||
|
const MatrixDefaultLocalizations();
|
||||||
|
@override
|
||||||
|
String acceptedTheInvitation(String targetName) =>
|
||||||
|
'$targetName accepted the invitation';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String activatedEndToEndEncryption(String senderName) =>
|
||||||
|
'$senderName activated end to end encryption';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get anyoneCanJoin => 'Anyone can join';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String bannedUser(String senderName, String targetName) =>
|
||||||
|
'$senderName banned $targetName';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheChatAvatar(String senderName) =>
|
||||||
|
'$senderName changed the chat avatar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheChatDescriptionTo(String senderName, String content) =>
|
||||||
|
'$senderName changed the chat description to $content';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheChatNameTo(String senderName, String content) =>
|
||||||
|
'$senderName changed the chat name to $content';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheChatPermissions(String senderName) =>
|
||||||
|
'$senderName changed the chat permissions';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheDisplaynameTo(String targetName, String newDisplayname) =>
|
||||||
|
'$targetName changed the displayname to $newDisplayname';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheGuestAccessRules(String senderName) =>
|
||||||
|
'$senderName changed the guest access rules';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheGuestAccessRulesTo(
|
||||||
|
String senderName, String localizedString) =>
|
||||||
|
'$senderName changed the guest access rules to $localizedString';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheHistoryVisibility(String senderName) =>
|
||||||
|
'$senderName changed the history visibility';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheHistoryVisibilityTo(
|
||||||
|
String senderName, String localizedString) =>
|
||||||
|
'$senderName changed the history visibility to $localizedString';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheJoinRules(String senderName) =>
|
||||||
|
'$senderName changed the join rules';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheJoinRulesTo(String senderName, String localizedString) =>
|
||||||
|
'$senderName changed the join rules to $localizedString';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheProfileAvatar(String targetName) =>
|
||||||
|
'$targetName changed the profile avatar';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheRoomAliases(String senderName) =>
|
||||||
|
'$senderName changed the room aliases';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String changedTheRoomInvitationLink(String senderName) =>
|
||||||
|
'$senderName changed the room invitation link';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get channelCorruptedDecryptError =>
|
||||||
|
'The secure channel has been corrupted';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String couldNotDecryptMessage(String errorText) =>
|
||||||
|
'Could not decrypt message: $errorText';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String createdTheChat(String senderName) => '$senderName created the chat';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get emptyChat => 'Empty chat';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get encryptionNotEnabled => 'Encryption not enabled';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get fromJoining => 'From joining';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get fromTheInvitation => 'From the invitation';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String groupWith(String displayname) => 'Group with $displayname';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get guestsAreForbidden => 'Guests are forbidden';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get guestsCanJoin => 'Guests can join';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String hasWithdrawnTheInvitationFor(String senderName, String targetName) =>
|
||||||
|
'$senderName has withdrawn the invitation for $targetName';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String invitedUser(String senderName, String targetName) =>
|
||||||
|
'$senderName has invited $targetName';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get invitedUsersOnly => 'Invited users only';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String joinedTheChat(String targetName) => '$targetName joined the chat';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String kicked(String senderName, String targetName) =>
|
||||||
|
'$senderName kicked $targetName';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String kickedAndBanned(String senderName, String targetName) =>
|
||||||
|
'$senderName banned $targetName';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get needPantalaimonWarning => 'Need pantalaimon';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get noPermission => 'No permission';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String redactedAnEvent(String senderName) => '$senderName redacted an event';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String rejectedTheInvitation(String targetName) =>
|
||||||
|
'$targetName rejected the invitation';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String removedBy(String calcDisplayname) => 'Removed by $calcDisplayname';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get roomHasBeenUpgraded => 'Room has been upgraded';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String sentAFile(String senderName) => '$senderName sent a file';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String sentAPicture(String senderName) => '$senderName sent a picture';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String sentASticker(String senderName) => '$senderName sent a sticker';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String sentAVideo(String senderName) => '$senderName sent a video';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String sentAnAudio(String senderName) => '$senderName sent an audio';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String sharedTheLocation(String senderName) =>
|
||||||
|
'$senderName shared the location';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String unbannedUser(String senderName, String targetName) =>
|
||||||
|
'$senderName unbanned $targetName';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get unknownEncryptionAlgorithm => 'Unknown encryption algorithm';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String unknownEvent(String typeKey) => 'Unknown event $typeKey';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String userLeftTheChat(String targetName) => '$targetName left the chat';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get visibleForAllParticipants => 'Visible for all participants';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get visibleForEveryone => 'Visible for everyone';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get you => 'You';
|
||||||
|
}
|
71
test/matrix_exception_test.dart
Normal file
71
test/matrix_exception_test.dart
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Zender & Kurtz GbR.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Christian Pauly <krille@famedly.com>
|
||||||
|
* Marcel Radzio <mtrnord@famedly.com>
|
||||||
|
*
|
||||||
|
* This file is part of famedlysdk.
|
||||||
|
*
|
||||||
|
* famedlysdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* famedlysdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:http/http.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
/// All Tests related to device keys
|
||||||
|
group('Matrix Exception', () {
|
||||||
|
test('Matrix Exception', () async {
|
||||||
|
final matrixException = MatrixException(
|
||||||
|
Response(
|
||||||
|
'{"flows":[{"stages":["example.type.foo"]}],"params":{"example.type.baz":{"example_key":"foobar"}},"session":"xxxxxxyz","completed":["example.type.foo"]}',
|
||||||
|
401,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(matrixException.errcode, 'M_FORBIDDEN');
|
||||||
|
final flows = matrixException.authenticationFlows;
|
||||||
|
expect(flows.length, 1);
|
||||||
|
expect(flows.first.stages.length, 1);
|
||||||
|
expect(flows.first.stages.first, 'example.type.foo');
|
||||||
|
expect(
|
||||||
|
matrixException.authenticationParams['example.type.baz'],
|
||||||
|
{'example_key': 'foobar'},
|
||||||
|
);
|
||||||
|
expect(matrixException.completedAuthenticationFlows.length, 1);
|
||||||
|
expect(matrixException.completedAuthenticationFlows.first,
|
||||||
|
'example.type.foo');
|
||||||
|
expect(matrixException.session, 'xxxxxxyz');
|
||||||
|
});
|
||||||
|
test('Unknown Exception', () async {
|
||||||
|
final matrixException = MatrixException(
|
||||||
|
Response(
|
||||||
|
'{"errcode":"M_HAHA","error":"HAHA","retry_after_ms":500}',
|
||||||
|
401,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(matrixException.error, MatrixError.M_UNKNOWN);
|
||||||
|
expect(matrixException.retryAfterMs, 500);
|
||||||
|
});
|
||||||
|
test('Missing Exception', () async {
|
||||||
|
final matrixException = MatrixException(
|
||||||
|
Response(
|
||||||
|
'{"error":"HAHA"}',
|
||||||
|
401,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(matrixException.error, MatrixError.M_UNKNOWN);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
52
test/matrix_file_test.dart
Normal file
52
test/matrix_file_test.dart
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Zender & Kurtz GbR.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Christian Pauly <krille@famedly.com>
|
||||||
|
* Marcel Radzio <mtrnord@famedly.com>
|
||||||
|
*
|
||||||
|
* This file is part of famedlysdk.
|
||||||
|
*
|
||||||
|
* famedlysdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* famedlysdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
import 'package:olm/olm.dart' as olm;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
/// All Tests related to device keys
|
||||||
|
group('Matrix File', () {
|
||||||
|
test('Decrypt', () async {
|
||||||
|
final text = 'hello world';
|
||||||
|
final file = MatrixFile(
|
||||||
|
path: '/path/to/file.txt',
|
||||||
|
bytes: Uint8List.fromList(text.codeUnits),
|
||||||
|
);
|
||||||
|
var olmEnabled = true;
|
||||||
|
try {
|
||||||
|
await olm.init();
|
||||||
|
olm.Account();
|
||||||
|
} catch (_) {
|
||||||
|
olmEnabled = false;
|
||||||
|
}
|
||||||
|
if (olmEnabled) {
|
||||||
|
final encryptedFile = await file.encrypt();
|
||||||
|
expect(encryptedFile != null, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -45,6 +45,8 @@ void main() {
|
||||||
expect('\$test:example.com'.sigil, '\$');
|
expect('\$test:example.com'.sigil, '\$');
|
||||||
expect(mxId.localpart, 'test');
|
expect(mxId.localpart, 'test');
|
||||||
expect(mxId.domain, 'example.com');
|
expect(mxId.domain, 'example.com');
|
||||||
|
expect(mxId.equals('@Test:example.com'), true);
|
||||||
|
expect(mxId.equals('@test:example.org'), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
65
test/matrix_localizations_test.dart
Normal file
65
test/matrix_localizations_test.dart
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Zender & Kurtz GbR.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Christian Pauly <krille@famedly.com>
|
||||||
|
* Marcel Radzio <mtrnord@famedly.com>
|
||||||
|
*
|
||||||
|
* This file is part of famedlysdk.
|
||||||
|
*
|
||||||
|
* famedlysdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* famedlysdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
import 'matrix_default_localizations.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
/// All Tests related to device keys
|
||||||
|
group('Matrix Localizations', () {
|
||||||
|
test('Matrix Localizations', () {
|
||||||
|
expect(
|
||||||
|
HistoryVisibility.invited
|
||||||
|
.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'From the invitation');
|
||||||
|
expect(
|
||||||
|
HistoryVisibility.joined
|
||||||
|
.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'From joining');
|
||||||
|
expect(
|
||||||
|
HistoryVisibility.shared
|
||||||
|
.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'Visible for all participants');
|
||||||
|
expect(
|
||||||
|
HistoryVisibility.world_readable
|
||||||
|
.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'Visible for everyone');
|
||||||
|
expect(
|
||||||
|
GuestAccess.can_join.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'Guests can join');
|
||||||
|
expect(
|
||||||
|
GuestAccess.forbidden
|
||||||
|
.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'Guests are forbidden');
|
||||||
|
expect(JoinRules.invite.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'Invited users only');
|
||||||
|
expect(JoinRules.public.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'Anyone can join');
|
||||||
|
expect(JoinRules.private.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'private');
|
||||||
|
expect(JoinRules.knock.getLocalizedString(MatrixDefaultLocalizations()),
|
||||||
|
'knock');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
59
test/public_rooms_response_test.dart
Normal file
59
test/public_rooms_response_test.dart
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Zender & Kurtz GbR.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Christian Pauly <krille@famedly.com>
|
||||||
|
* Marcel Radzio <mtrnord@famedly.com>
|
||||||
|
*
|
||||||
|
* This file is part of famedlysdk.
|
||||||
|
*
|
||||||
|
* famedlysdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* famedlysdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
import 'fake_matrix_api.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
/// All Tests related to device keys
|
||||||
|
group('Public Rooms Response', () {
|
||||||
|
Client client;
|
||||||
|
test('Public Rooms Response', () async {
|
||||||
|
client = Client('testclient', debug: true);
|
||||||
|
client.httpClient = FakeMatrixApi();
|
||||||
|
|
||||||
|
await client.checkServer('https://fakeServer.notExisting');
|
||||||
|
final responseMap = {
|
||||||
|
'chunk': [
|
||||||
|
{
|
||||||
|
'aliases': ['#murrays:cheese.bar'],
|
||||||
|
'avatar_url': 'mxc://bleeker.street/CHEDDARandBRIE',
|
||||||
|
'guest_can_join': false,
|
||||||
|
'name': 'CHEESE',
|
||||||
|
'num_joined_members': 37,
|
||||||
|
'room_id': '1234',
|
||||||
|
'topic': 'Tasty tasty cheese',
|
||||||
|
'world_readable': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'next_batch': 'p190q',
|
||||||
|
'prev_batch': 'p1902',
|
||||||
|
'total_room_count_estimate': 115
|
||||||
|
};
|
||||||
|
final publicRoomsResponse =
|
||||||
|
PublicRoomsResponse.fromJson(responseMap, client);
|
||||||
|
await publicRoomsResponse.publicRooms.first.join();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
45
test/pusher_test.dart
Normal file
45
test/pusher_test.dart
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Zender & Kurtz GbR.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Christian Pauly <krille@famedly.com>
|
||||||
|
* Marcel Radzio <mtrnord@famedly.com>
|
||||||
|
*
|
||||||
|
* This file is part of famedlysdk.
|
||||||
|
*
|
||||||
|
* famedlysdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* famedlysdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import 'package:famedlysdk/src/utils/pusher.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
/// All Tests related to device keys
|
||||||
|
group('Pusher', () {
|
||||||
|
test('Pusher', () {
|
||||||
|
final rawPusher = {
|
||||||
|
'pushkey': 'Xp/MzCt8/9DcSNE9cuiaoT5Ac55job3TdLSSmtmYl4A=',
|
||||||
|
'kind': 'http',
|
||||||
|
'app_id': 'face.mcapp.appy.prod',
|
||||||
|
'app_display_name': 'Appy McAppface',
|
||||||
|
'device_display_name': "Alice's Phone",
|
||||||
|
'profile_tag': 'xyz',
|
||||||
|
'lang': 'en-US',
|
||||||
|
'data': {'url': 'https://example.com/_matrix/push/v1/notify'}
|
||||||
|
};
|
||||||
|
|
||||||
|
final pusher = Pusher.fromJson(rawPusher);
|
||||||
|
expect(pusher.toJson(), rawPusher);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
40
test/well_known_informations_test.dart
Normal file
40
test/well_known_informations_test.dart
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Zender & Kurtz GbR.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Christian Pauly <krille@famedly.com>
|
||||||
|
* Marcel Radzio <mtrnord@famedly.com>
|
||||||
|
*
|
||||||
|
* This file is part of famedlysdk.
|
||||||
|
*
|
||||||
|
* famedlysdk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* famedlysdk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
/// All Tests related to device keys
|
||||||
|
group('WellKnownInformations', () {
|
||||||
|
test('WellKnownInformations', () {
|
||||||
|
final json = {
|
||||||
|
'm.homeserver': {'base_url': 'https://matrix.example.com'},
|
||||||
|
'm.identity_server': {'base_url': 'https://identity.example.com'},
|
||||||
|
'org.example.custom.property': {
|
||||||
|
'app_url': 'https://custom.app.example.org'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
WellKnownInformations.fromJson(json);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue