-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix use incorrect length value in RtmClientImplOverride.publish/…
…StreamChannelImpl.publishTopicMessage
- Loading branch information
1 parent
985c67a
commit bcf0a38
Showing
8 changed files
with
370 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
test_shard/integration_test_app/test/agora_rtm_client_impl_override_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'dart:convert'; | ||
import 'dart:typed_data' show Uint8List; | ||
|
||
import 'package:agora_rtm/agora_rtm.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:agora_rtm/src/bindings/agora_rtm_client_impl_override.dart' | ||
as agora_rtm_client_impl; | ||
|
||
import 'fake_iris_method_channel.dart'; | ||
|
||
void main() { | ||
test('RtmClientImplOverride.publish', () { | ||
FakeIrisMethodChannel irisMethodChannel = FakeIrisMethodChannel(); | ||
agora_rtm_client_impl.RtmClientImplOverride rtmClientImplOverride = | ||
agora_rtm_client_impl.RtmClientImplOverride.create(irisMethodChannel); | ||
const message = 'hello'; | ||
final messageUint8List = Uint8List.fromList(utf8.encode(message)); | ||
|
||
rtmClientImplOverride.publish( | ||
channelName: '123', | ||
message: message, | ||
length: 5, | ||
option: const PublishOptions()); | ||
|
||
final methodCall = irisMethodChannel.methodCallQueue[0]; | ||
final paramsMap = jsonDecode(methodCall.params); | ||
expect(paramsMap['length'], messageUint8List.length); | ||
expect(methodCall.buffers![0], messageUint8List); | ||
}); | ||
|
||
test('RtmClientImplOverride.publishBinaryMessage', () { | ||
FakeIrisMethodChannel irisMethodChannel = FakeIrisMethodChannel(); | ||
agora_rtm_client_impl.RtmClientImplOverride rtmClientImplOverride = | ||
agora_rtm_client_impl.RtmClientImplOverride.create(irisMethodChannel); | ||
const message = 'hello'; | ||
final messageUint8List = Uint8List.fromList(utf8.encode(message)); | ||
|
||
rtmClientImplOverride.publishBinaryMessage( | ||
channelName: '123', | ||
message: messageUint8List, | ||
length: messageUint8List.length, | ||
option: const PublishOptions()); | ||
|
||
final methodCall = irisMethodChannel.methodCallQueue[0]; | ||
final paramsMap = jsonDecode(methodCall.params); | ||
expect(paramsMap['length'], messageUint8List.length); | ||
expect(methodCall.buffers![0], messageUint8List); | ||
}); | ||
} |
49 changes: 49 additions & 0 deletions
49
test_shard/integration_test_app/test/agora_stream_channel_impl_override_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'dart:convert'; | ||
import 'dart:typed_data' show Uint8List; | ||
|
||
import 'package:agora_rtm/agora_rtm.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:agora_rtm/src/bindings/agora_stream_channel_impl_override.dart' | ||
as agora_stream_channel_impl; | ||
|
||
import 'fake_iris_method_channel.dart'; | ||
|
||
void main() { | ||
test('StreamChannelImpl.publishTopicMessage', () { | ||
FakeIrisMethodChannel irisMethodChannel = FakeIrisMethodChannel(); | ||
agora_stream_channel_impl.StreamChannelImpl streamChannelImpl = | ||
agora_stream_channel_impl.StreamChannelImpl(irisMethodChannel, '123'); | ||
const message = 'hello'; | ||
final messageUint8List = Uint8List.fromList(utf8.encode(message)); | ||
|
||
streamChannelImpl.publishTopicMessage( | ||
topic: '123', | ||
message: message, | ||
length: 5, | ||
option: const TopicMessageOptions()); | ||
|
||
final methodCall = irisMethodChannel.methodCallQueue[0]; | ||
final paramsMap = jsonDecode(methodCall.params); | ||
expect(paramsMap['length'], messageUint8List.length); | ||
expect(methodCall.buffers![0], messageUint8List); | ||
}); | ||
|
||
test('StreamChannelImpl.publishBinaryMessage', () { | ||
FakeIrisMethodChannel irisMethodChannel = FakeIrisMethodChannel(); | ||
agora_stream_channel_impl.StreamChannelImpl streamChannelImpl = | ||
agora_stream_channel_impl.StreamChannelImpl(irisMethodChannel, '123'); | ||
const message = 'hello'; | ||
final messageUint8List = Uint8List.fromList(utf8.encode(message)); | ||
|
||
streamChannelImpl.publishBinaryMessage( | ||
topic: '123', | ||
message: messageUint8List, | ||
length: messageUint8List.length, | ||
option: const TopicMessageOptions()); | ||
|
||
final methodCall = irisMethodChannel.methodCallQueue[0]; | ||
final paramsMap = jsonDecode(methodCall.params); | ||
expect(paramsMap['length'], messageUint8List.length); | ||
expect(methodCall.buffers![0], messageUint8List); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.