Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions commet/integration_test/benchmark/benchmark.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:integration_test/integration_test.dart';

import 'benchmarks/timeline_viewer_benchmark.dart' as timeline;

main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ void main() {

testWidgets('Timeline Viewer Test', (tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MaterialApp(
theme: ThemeDark.theme,
home: const Scaffold(
body: BenchmarkTimelineViewer(),
await tester.pumpWidget(
MaterialApp(
theme: ThemeDark.theme,
home: const Scaffold(body: BenchmarkTimelineViewer()),
),
));
);

await tester.pump(const Duration(seconds: 1));

Expand All @@ -25,18 +25,15 @@ void main() {

var reportKey = 'TimelineViewer Scrolling';

await binding.traceAction(
() async {
// Scroll until the item to be found appears.
await tester.scrollUntilVisible(
itemFinder,
50.0,
maxScrolls: 10000,
scrollable: listFinder,
);
},
reportKey: reportKey,
);
await binding.traceAction(() async {
// Scroll until the item to be found appears.
await tester.scrollUntilVisible(
itemFinder,
50.0,
maxScrolls: 10000,
scrollable: listFinder,
);
}, reportKey: reportKey);

binding.reportData?[reportKey]["extra_values"] = [
{
Expand All @@ -58,7 +55,7 @@ void main() {
"name": "$reportKey - Timeline Event Message Url Preview Build Count",
"value": BenchmarkValues.numTimelineUrlPreviewBuilt,
"unit": "Builds",
}
},
];
});
}
27 changes: 19 additions & 8 deletions commet/integration_test/extensions/common_flows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ extension CommonFlows on WidgetTester {
const String.fromEnvironment('HOMESERVER', defaultValue: "localhost");
String get username =>
const String.fromEnvironment('USER1_NAME', defaultValue: "alice");
String get password => const String.fromEnvironment('USER1_PW',
defaultValue: "AliceInWonderland");
String get password => const String.fromEnvironment(
'USER1_PW',
defaultValue: "AliceInWonderland",
);

String get userTwoName =>
const String.fromEnvironment('USER2_NAME', defaultValue: "bob");
Expand Down Expand Up @@ -81,8 +83,11 @@ extension CommonFlows on WidgetTester {

await pumpAndSettle();

await waitFor(() => app.clientManager.isLoggedIn(),
timeout: const Duration(seconds: 5), skipPumpAndSettle: true);
await waitFor(
() => app.clientManager.isLoggedIn(),
timeout: const Duration(seconds: 5),
skipPumpAndSettle: true,
);
expect(app.clientManager.isLoggedIn(), equals(true));
}

Expand All @@ -104,8 +109,11 @@ extension CommonFlows on WidgetTester {

await pumpAndSettle();

await waitFor(() => app.clientManager.isLoggedIn(),
timeout: const Duration(seconds: 5), skipPumpAndSettle: true);
await waitFor(
() => app.clientManager.isLoggedIn(),
timeout: const Duration(seconds: 5),
skipPumpAndSettle: true,
);
expect(app.clientManager.isLoggedIn(), equals(true));
}

Expand Down Expand Up @@ -137,8 +145,11 @@ extension CommonFlows on WidgetTester {
}

Future<void> openSettings(App app) async {
await dragUntilVisible(find.byKey(SideNavigationBar.settingsKey),
find.byType(SideNavigationBar), const Offset(0, 20));
await dragUntilVisible(
find.byKey(SideNavigationBar.settingsKey),
find.byType(SideNavigationBar),
const Offset(0, 20),
);

await tap(find.byKey(SideNavigationBar.settingsKey));

Expand Down
15 changes: 11 additions & 4 deletions commet/integration_test/matrix/change_space_name_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'package:tiamat/tiamat.dart' as tiamat;

import '../extensions/common_flows.dart';
import '../generated/l10n.dart';

Expand Down Expand Up @@ -47,8 +48,10 @@ void main() {

expect(space.displayName, equals(newName));

expect(find.widgetWithText(SpaceHeader, newName).evaluate().isNotEmpty,
isTrue);
expect(
find.widgetWithText(SpaceHeader, newName).evaluate().isNotEmpty,
isTrue,
);
});
}

Expand All @@ -63,7 +66,11 @@ Future<void> _openSpaceSettings(WidgetTester tester) async {
}

Future<void> _openSpaceAppearanceSettings(WidgetTester tester) async {
await tester.tap(find.widgetWithText(
tiamat.TextButton, T.current.labelSpaceAppearanceSettings));
await tester.tap(
find.widgetWithText(
tiamat.TextButton,
T.current.labelSpaceAppearanceSettings,
),
);
await tester.pumpAndSettle();
}
78 changes: 47 additions & 31 deletions commet/integration_test/matrix/create_space_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:commet/main.dart';
import 'package:integration_test/integration_test.dart';

import '../extensions/common_flows.dart';

import 'package:tiamat/tiamat.dart' as tiamat;

import '../generated/l10n.dart';
Expand All @@ -27,13 +28,16 @@ void main() {

var client = app.clientManager.clients.first;

expect(client.spaces.any((element) => element.displayName == spaceName),
isTrue);
expect(
client.spaces
.firstWhere((element) => element.displayName == spaceName)
.visibility,
equals(RoomVisibility.invite));
client.spaces.any((element) => element.displayName == spaceName),
isTrue,
);
expect(
client.spaces
.firstWhere((element) => element.displayName == spaceName)
.visibility,
equals(RoomVisibility.invite),
);

await app.clientManager.close();
await tester.clean();
Expand All @@ -52,44 +56,52 @@ void main() {

var client = app.clientManager.clients.first;

expect(client.spaces.any((element) => element.displayName == spaceName),
isTrue);
expect(
client.spaces
.firstWhere((element) => element.displayName == spaceName)
.visibility,
equals(RoomVisibility.public));
client.spaces.any((element) => element.displayName == spaceName),
isTrue,
);
expect(
client.spaces
.firstWhere((element) => element.displayName == spaceName)
.visibility,
equals(RoomVisibility.public),
);

await app.clientManager.close();
await tester.clean();
});
}

Future<void> _confirmCreateSpace(WidgetTester tester) async {
await tester.tap(find
.widgetWithText(tiamat.Button, T.current.promptConfirmSpaceCreation)
.first);
await tester.tap(
find
.widgetWithText(tiamat.Button, T.current.promptConfirmSpaceCreation)
.first,
);

await tester.pumpAndSettle();
}

Future<void> _setSpaceName(WidgetTester tester, String spaceName) async {
await tester.enterText(
find.widgetWithText(
tiamat.TextInput,
T.current.promptSpaceName,
),
spaceName);
find.widgetWithText(tiamat.TextInput, T.current.promptSpaceName),
spaceName,
);
}

Future<void> _setPrivate(WidgetTester tester) async {
await tester.tap(find.byType(tiamat.DropdownSelector<RoomVisibility>));

await tester.pumpAndSettle();

await tester.tap(find
.widgetWithText(tiamat.Text, T.current.spaceVisibilityPrivateExplanation)
.last);
await tester.tap(
find
.widgetWithText(
tiamat.Text,
T.current.spaceVisibilityPrivateExplanation,
)
.last,
);

await tester.pumpAndSettle();
}
Expand All @@ -99,9 +111,11 @@ Future<void> _setPublic(WidgetTester tester) async {

await tester.pumpAndSettle();

await tester.tap(find
.widgetWithText(tiamat.Text, T.current.spaceVisibilityPublicExplanation)
.last);
await tester.tap(
find
.widgetWithText(tiamat.Text, T.current.spaceVisibilityPublicExplanation)
.last,
);

await tester.pumpAndSettle();
}
Expand All @@ -114,16 +128,18 @@ Future<void> _openMenu(WidgetTester tester, App app) async {
await tester.pumpAndSettle();

await tester.dragUntilVisible(
find.widgetWithIcon(tiamat.ImageButton, Icons.add),
find.byType(SpaceSelector),
const Offset(0, 50));
find.widgetWithIcon(tiamat.ImageButton, Icons.add),
find.byType(SpaceSelector),
const Offset(0, 50),
);

await tester.tap(find.widgetWithIcon(tiamat.ImageButton, Icons.add));

await tester.pumpAndSettle();

await tester
.tap(find.widgetWithText(InkWell, T.current.promptCreateNewSpace));
await tester.tap(
find.widgetWithText(InkWell, T.current.promptCreateNewSpace),
);

await tester.pumpAndSettle();
}
55 changes: 33 additions & 22 deletions commet/integration_test/matrix/key_verification_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import 'package:commet/utils/common_strings.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:matrix/encryption/utils/key_verification.dart';

import '../extensions/wait_for.dart';
import '../extensions/common_flows.dart';
import '../generated/l10n.dart';

void main() {
testWidgets('Test emoji verification started from another device',
(WidgetTester tester) async {
testWidgets('Test emoji verification started from another device', (
WidgetTester tester,
) async {
var app = await tester.setupApp();
await tester.pumpWidget(app);
await tester.login(app);
Expand All @@ -22,31 +24,36 @@ void main() {
var client = matrixClient.getMatrixClient();

var devices = await otherClient.getDevices();
var device =
devices!.firstWhere((element) => element.deviceId == client.deviceID);
var device = devices!.firstWhere(
(element) => element.deviceId == client.deviceID,
);
expect(device, isNotNull);

var verification = await otherClient
.userDeviceKeys[otherClient.userID]!.deviceKeys[device.deviceId]!
.userDeviceKeys[otherClient.userID]!
.deviceKeys[device.deviceId]!
.startVerification();
verification.onUpdate = () {};

await tester.waitFor(
() => find.byType(MatrixVerificationPage).evaluate().isNotEmpty);
() => find.byType(MatrixVerificationPage).evaluate().isNotEmpty,
);

await tester.pumpAndSettle();

var button = find.descendant(
of: find.byType(MatrixVerificationPage),
matching:
find.widgetWithText(ElevatedButton, CommonStrings.promptAccept));
of: find.byType(MatrixVerificationPage),
matching: find.widgetWithText(ElevatedButton, CommonStrings.promptAccept),
);

await tester.tap(button);

await tester.waitFor(() => find
.widgetWithText(ElevatedButton, T.current.promptConfirmEmojiMatches)
.evaluate()
.isNotEmpty);
await tester.waitFor(
() => find
.widgetWithText(ElevatedButton, T.current.promptConfirmEmojiMatches)
.evaluate()
.isNotEmpty,
);

await tester.pumpAndSettle();

Expand All @@ -56,23 +63,27 @@ void main() {

await verification.acceptSas();

await tester.waitFor(() => find
.widgetWithText(ElevatedButton, T.current.messageVerificationComplete)
.evaluate()
.isNotEmpty);
await tester.waitFor(
() => find
.widgetWithText(ElevatedButton, T.current.messageVerificationComplete)
.evaluate()
.isNotEmpty,
);

await tester.pumpAndSettle();

expect(verification.isDone, equals(true));
expect(verification.state, equals(KeyVerificationState.done));

expect(
client.userDeviceKeys[client.userID]!.deviceKeys[otherClient.deviceID!],
isNotNull);
client.userDeviceKeys[client.userID]!.deviceKeys[otherClient.deviceID!],
isNotNull,
);
expect(
otherClient
.userDeviceKeys[otherClient.userID]!.deviceKeys[client.deviceID!],
isNotNull);
otherClient.userDeviceKeys[otherClient.userID]!.deviceKeys[client
.deviceID!],
isNotNull,
);

await app.clientManager.close();
await otherClient.dispose();
Expand Down
Loading
Loading