mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Removes unnecessary error message: "Invalid read in StandardCodecByteStreamReader" for cpp BasicMessageChannel (flutter/engine#26956)
This commit is contained in:
parent
0821f23495
commit
487b8743cb
@ -318,6 +318,9 @@ StandardMessageCodec::~StandardMessageCodec() = default;
|
||||
std::unique_ptr<EncodableValue> StandardMessageCodec::DecodeMessageInternal(
|
||||
const uint8_t* binary_message,
|
||||
size_t message_size) const {
|
||||
if (!binary_message) {
|
||||
return std::make_unique<EncodableValue>();
|
||||
}
|
||||
ByteBufferStreamReader stream(binary_message, message_size);
|
||||
return std::make_unique<EncodableValue>(serializer_->ReadValue(&stream));
|
||||
}
|
||||
|
||||
@ -8,10 +8,23 @@
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/shell/platform/common/client_wrapper/testing/test_codec_extensions.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
namespace {
|
||||
|
||||
class MockStandardCodecSerializer : public StandardCodecSerializer {
|
||||
public:
|
||||
MOCK_CONST_METHOD2(WriteValue,
|
||||
void(const EncodableValue& value,
|
||||
ByteStreamWriter* stream));
|
||||
MOCK_CONST_METHOD2(ReadValueOfType,
|
||||
EncodableValue(uint8_t type, ByteStreamReader* stream));
|
||||
};
|
||||
} // namespace
|
||||
|
||||
// Validates round-trip encoding and decoding of |value|, and checks that the
|
||||
// encoded value matches |expected_encoding|.
|
||||
//
|
||||
@ -68,6 +81,18 @@ TEST(StandardMessageCodec, CanEncodeAndDecodeNull) {
|
||||
CheckEncodeDecode(EncodableValue(), bytes);
|
||||
}
|
||||
|
||||
TEST(StandardMessageCodec, CanDecodeEmptyBytesAsNullWithoutCallingSerializer) {
|
||||
std::vector<uint8_t> bytes = {};
|
||||
const MockStandardCodecSerializer serializer;
|
||||
const StandardMessageCodec& codec =
|
||||
StandardMessageCodec::GetInstance(&serializer);
|
||||
|
||||
auto decoded = codec.DecodeMessage(bytes);
|
||||
|
||||
EXPECT_EQ(EncodableValue(), *decoded);
|
||||
EXPECT_CALL(serializer, ReadValueOfType(::testing::_, ::testing::_)).Times(0);
|
||||
}
|
||||
|
||||
TEST(StandardMessageCodec, CanEncodeAndDecodeTrue) {
|
||||
std::vector<uint8_t> bytes = {0x01};
|
||||
CheckEncodeDecode(EncodableValue(true), bytes);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user