forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove JSON codec from C++ client wrapper (flutter#17312)
The JSON codec is awkward to use in the wrapper (since the client has to build and link one of the JSON libraries to do so). Since it would be very cumbersome to wrap in a C API, and there's essentially no reason to use it instead of the standard codec, this removes it from the wrapper entirely. Since some system channels (internal to the engine) still use it, it's moved into common/cpp instead of being eliminated entirely. Internally we always use RapidJSON though, so the jsoncpp implementation is removed. Also adds some unit test coverage, since there wasn't any. Fixes flutter#30669
- Loading branch information
1 parent
ff62dec
commit 08ae3bb
Showing
21 changed files
with
239 additions
and
147 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
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
26 changes: 0 additions & 26 deletions
26
shell/platform/common/cpp/client_wrapper/include/flutter/json_type.h
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/shell/platform/common/cpp/json_message_codec.h" | ||
|
||
#include <limits> | ||
#include <map> | ||
#include <vector> | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace flutter { | ||
|
||
namespace { | ||
|
||
// Validates round-trip encoding and decoding of |value|. | ||
static void CheckEncodeDecode(const rapidjson::Document& value) { | ||
const JsonMessageCodec& codec = JsonMessageCodec::GetInstance(); | ||
auto encoded = codec.EncodeMessage(value); | ||
ASSERT_TRUE(encoded); | ||
auto decoded = codec.DecodeMessage(*encoded); | ||
EXPECT_EQ(value, *decoded); | ||
} | ||
|
||
} // namespace | ||
|
||
// Tests that a JSON document with various data types round-trips correctly. | ||
TEST(JsonMessageCodec, EncodeDecode) { | ||
rapidjson::Document array(rapidjson::kArrayType); | ||
auto& allocator = array.GetAllocator(); | ||
|
||
array.PushBack("string", allocator); | ||
|
||
rapidjson::Value map(rapidjson::kObjectType); | ||
map.AddMember("a", -7, allocator); | ||
map.AddMember("b", std::numeric_limits<int>::max(), allocator); | ||
map.AddMember("c", 3.14159, allocator); | ||
map.AddMember("d", true, allocator); | ||
map.AddMember("e", rapidjson::Value(), allocator); | ||
array.PushBack(map, allocator); | ||
|
||
CheckEncodeDecode(array); | ||
} | ||
|
||
} // namespace flutter |
Oops, something went wrong.