From 6464f4eb9717775bc93ff724011da286c5b167b8 Mon Sep 17 00:00:00 2001 From: liyuqian Date: Tue, 31 Mar 2020 15:02:26 -0700 Subject: [PATCH] Strengthen json string comparisons (flutter/engine#17425) Make the test robust even if the json map reorders its keys. --- engine/src/flutter/shell/common/shell_unittests.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/common/shell_unittests.cc b/engine/src/flutter/shell/common/shell_unittests.cc index 96308c408b..8a7bd5d51d 100644 --- a/engine/src/flutter/shell/common/shell_unittests.cc +++ b/engine/src/flutter/shell/common/shell_unittests.cc @@ -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](