Skip to content

Commit

Permalink
Strengthen json string comparisons (flutter#17425)
Browse files Browse the repository at this point in the history
Make the test robust even if the json map reorders its keys.
  • Loading branch information
liyuqian authored Mar 31, 2020
1 parent 807ca85 commit 70b12fa
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions shell/common/shell_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1162,10 +1162,14 @@ TEST_F(ShellTest, OnServiceProtocolGetSkSLsWorks) {
document.Accept(writer);
DestroyShell(std::move(shell));

// Base64 encoding of x, y are eQ, eA.
ASSERT_STREQ(
buffer.GetString(),
"{\"type\":\"GetSkSLs\",\"SkSLs\":{\"II\":\"eQ==\",\"IE\":\"eA==\"}}");
const std::string expected_json1 =
"{\"type\":\"GetSkSLs\",\"SkSLs\":{\"II\":\"eQ==\",\"IE\":\"eA==\"}}";
const std::string expected_json2 =
"{\"type\":\"GetSkSLs\",\"SkSLs\":{\"IE\":\"eA==\",\"II\":\"eQ==\"}}";
bool json_is_expected = (expected_json1 == buffer.GetString()) ||
(expected_json2 == buffer.GetString());
ASSERT_TRUE(json_is_expected) << buffer.GetString() << " is not equal to "
<< expected_json1 << " or " << expected_json2;

// Cleanup files
fml::FileVisitor recursive_cleanup = [&recursive_cleanup](
Expand Down

0 comments on commit 70b12fa

Please sign in to comment.