Merge branch 'license-fix-foobar-typo' into 'master'
[License] Replace 'foobar' with 'famedlysdk' in all Files. Closes #15 See merge request famedly/famedlysdk!11
This commit is contained in:
commit
c295841935
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
library famedlysdk;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:convert';
|
||||
|
@ -29,7 +29,6 @@ import './Room.dart';
|
|||
|
||||
/// A single Matrix event, e.g. a message in a chat.
|
||||
class Event {
|
||||
|
||||
/// The Matrix ID for this event in the format '$localpart:server.abc'.
|
||||
final String id;
|
||||
|
||||
|
@ -56,9 +55,12 @@ class Event {
|
|||
int status;
|
||||
|
||||
/// The json payload of the content. The content highly depends on the type.
|
||||
final Map<String,dynamic> content;
|
||||
final Map<String, dynamic> content;
|
||||
|
||||
Event(this.id, this.sender, this.time,{
|
||||
Event(
|
||||
this.id,
|
||||
this.sender,
|
||||
this.time, {
|
||||
this.room,
|
||||
this.stateKey,
|
||||
this.status = 2,
|
||||
|
@ -73,7 +75,7 @@ class Event {
|
|||
String get formattedText => content["formatted_body"] ?? "";
|
||||
|
||||
/// Use this to get the body.
|
||||
String getBody () {
|
||||
String getBody() {
|
||||
if (text != "") return text;
|
||||
if (formattedText != "") return formattedText;
|
||||
return "*** Unable to parse Content ***";
|
||||
|
@ -82,36 +84,52 @@ class Event {
|
|||
/// Get the real type.
|
||||
EventTypes get type {
|
||||
switch (environment) {
|
||||
case "m.room.avatar": return EventTypes.RoomAvatar;
|
||||
case "m.room.name": return EventTypes.RoomName;
|
||||
case "m.room.topic": return EventTypes.RoomTopic;
|
||||
case "m.room.Aliases": return EventTypes.RoomAliases;
|
||||
case "m.room.canonical_alias": return EventTypes.RoomCanonicalAlias;
|
||||
case "m.room.create": return EventTypes.RoomCreate;
|
||||
case "m.room.join_rules": return EventTypes.RoomJoinRules;
|
||||
case "m.room.member": return EventTypes.RoomMember;
|
||||
case "m.room.power_levels": return EventTypes.RoomPowerLevels;
|
||||
case "m.room.avatar":
|
||||
return EventTypes.RoomAvatar;
|
||||
case "m.room.name":
|
||||
return EventTypes.RoomName;
|
||||
case "m.room.topic":
|
||||
return EventTypes.RoomTopic;
|
||||
case "m.room.Aliases":
|
||||
return EventTypes.RoomAliases;
|
||||
case "m.room.canonical_alias":
|
||||
return EventTypes.RoomCanonicalAlias;
|
||||
case "m.room.create":
|
||||
return EventTypes.RoomCreate;
|
||||
case "m.room.join_rules":
|
||||
return EventTypes.RoomJoinRules;
|
||||
case "m.room.member":
|
||||
return EventTypes.RoomMember;
|
||||
case "m.room.power_levels":
|
||||
return EventTypes.RoomPowerLevels;
|
||||
case "m.room.message":
|
||||
switch(content["msgtype"] ?? "m.text") {
|
||||
case "m.text": return EventTypes.Text;
|
||||
case "m.notice": return EventTypes.Notice;
|
||||
case "m.emote": return EventTypes.Emote;
|
||||
case "m.image": return EventTypes.Image;
|
||||
case "m.video": return EventTypes.Video;
|
||||
case "m.audio": return EventTypes.Audio;
|
||||
case "m.file": return EventTypes.File;
|
||||
case "m.location": return EventTypes.Location;
|
||||
switch (content["msgtype"] ?? "m.text") {
|
||||
case "m.text":
|
||||
return EventTypes.Text;
|
||||
case "m.notice":
|
||||
return EventTypes.Notice;
|
||||
case "m.emote":
|
||||
return EventTypes.Emote;
|
||||
case "m.image":
|
||||
return EventTypes.Image;
|
||||
case "m.video":
|
||||
return EventTypes.Video;
|
||||
case "m.audio":
|
||||
return EventTypes.Audio;
|
||||
case "m.file":
|
||||
return EventTypes.File;
|
||||
case "m.location":
|
||||
return EventTypes.Location;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Generate a new Event object from a json string, mostly a table row.
|
||||
static Event fromJson(Map<String, dynamic> jsonObj, Room room) {
|
||||
Map<String,dynamic> content;
|
||||
Map<String, dynamic> content;
|
||||
try {
|
||||
content = json.decode(jsonObj["content_json"]);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
print("jsonObj decode of event content failed: ${e.toString()}");
|
||||
content = {};
|
||||
}
|
||||
|
@ -128,11 +146,10 @@ class Event {
|
|||
}
|
||||
|
||||
@Deprecated("Use [client.store.getEventList(Room room)] instead!")
|
||||
static Future<List<Event>> getEventList(Client matrix, Room room) async{
|
||||
static Future<List<Event>> getEventList(Client matrix, Room room) async {
|
||||
List<Event> eventList = await matrix.store.getEventList(room);
|
||||
return eventList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum EventTypes {
|
||||
|
@ -155,7 +172,7 @@ enum EventTypes {
|
|||
RoomAvatar,
|
||||
}
|
||||
|
||||
final Map<String,int> StatusTypes = {
|
||||
final Map<String, int> StatusTypes = {
|
||||
"ERROR": -1,
|
||||
"SENDING": 0,
|
||||
"SENT": 1,
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:famedlysdk/src/Client.dart';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:famedlysdk/src/responses/ErrorResponse.dart';
|
||||
|
|
|
@ -18,14 +18,13 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
/// Represents a special response from the Homeserver for errors.
|
||||
class ErrorResponse {
|
||||
|
||||
/// The unique identifier for this error.
|
||||
String errcode;
|
||||
|
||||
|
|
|
@ -18,13 +18,12 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/// Represents a new event (e.g. a message in a room) or an update for an
|
||||
/// already known event.
|
||||
class EventUpdate {
|
||||
|
||||
/// Usually 'timeline', 'state' or whatever.
|
||||
final String eventType;
|
||||
|
||||
|
|
|
@ -18,13 +18,12 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/// Represents a new room or an update for an
|
||||
/// already known room.
|
||||
class RoomUpdate {
|
||||
|
||||
/// All rooms have an idea in the format: !uniqueid:server.abc
|
||||
final String id;
|
||||
|
||||
|
|
|
@ -18,12 +18,11 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/// Represents a new global event like presence or account_data.
|
||||
class UserUpdate {
|
||||
|
||||
/// Usually 'presence', 'account_data' or whatever.
|
||||
final String eventType;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// TODO: localize this!
|
||||
|
@ -32,8 +32,7 @@ class ChatTime {
|
|||
/// Insert with a timestamp [ts] which represents the milliseconds since
|
||||
/// the Unix epoch.
|
||||
ChatTime(num ts) {
|
||||
if (ts != null)
|
||||
dateTime = DateTime.fromMillisecondsSinceEpoch(ts);
|
||||
if (ts != null) dateTime = DateTime.fromMillisecondsSinceEpoch(ts);
|
||||
}
|
||||
|
||||
/// Returns a ChatTime object which represents the current time.
|
||||
|
@ -51,12 +50,16 @@ class ChatTime {
|
|||
bool sameDay =
|
||||
sameYear && now.month == dateTime.month && now.day == dateTime.day;
|
||||
|
||||
bool sameWeek = sameYear && !sameDay && now.millisecondsSinceEpoch - dateTime.millisecondsSinceEpoch < 1000*60*60*24*7;
|
||||
bool sameWeek = sameYear &&
|
||||
!sameDay &&
|
||||
now.millisecondsSinceEpoch - dateTime.millisecondsSinceEpoch <
|
||||
1000 * 60 * 60 * 24 * 7;
|
||||
|
||||
if (sameDay) {
|
||||
return toTimeString();
|
||||
} else if (sameWeek) {
|
||||
switch (dateTime.weekday) { // TODO: Needs localization
|
||||
switch (dateTime.weekday) {
|
||||
// TODO: Needs localization
|
||||
case 1:
|
||||
return "Montag";
|
||||
case 2:
|
||||
|
@ -103,7 +106,8 @@ class ChatTime {
|
|||
operator ==(dynamic other) {
|
||||
if (other is ChatTime)
|
||||
return this.toTimeStamp() == other.toTimeStamp();
|
||||
else return false;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Two message events can belong to the same environment. That means that they
|
||||
|
@ -114,7 +118,8 @@ class ChatTime {
|
|||
/// Checks if two ChatTimes are close enough to belong to the same
|
||||
/// environment.
|
||||
bool sameEnvironment(ChatTime prevTime) {
|
||||
return toTimeStamp() - prevTime.toTimeStamp() < 1000*60*minutesBetweenEnvironments;
|
||||
return toTimeStamp() - prevTime.toTimeStamp() <
|
||||
1000 * 60 * minutesBetweenEnvironments;
|
||||
}
|
||||
|
||||
/// Returns a simple time String.
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:famedlysdk/src/Client.dart';
|
||||
|
|
|
@ -18,30 +18,29 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:famedlysdk/src/utils/ChatTime.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
/// All Tests related to the ChatTime
|
||||
group("ChatTime", () {
|
||||
|
||||
test("Comparing", () async {
|
||||
final int originServerTs = DateTime.now().millisecondsSinceEpoch - (ChatTime.minutesBetweenEnvironments-1)*1000*60;
|
||||
final int oldOriginServerTs = DateTime.now().millisecondsSinceEpoch - (ChatTime.minutesBetweenEnvironments+1)*1000*60;
|
||||
final int originServerTs = DateTime.now().millisecondsSinceEpoch -
|
||||
(ChatTime.minutesBetweenEnvironments - 1) * 1000 * 60;
|
||||
final int oldOriginServerTs = DateTime.now().millisecondsSinceEpoch -
|
||||
(ChatTime.minutesBetweenEnvironments + 1) * 1000 * 60;
|
||||
|
||||
final ChatTime chatTime = ChatTime(originServerTs);
|
||||
final ChatTime oldChatTime = ChatTime(oldOriginServerTs);
|
||||
final ChatTime nowTime = ChatTime.now();
|
||||
|
||||
expect(chatTime.toTimeStamp(), originServerTs);
|
||||
expect(nowTime.toTimeStamp()>chatTime.toTimeStamp(),true);
|
||||
expect(nowTime.sameEnvironment(chatTime),true);
|
||||
expect(nowTime.sameEnvironment(oldChatTime),false);
|
||||
expect(nowTime.toTimeStamp() > chatTime.toTimeStamp(), true);
|
||||
expect(nowTime.sameEnvironment(chatTime), true);
|
||||
expect(nowTime.sameEnvironment(oldChatTime), false);
|
||||
|
||||
expect(chatTime > oldChatTime, true);
|
||||
expect(chatTime < oldChatTime, false);
|
||||
|
@ -55,10 +54,10 @@ void main() {
|
|||
final int timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final ChatTime chatTime = ChatTime(timestamp);
|
||||
//expect(chatTime.toTimeString(),"05:36"); // This depends on the time and your timezone ;)
|
||||
expect(chatTime.toTimeString(),chatTime.toEventTimeString());
|
||||
expect(chatTime.toTimeString(), chatTime.toEventTimeString());
|
||||
|
||||
final ChatTime oldChatTime = ChatTime(156014498475);
|
||||
expect(oldChatTime.toString(),"11.12.1974");
|
||||
expect(oldChatTime.toString(), "11.12.1974");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:famedlysdk/src/responses/PushrulesResponse.dart';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:http/testing.dart';
|
||||
|
@ -95,13 +95,8 @@ class FakeMatrixApi extends MockClient {
|
|||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
{"set_tweak": "sound", "value": "default"},
|
||||
{"set_tweak": "highlight"}
|
||||
],
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
|
@ -111,18 +106,14 @@ class FakeMatrixApi extends MockClient {
|
|||
],
|
||||
"override": [
|
||||
{
|
||||
"actions": [
|
||||
"dont_notify"
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"conditions": [],
|
||||
"default": true,
|
||||
"enabled": false,
|
||||
"rule_id": ".m.rule.master"
|
||||
},
|
||||
{
|
||||
"actions": [
|
||||
"dont_notify"
|
||||
],
|
||||
"actions": ["dont_notify"],
|
||||
"conditions": [
|
||||
{
|
||||
"key": "content.msgtype",
|
||||
|
@ -141,14 +132,8 @@ class FakeMatrixApi extends MockClient {
|
|||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "ring"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
{"set_tweak": "sound", "value": "ring"},
|
||||
{"set_tweak": "highlight", "value": false}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
|
@ -164,18 +149,11 @@ class FakeMatrixApi extends MockClient {
|
|||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight"
|
||||
}
|
||||
{"set_tweak": "sound", "value": "default"},
|
||||
{"set_tweak": "highlight"}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"kind": "contains_display_name"
|
||||
}
|
||||
{"kind": "contains_display_name"}
|
||||
],
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
|
@ -184,20 +162,11 @@ class FakeMatrixApi extends MockClient {
|
|||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
{"set_tweak": "sound", "value": "default"},
|
||||
{"set_tweak": "highlight", "value": false}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"is": "2",
|
||||
"kind": "room_member_count"
|
||||
}
|
||||
{"is": "2", "kind": "room_member_count"}
|
||||
],
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
|
@ -206,14 +175,8 @@ class FakeMatrixApi extends MockClient {
|
|||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "sound",
|
||||
"value": "default"
|
||||
},
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
{"set_tweak": "sound", "value": "default"},
|
||||
{"set_tweak": "highlight", "value": false}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
|
@ -239,10 +202,7 @@ class FakeMatrixApi extends MockClient {
|
|||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
{"set_tweak": "highlight", "value": false}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
|
@ -258,10 +218,7 @@ class FakeMatrixApi extends MockClient {
|
|||
{
|
||||
"actions": [
|
||||
"notify",
|
||||
{
|
||||
"set_tweak": "highlight",
|
||||
"value": false
|
||||
}
|
||||
{"set_tweak": "highlight", "value": false}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
@ -26,20 +26,22 @@ import 'package:famedlysdk/src/Client.dart';
|
|||
import 'package:famedlysdk/src/utils/MxContent.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
|
||||
/// All Tests related to the MxContent
|
||||
group("MxContent", () {
|
||||
|
||||
test("Formatting", () async {
|
||||
Client client = Client("testclient");
|
||||
client.homeserver = "https://testserver.abc";
|
||||
final String mxc = "mxc://exampleserver.abc/abcdefghijklmn";
|
||||
final MxContent content = MxContent(mxc);
|
||||
|
||||
expect(content.getDownloadLink(client),"${client.homeserver}/_matrix/media/r0/download/exampleserver.abc/abcdefghijklmn");
|
||||
expect(content.getThumbnail(client, width: 50, height: 50),"${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=crop");
|
||||
expect(content.getThumbnail(client, width: 50, height: 50, method: ThumbnailMethod.scale),"${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale");
|
||||
expect(content.getDownloadLink(client),
|
||||
"${client.homeserver}/_matrix/media/r0/download/exampleserver.abc/abcdefghijklmn");
|
||||
expect(content.getThumbnail(client, width: 50, height: 50),
|
||||
"${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=crop");
|
||||
expect(
|
||||
content.getThumbnail(client,
|
||||
width: 50, height: 50, method: ThumbnailMethod.scale),
|
||||
"${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=scale");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with famedlysdk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
@ -28,14 +28,13 @@ void main() {
|
|||
/// All Tests related to the Event
|
||||
group("User", () {
|
||||
test("Create from json", () async {
|
||||
|
||||
final String id = "@alice:server.abc";
|
||||
final String membership = "join";
|
||||
final String displayName = "Alice";
|
||||
final String avatarUrl = "";
|
||||
final int powerLevel = 50;
|
||||
|
||||
final Map<String,dynamic> jsonObj = {
|
||||
final Map<String, dynamic> jsonObj = {
|
||||
"matrix_id": id,
|
||||
"displayname": displayName,
|
||||
"avatar_url": avatarUrl,
|
||||
|
@ -45,13 +44,12 @@ void main() {
|
|||
|
||||
User user = User.fromJson(jsonObj, null);
|
||||
|
||||
expect(user.id,id);
|
||||
expect(user.membership,membership);
|
||||
expect(user.displayName,displayName);
|
||||
expect(user.avatarUrl.mxc,avatarUrl);
|
||||
expect(user.powerLevel,powerLevel);
|
||||
expect(user.calcDisplayname(),displayName);
|
||||
|
||||
expect(user.id, id);
|
||||
expect(user.membership, membership);
|
||||
expect(user.displayName, displayName);
|
||||
expect(user.avatarUrl.mxc, avatarUrl);
|
||||
expect(user.powerLevel, powerLevel);
|
||||
expect(user.calcDisplayname(), displayName);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue