@@ -118,8 +118,9 @@ void main() {
|
||||
final clientState = MockClientState();
|
||||
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.totalUnreadCount).thenAnswer((_) => 0);
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(0));
|
||||
.thenAnswer((_) => Stream.value(0));
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
||||
@@ -34,6 +34,7 @@ void main() {
|
||||
.thenAnswer((_) => Stream.value(ConnectionStatus.connected));
|
||||
when(() => channelState.unreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => clientState.totalUnreadCount).thenAnswer((i) => 1);
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
when(() => channelState.membersStream).thenAnswer((i) => Stream.value([
|
||||
@@ -109,6 +110,7 @@ void main() {
|
||||
.thenAnswer((_) => Stream.value(ConnectionStatus.disconnected));
|
||||
when(() => client.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.disconnected);
|
||||
when(() => clientState.totalUnreadCount).thenAnswer((i) => 1);
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
|
||||
@@ -171,6 +173,7 @@ void main() {
|
||||
]);
|
||||
when(() => client.wsConnectionStatusStream)
|
||||
.thenAnswer((_) => Stream.value(ConnectionStatus.connecting));
|
||||
when(() => clientState.totalUnreadCount).thenAnswer((i) => 1);
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
|
||||
@@ -375,6 +378,7 @@ void main() {
|
||||
]);
|
||||
when(() => client.wsConnectionStatusStream)
|
||||
.thenAnswer((_) => Stream.value(ConnectionStatus.connecting));
|
||||
when(() => clientState.totalUnreadCount).thenAnswer((i) => 1);
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -552,10 +552,8 @@ void main() {
|
||||
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
|
||||
when(() => client.flagMessage(any())).thenThrow(ApiError(
|
||||
'{}',
|
||||
500,
|
||||
));
|
||||
when(() => client.flagMessage(any()))
|
||||
.thenThrow(StreamChatNetworkError(ChatErrorCode.internalSystemError));
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
@@ -609,10 +607,8 @@ void main() {
|
||||
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
|
||||
when(() => client.flagMessage(any())).thenThrow(ApiError(
|
||||
'{"code":4}',
|
||||
400,
|
||||
));
|
||||
when(() => client.flagMessage(any()))
|
||||
.thenThrow(StreamChatNetworkError(ChatErrorCode.inputError));
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
@@ -719,10 +715,8 @@ void main() {
|
||||
|
||||
when(() => client.state).thenReturn(clientState);
|
||||
when(() => clientState.user).thenReturn(OwnUser(id: 'user-id'));
|
||||
when(() => channel.deleteMessage(any())).thenThrow(ApiError(
|
||||
'{}',
|
||||
500,
|
||||
));
|
||||
when(() => channel.deleteMessage(any()))
|
||||
.thenThrow(StreamChatNetworkError(ChatErrorCode.internalSystemError));
|
||||
|
||||
final themeData = ThemeData();
|
||||
final streamTheme = StreamChatThemeData.fromTheme(themeData);
|
||||
|
||||
@@ -45,6 +45,7 @@ void main() {
|
||||
]);
|
||||
when(() => client.wsConnectionStatusStream)
|
||||
.thenAnswer((_) => Stream.value(ConnectionStatus.connecting));
|
||||
when(() => clientState.totalUnreadCount).thenAnswer((i) => 1);
|
||||
when(() => clientState.totalUnreadCountStream)
|
||||
.thenAnswer((i) => Stream.value(1));
|
||||
|
||||
|
||||
@@ -300,7 +300,9 @@ void main() {
|
||||
when(() => mockChannel.state.isUpToDate).thenReturn(false);
|
||||
when(() => mockChannel.initialized).thenAnswer((_) async => true);
|
||||
when(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
messagesPagination: any(named: 'messagesPagination'),
|
||||
preferOffline: any(named: 'preferOffline'),
|
||||
|
||||
@@ -165,7 +165,9 @@ void main() {
|
||||
when(() => mockChannel.initialized).thenAnswer((_) async => true);
|
||||
final messages = _generateMessages();
|
||||
when(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: any(named: 'messagesPagination'),
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
@@ -183,7 +185,9 @@ void main() {
|
||||
|
||||
verify(() => mockChannel.initialized).called(1);
|
||||
verify(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: any(named: 'messagesPagination'),
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
@@ -228,7 +232,9 @@ void main() {
|
||||
final messages = _generateMessages();
|
||||
|
||||
when(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: beforePagination,
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
@@ -236,7 +242,9 @@ void main() {
|
||||
)).thenAnswer((_) async => ChannelState(messages: messages));
|
||||
|
||||
when(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: afterPagination,
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
@@ -259,7 +267,9 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
verify(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: beforePagination,
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
@@ -267,7 +277,9 @@ void main() {
|
||||
)).called(1);
|
||||
|
||||
verify(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: afterPagination,
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
@@ -285,7 +297,9 @@ void main() {
|
||||
);
|
||||
|
||||
when(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: updatedBeforePagination,
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
@@ -293,7 +307,9 @@ void main() {
|
||||
)).thenAnswer((_) async => ChannelState(messages: messages));
|
||||
|
||||
when(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: updatedAfterPagination,
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
@@ -303,7 +319,9 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
verify(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: updatedBeforePagination,
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
@@ -311,7 +329,9 @@ void main() {
|
||||
)).called(1);
|
||||
|
||||
verify(() => mockChannel.query(
|
||||
options: any(named: 'options'),
|
||||
state: any(named: 'state'),
|
||||
watch: any(named: 'watch'),
|
||||
presence: any(named: 'presence'),
|
||||
messagesPagination: updatedAfterPagination,
|
||||
membersPagination: any(named: 'membersPagination'),
|
||||
watchersPagination: any(named: 'watchersPagination'),
|
||||
|
||||
@@ -227,7 +227,7 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'didChangeAppLifecycleState should not call client.connect() '
|
||||
'didChangeAppLifecycleState should not call client.openConnection() '
|
||||
'if connection is not available in case the '
|
||||
'widget lifestyle changes to AppLifecycleState.resume',
|
||||
(tester) async {
|
||||
@@ -238,8 +238,8 @@ void main() {
|
||||
|
||||
final event = Event();
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.connect()).thenAnswer((_) async => event);
|
||||
when(() => mockClient.disconnect()).thenAnswer((_) async => null);
|
||||
when(() => mockClient.openConnection()).thenAnswer((_) async => event);
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async => null);
|
||||
when(() => mockClient.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.disconnected);
|
||||
|
||||
@@ -267,7 +267,7 @@ void main() {
|
||||
streamChatCoreState
|
||||
.didChangeAppLifecycleState(AppLifecycleState.resumed);
|
||||
|
||||
verifyNever(() => mockClient.connect());
|
||||
verifyNever(() => mockClient.openConnection());
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -327,8 +327,8 @@ void main() {
|
||||
|
||||
final event = Event();
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.connect()).thenAnswer((_) async => event);
|
||||
when(() => mockClient.disconnect()).thenAnswer((_) async => null);
|
||||
when(() => mockClient.openConnection()).thenAnswer((_) async => event);
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async => null);
|
||||
when(() => mockClient.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.disconnected);
|
||||
|
||||
@@ -348,7 +348,7 @@ void main() {
|
||||
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
verify(() => mockClient.connect()).called(1);
|
||||
verify(() => mockClient.openConnection()).called(1);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -376,8 +376,8 @@ void main() {
|
||||
|
||||
final event = Event();
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.connect()).thenAnswer((_) async => event);
|
||||
when(mockClient.disconnect).thenAnswer((_) async => null);
|
||||
when(() => mockClient.openConnection()).thenAnswer((_) async => event);
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async => null);
|
||||
when(() => mockClient.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.connected);
|
||||
|
||||
@@ -385,7 +385,7 @@ void main() {
|
||||
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
verify(() => mockClient.disconnect()).called(1);
|
||||
verify(() => mockClient.closeConnection()).called(1);
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -402,8 +402,8 @@ void main() {
|
||||
|
||||
final event = Event();
|
||||
when(() => mockClient.on()).thenAnswer((_) => Stream.value(event));
|
||||
when(() => mockClient.connect()).thenAnswer((_) async => event);
|
||||
when(() => mockClient.disconnect()).thenAnswer((_) async => null);
|
||||
when(() => mockClient.openConnection()).thenAnswer((_) async => event);
|
||||
when(() => mockClient.closeConnection()).thenAnswer((_) async => null);
|
||||
when(() => mockClient.wsConnectionStatus)
|
||||
.thenReturn(ConnectionStatus.disconnected);
|
||||
|
||||
@@ -432,7 +432,7 @@ void main() {
|
||||
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
|
||||
verifyNever(() => mockClient.disconnect());
|
||||
verifyNever(() => mockClient.closeConnection());
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||