[License] Replace 'foobar' with 'famedlysdk' in all Files.

This commit is contained in:
Christian Pauly 2019-06-21 09:46:53 +02:00
parent 116a644a0e
commit 372c185228
20 changed files with 243 additions and 269 deletions

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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; library famedlysdk;

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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'; import 'dart:async';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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'; import 'dart:async';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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'; import 'dart:convert';
@ -29,7 +29,6 @@ import './Room.dart';
/// A single Matrix event, e.g. a message in a chat. /// A single Matrix event, e.g. a message in a chat.
class Event { class Event {
/// The Matrix ID for this event in the format '$localpart:server.abc'. /// The Matrix ID for this event in the format '$localpart:server.abc'.
final String id; final String id;
@ -56,9 +55,12 @@ class Event {
int status; int status;
/// The json payload of the content. The content highly depends on the type. /// 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.room,
this.stateKey, this.stateKey,
this.status = 2, this.status = 2,
@ -73,7 +75,7 @@ class Event {
String get formattedText => content["formatted_body"] ?? ""; String get formattedText => content["formatted_body"] ?? "";
/// Use this to get the body. /// Use this to get the body.
String getBody () { String getBody() {
if (text != "") return text; if (text != "") return text;
if (formattedText != "") return formattedText; if (formattedText != "") return formattedText;
return "*** Unable to parse Content ***"; return "*** Unable to parse Content ***";
@ -82,36 +84,52 @@ class Event {
/// Get the real type. /// Get the real type.
EventTypes get type { EventTypes get type {
switch (environment) { switch (environment) {
case "m.room.avatar": return EventTypes.RoomAvatar; case "m.room.avatar":
case "m.room.name": return EventTypes.RoomName; return EventTypes.RoomAvatar;
case "m.room.topic": return EventTypes.RoomTopic; case "m.room.name":
case "m.room.Aliases": return EventTypes.RoomAliases; return EventTypes.RoomName;
case "m.room.canonical_alias": return EventTypes.RoomCanonicalAlias; case "m.room.topic":
case "m.room.create": return EventTypes.RoomCreate; return EventTypes.RoomTopic;
case "m.room.join_rules": return EventTypes.RoomJoinRules; case "m.room.Aliases":
case "m.room.member": return EventTypes.RoomMember; return EventTypes.RoomAliases;
case "m.room.power_levels": return EventTypes.RoomPowerLevels; 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": case "m.room.message":
switch(content["msgtype"] ?? "m.text") { switch (content["msgtype"] ?? "m.text") {
case "m.text": return EventTypes.Text; case "m.text":
case "m.notice": return EventTypes.Notice; return EventTypes.Text;
case "m.emote": return EventTypes.Emote; case "m.notice":
case "m.image": return EventTypes.Image; return EventTypes.Notice;
case "m.video": return EventTypes.Video; case "m.emote":
case "m.audio": return EventTypes.Audio; return EventTypes.Emote;
case "m.file": return EventTypes.File; case "m.image":
case "m.location": return EventTypes.Location; 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. /// Generate a new Event object from a json string, mostly a table row.
static Event fromJson(Map<String, dynamic> jsonObj, Room room) { static Event fromJson(Map<String, dynamic> jsonObj, Room room) {
Map<String,dynamic> content; Map<String, dynamic> content;
try { try {
content = json.decode(jsonObj["content_json"]); content = json.decode(jsonObj["content_json"]);
} catch(e) { } catch (e) {
print("jsonObj decode of event content failed: ${e.toString()}"); print("jsonObj decode of event content failed: ${e.toString()}");
content = {}; content = {};
} }
@ -128,11 +146,10 @@ class Event {
} }
@Deprecated("Use [client.store.getEventList(Room room)] instead!") @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); List<Event> eventList = await matrix.store.getEventList(room);
return eventList; return eventList;
} }
} }
enum EventTypes { enum EventTypes {
@ -155,7 +172,7 @@ enum EventTypes {
RoomAvatar, RoomAvatar,
} }
final Map<String,int> StatusTypes = { final Map<String, int> StatusTypes = {
"ERROR": -1, "ERROR": -1,
"SENDING": 0, "SENDING": 0,
"SENT": 1, "SENT": 1,

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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'; import 'package:famedlysdk/src/Client.dart';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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'; import 'dart:async';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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'; import 'package:famedlysdk/src/responses/ErrorResponse.dart';

View file

@ -18,14 +18,13 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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; import 'package:http/http.dart' as http;
/// Represents a special response from the Homeserver for errors. /// Represents a special response from the Homeserver for errors.
class ErrorResponse { class ErrorResponse {
/// The unique identifier for this error. /// The unique identifier for this error.
String errcode; String errcode;

View file

@ -18,13 +18,12 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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 /// Represents a new event (e.g. a message in a room) or an update for an
/// already known event. /// already known event.
class EventUpdate { class EventUpdate {
/// Usually 'timeline', 'state' or whatever. /// Usually 'timeline', 'state' or whatever.
final String eventType; final String eventType;

View file

@ -18,13 +18,12 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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 /// Represents a new room or an update for an
/// already known room. /// already known room.
class RoomUpdate { class RoomUpdate {
/// All rooms have an idea in the format: !uniqueid:server.abc /// All rooms have an idea in the format: !uniqueid:server.abc
final String id; final String id;

View file

@ -18,12 +18,11 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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. /// Represents a new global event like presence or account_data.
class UserUpdate { class UserUpdate {
/// Usually 'presence', 'account_data' or whatever. /// Usually 'presence', 'account_data' or whatever.
final String eventType; final String eventType;

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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! // TODO: localize this!
@ -32,8 +32,7 @@ class ChatTime {
/// Insert with a timestamp [ts] which represents the milliseconds since /// Insert with a timestamp [ts] which represents the milliseconds since
/// the Unix epoch. /// the Unix epoch.
ChatTime(num ts) { ChatTime(num ts) {
if (ts != null) if (ts != null) dateTime = DateTime.fromMillisecondsSinceEpoch(ts);
dateTime = DateTime.fromMillisecondsSinceEpoch(ts);
} }
/// Returns a ChatTime object which represents the current time. /// Returns a ChatTime object which represents the current time.
@ -51,12 +50,16 @@ class ChatTime {
bool sameDay = bool sameDay =
sameYear && now.month == dateTime.month && now.day == dateTime.day; 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) { if (sameDay) {
return toTimeString(); return toTimeString();
} else if (sameWeek) { } else if (sameWeek) {
switch (dateTime.weekday) { // TODO: Needs localization switch (dateTime.weekday) {
// TODO: Needs localization
case 1: case 1:
return "Montag"; return "Montag";
case 2: case 2:
@ -103,7 +106,8 @@ class ChatTime {
operator ==(dynamic other) { operator ==(dynamic other) {
if (other is ChatTime) if (other is ChatTime)
return this.toTimeStamp() == other.toTimeStamp(); return this.toTimeStamp() == other.toTimeStamp();
else return false; else
return false;
} }
/// Two message events can belong to the same environment. That means that they /// 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 /// Checks if two ChatTimes are close enough to belong to the same
/// environment. /// environment.
bool sameEnvironment(ChatTime prevTime) { bool sameEnvironment(ChatTime prevTime) {
return toTimeStamp() - prevTime.toTimeStamp() < 1000*60*minutesBetweenEnvironments; return toTimeStamp() - prevTime.toTimeStamp() <
1000 * 60 * minutesBetweenEnvironments;
} }
/// Returns a simple time String. /// Returns a simple time String.

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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'; import 'package:famedlysdk/src/Client.dart';

View file

@ -18,30 +18,29 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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:flutter_test/flutter_test.dart';
import 'package:famedlysdk/src/utils/ChatTime.dart'; import 'package:famedlysdk/src/utils/ChatTime.dart';
void main() { void main() {
/// All Tests related to the ChatTime /// All Tests related to the ChatTime
group("ChatTime", () { group("ChatTime", () {
test("Comparing", () async { test("Comparing", () async {
final int originServerTs = DateTime.now().millisecondsSinceEpoch - (ChatTime.minutesBetweenEnvironments-1)*1000*60; final int originServerTs = DateTime.now().millisecondsSinceEpoch -
final int oldOriginServerTs = DateTime.now().millisecondsSinceEpoch - (ChatTime.minutesBetweenEnvironments+1)*1000*60; (ChatTime.minutesBetweenEnvironments - 1) * 1000 * 60;
final int oldOriginServerTs = DateTime.now().millisecondsSinceEpoch -
(ChatTime.minutesBetweenEnvironments + 1) * 1000 * 60;
final ChatTime chatTime = ChatTime(originServerTs); final ChatTime chatTime = ChatTime(originServerTs);
final ChatTime oldChatTime = ChatTime(oldOriginServerTs); final ChatTime oldChatTime = ChatTime(oldOriginServerTs);
final ChatTime nowTime = ChatTime.now(); final ChatTime nowTime = ChatTime.now();
expect(chatTime.toTimeStamp(), originServerTs); expect(chatTime.toTimeStamp(), originServerTs);
expect(nowTime.toTimeStamp()>chatTime.toTimeStamp(),true); expect(nowTime.toTimeStamp() > chatTime.toTimeStamp(), true);
expect(nowTime.sameEnvironment(chatTime),true); expect(nowTime.sameEnvironment(chatTime), true);
expect(nowTime.sameEnvironment(oldChatTime),false); expect(nowTime.sameEnvironment(oldChatTime), false);
expect(chatTime > oldChatTime, true); expect(chatTime > oldChatTime, true);
expect(chatTime < oldChatTime, false); expect(chatTime < oldChatTime, false);
@ -55,10 +54,10 @@ void main() {
final int timestamp = DateTime.now().millisecondsSinceEpoch; final int timestamp = DateTime.now().millisecondsSinceEpoch;
final ChatTime chatTime = ChatTime(timestamp); final ChatTime chatTime = ChatTime(timestamp);
//expect(chatTime.toTimeString(),"05:36"); // This depends on the time and your timezone ;) //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); final ChatTime oldChatTime = ChatTime(156014498475);
expect(oldChatTime.toString(),"11.12.1974"); expect(oldChatTime.toString(), "11.12.1974");
}); });
}); });
} }

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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'; import 'package:famedlysdk/src/responses/PushrulesResponse.dart';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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:flutter_test/flutter_test.dart';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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'; import 'package:http/testing.dart';
@ -95,13 +95,8 @@ class FakeMatrixApi extends MockClient {
{ {
"actions": [ "actions": [
"notify", "notify",
{ {"set_tweak": "sound", "value": "default"},
"set_tweak": "sound", {"set_tweak": "highlight"}
"value": "default"
},
{
"set_tweak": "highlight"
}
], ],
"default": true, "default": true,
"enabled": true, "enabled": true,
@ -111,18 +106,14 @@ class FakeMatrixApi extends MockClient {
], ],
"override": [ "override": [
{ {
"actions": [ "actions": ["dont_notify"],
"dont_notify"
],
"conditions": [], "conditions": [],
"default": true, "default": true,
"enabled": false, "enabled": false,
"rule_id": ".m.rule.master" "rule_id": ".m.rule.master"
}, },
{ {
"actions": [ "actions": ["dont_notify"],
"dont_notify"
],
"conditions": [ "conditions": [
{ {
"key": "content.msgtype", "key": "content.msgtype",
@ -141,14 +132,8 @@ class FakeMatrixApi extends MockClient {
{ {
"actions": [ "actions": [
"notify", "notify",
{ {"set_tweak": "sound", "value": "ring"},
"set_tweak": "sound", {"set_tweak": "highlight", "value": false}
"value": "ring"
},
{
"set_tweak": "highlight",
"value": false
}
], ],
"conditions": [ "conditions": [
{ {
@ -164,18 +149,11 @@ class FakeMatrixApi extends MockClient {
{ {
"actions": [ "actions": [
"notify", "notify",
{ {"set_tweak": "sound", "value": "default"},
"set_tweak": "sound", {"set_tweak": "highlight"}
"value": "default"
},
{
"set_tweak": "highlight"
}
], ],
"conditions": [ "conditions": [
{ {"kind": "contains_display_name"}
"kind": "contains_display_name"
}
], ],
"default": true, "default": true,
"enabled": true, "enabled": true,
@ -184,20 +162,11 @@ class FakeMatrixApi extends MockClient {
{ {
"actions": [ "actions": [
"notify", "notify",
{ {"set_tweak": "sound", "value": "default"},
"set_tweak": "sound", {"set_tweak": "highlight", "value": false}
"value": "default"
},
{
"set_tweak": "highlight",
"value": false
}
], ],
"conditions": [ "conditions": [
{ {"is": "2", "kind": "room_member_count"}
"is": "2",
"kind": "room_member_count"
}
], ],
"default": true, "default": true,
"enabled": true, "enabled": true,
@ -206,14 +175,8 @@ class FakeMatrixApi extends MockClient {
{ {
"actions": [ "actions": [
"notify", "notify",
{ {"set_tweak": "sound", "value": "default"},
"set_tweak": "sound", {"set_tweak": "highlight", "value": false}
"value": "default"
},
{
"set_tweak": "highlight",
"value": false
}
], ],
"conditions": [ "conditions": [
{ {
@ -239,10 +202,7 @@ class FakeMatrixApi extends MockClient {
{ {
"actions": [ "actions": [
"notify", "notify",
{ {"set_tweak": "highlight", "value": false}
"set_tweak": "highlight",
"value": false
}
], ],
"conditions": [ "conditions": [
{ {
@ -258,10 +218,7 @@ class FakeMatrixApi extends MockClient {
{ {
"actions": [ "actions": [
"notify", "notify",
{ {"set_tweak": "highlight", "value": false}
"set_tweak": "highlight",
"value": false
}
], ],
"conditions": [ "conditions": [
{ {

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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:flutter_test/flutter_test.dart';
@ -26,20 +26,22 @@ import 'package:famedlysdk/src/Client.dart';
import 'package:famedlysdk/src/utils/MxContent.dart'; import 'package:famedlysdk/src/utils/MxContent.dart';
void main() { void main() {
/// All Tests related to the MxContent /// All Tests related to the MxContent
group("MxContent", () { group("MxContent", () {
test("Formatting", () async { test("Formatting", () async {
Client client = Client("testclient"); Client client = Client("testclient");
client.homeserver = "https://testserver.abc"; client.homeserver = "https://testserver.abc";
final String mxc = "mxc://exampleserver.abc/abcdefghijklmn"; final String mxc = "mxc://exampleserver.abc/abcdefghijklmn";
final MxContent content = MxContent(mxc); final MxContent content = MxContent(mxc);
expect(content.getDownloadLink(client),"${client.homeserver}/_matrix/media/r0/download/exampleserver.abc/abcdefghijklmn"); expect(content.getDownloadLink(client),
expect(content.getThumbnail(client, width: 50, height: 50),"${client.homeserver}/_matrix/media/r0/thumbnail/exampleserver.abc/abcdefghijklmn?width=50&height=50&method=crop"); "${client.homeserver}/_matrix/media/r0/download/exampleserver.abc/abcdefghijklmn");
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.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");
}); });
}); });
} }

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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:flutter_test/flutter_test.dart';

View file

@ -18,7 +18,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * 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:flutter_test/flutter_test.dart';
@ -28,14 +28,13 @@ void main() {
/// All Tests related to the Event /// All Tests related to the Event
group("User", () { group("User", () {
test("Create from json", () async { test("Create from json", () async {
final String id = "@alice:server.abc"; final String id = "@alice:server.abc";
final String membership = "join"; final String membership = "join";
final String displayName = "Alice"; final String displayName = "Alice";
final String avatarUrl = ""; final String avatarUrl = "";
final int powerLevel = 50; final int powerLevel = 50;
final Map<String,dynamic> jsonObj = { final Map<String, dynamic> jsonObj = {
"matrix_id": id, "matrix_id": id,
"displayname": displayName, "displayname": displayName,
"avatar_url": avatarUrl, "avatar_url": avatarUrl,
@ -45,13 +44,12 @@ void main() {
User user = User.fromJson(jsonObj, null); User user = User.fromJson(jsonObj, null);
expect(user.id,id); expect(user.id, id);
expect(user.membership,membership); expect(user.membership, membership);
expect(user.displayName,displayName); expect(user.displayName, displayName);
expect(user.avatarUrl.mxc,avatarUrl); expect(user.avatarUrl.mxc, avatarUrl);
expect(user.powerLevel,powerLevel); expect(user.powerLevel, powerLevel);
expect(user.calcDisplayname(),displayName); expect(user.calcDisplayname(), displayName);
}); });
}); });
} }