From e722bba483c7c6b52022fe868fcb41ffd3f14b99 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Tue, 16 Apr 2019 22:37:39 -0700 Subject: [PATCH] Add desktop shell unittests to test script (flutter/engine#8600) Builds the unit test on all platforms, and adds them to the aggregate test script. --- engine/src/flutter/BUILD.gn | 9 ++----- .../common/cpp/client_wrapper/BUILD.gn | 2 ++ .../encodable_value_unittests.cc | 25 ++++++++++--------- .../standard_message_codec_unittests.cc | 2 +- .../platform/glfw/client_wrapper/BUILD.gn | 2 ++ engine/src/flutter/testing/run_tests.sh | 6 +++++ 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/engine/src/flutter/BUILD.gn b/engine/src/flutter/BUILD.gn index 2e7cc0fa71e..1ae4a19c648 100644 --- a/engine/src/flutter/BUILD.gn +++ b/engine/src/flutter/BUILD.gn @@ -49,20 +49,15 @@ group("flutter") { "$flutter_root/fml:fml_unittests", "$flutter_root/runtime:runtime_unittests", "$flutter_root/shell/common:shell_unittests", + "$flutter_root/shell/platform/common/cpp/client_wrapper:client_wrapper_unittests", "$flutter_root/shell/platform/embedder:embedder_unittests", + "$flutter_root/shell/platform/glfw/client_wrapper:client_wrapper_glfw_unittests", "$flutter_root/third_party/txt:txt_unittests", ] if (!is_win) { public_deps += [ "$flutter_root/shell/common:shell_benchmarks" ] } - - if (is_linux) { - public_deps += [ - "$flutter_root/shell/platform/common/cpp/client_wrapper:client_wrapper_unittests", - "$flutter_root/shell/platform/glfw/client_wrapper:client_wrapper_glfw_unittests", - ] - } } } diff --git a/engine/src/flutter/shell/platform/common/cpp/client_wrapper/BUILD.gn b/engine/src/flutter/shell/platform/common/cpp/client_wrapper/BUILD.gn index 095877364b3..4028b76650e 100644 --- a/engine/src/flutter/shell/platform/common/cpp/client_wrapper/BUILD.gn +++ b/engine/src/flutter/shell/platform/common/cpp/client_wrapper/BUILD.gn @@ -68,6 +68,8 @@ source_set("client_wrapper_library_stubs") { "testing/stub_flutter_api.h", ] + defines = [ "FLUTTER_DESKTOP_LIBRARY" ] + public_deps = [ "$flutter_root/shell/platform/common/cpp:common_cpp_library_headers", ] diff --git a/engine/src/flutter/shell/platform/common/cpp/client_wrapper/encodable_value_unittests.cc b/engine/src/flutter/shell/platform/common/cpp/client_wrapper/encodable_value_unittests.cc index 6784fa4b775..82ec96d0f88 100644 --- a/engine/src/flutter/shell/platform/common/cpp/client_wrapper/encodable_value_unittests.cc +++ b/engine/src/flutter/shell/platform/common/cpp/client_wrapper/encodable_value_unittests.cc @@ -59,7 +59,7 @@ TEST(EncodableValueTest, LongValueFromInt) { } TEST(EncodableValueTest, Long) { - EncodableValue value(42l); + EncodableValue value(INT64_C(42)); VerifyType(value, EncodableValue::Type::kLong); EXPECT_EQ(value.LongValue(), 42); @@ -170,7 +170,7 @@ TEST(EncodableValueTest, List) { TEST(EncodableValueTest, Map) { EncodableMap encodables = { {EncodableValue(), EncodableValue(std::vector{1, 2, 3})}, - {EncodableValue(1), EncodableValue(10000l)}, + {EncodableValue(1), EncodableValue(INT64_C(10000))}, {EncodableValue("two"), EncodableValue(7)}, }; EncodableValue value(encodables); @@ -178,7 +178,7 @@ TEST(EncodableValueTest, Map) { EncodableMap& map_value = value.MapValue(); EXPECT_EQ(map_value[EncodableValue()].IsIntList(), true); - EXPECT_EQ(map_value[EncodableValue(1)].LongValue(), 10000l); + EXPECT_EQ(map_value[EncodableValue(1)].LongValue(), INT64_C(10000)); EXPECT_EQ(map_value[EncodableValue("two")].IntValue(), 7); // Ensure that it's a modifiable copy of the original map. @@ -192,7 +192,8 @@ TEST(EncodableValueTest, EmptyTypeConstructor) { EXPECT_TRUE(EncodableValue(EncodableValue::Type::kNull).IsNull()); EXPECT_EQ(EncodableValue(EncodableValue::Type::kBool).BoolValue(), false); EXPECT_EQ(EncodableValue(EncodableValue::Type::kInt).IntValue(), 0); - EXPECT_EQ(EncodableValue(EncodableValue::Type::kLong).LongValue(), 0l); + EXPECT_EQ(EncodableValue(EncodableValue::Type::kLong).LongValue(), + INT64_C(0)); EXPECT_EQ(EncodableValue(EncodableValue::Type::kDouble).DoubleValue(), 0.0); EXPECT_EQ(EncodableValue(EncodableValue::Type::kString).StringValue().size(), 0u); @@ -226,9 +227,9 @@ TEST(EncodableValueTest, Comparison) { EncodableValue(0), EncodableValue(100), // Long - EncodableValue(-7l), - EncodableValue(0l), - EncodableValue(100l), + EncodableValue(INT64_C(-7)), + EncodableValue(INT64_C(0)), + EncodableValue(INT64_C(100)), // Double EncodableValue(-7.0), EncodableValue(0.0), @@ -243,11 +244,11 @@ TEST(EncodableValueTest, Comparison) { EncodableValue(std::vector{0, 1}), EncodableValue(std::vector{0, 100}), // LongList - EncodableValue(std::vector{0, 1l}), - EncodableValue(std::vector{0, 100l}), + EncodableValue(std::vector{0, INT64_C(1)}), + EncodableValue(std::vector{0, INT64_C(100)}), // DoubleList - EncodableValue(std::vector{0, 1l}), - EncodableValue(std::vector{0, 100l}), + EncodableValue(std::vector{0, INT64_C(1)}), + EncodableValue(std::vector{0, INT64_C(100)}), // List EncodableValue(EncodableList{EncodableValue(), EncodableValue(true)}), EncodableValue(EncodableList{EncodableValue(), EncodableValue(1.0)}), @@ -289,7 +290,7 @@ TEST(EncodableValueTest, DeepCopy) { EncodableList encodables = { EncodableValue(EncodableMap{ {EncodableValue(), EncodableValue(std::vector{1, 2, 3})}, - {EncodableValue(1), EncodableValue(10000l)}, + {EncodableValue(1), EncodableValue(INT64_C(0000))}, {EncodableValue("two"), EncodableValue(7)}, }), EncodableValue(EncodableList{ diff --git a/engine/src/flutter/shell/platform/common/cpp/client_wrapper/standard_message_codec_unittests.cc b/engine/src/flutter/shell/platform/common/cpp/client_wrapper/standard_message_codec_unittests.cc index 08f90e54d38..e56a44d62be 100644 --- a/engine/src/flutter/shell/platform/common/cpp/client_wrapper/standard_message_codec_unittests.cc +++ b/engine/src/flutter/shell/platform/common/cpp/client_wrapper/standard_message_codec_unittests.cc @@ -72,7 +72,7 @@ TEST(StandardMessageCodec, CanEncodeAndDecodeInt32) { TEST(StandardMessageCodec, CanEncodeAndDecodeInt64) { std::vector bytes = {0x04, 0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12}; - CheckEncodeDecode(EncodableValue(0x1234567890abcdef), bytes); + CheckEncodeDecode(EncodableValue(INT64_C(0x1234567890abcdef)), bytes); } TEST(StandardMessageCodec, CanEncodeAndDecodeDouble) { diff --git a/engine/src/flutter/shell/platform/glfw/client_wrapper/BUILD.gn b/engine/src/flutter/shell/platform/glfw/client_wrapper/BUILD.gn index d9e1b482dba..4a59ee8f4aa 100644 --- a/engine/src/flutter/shell/platform/glfw/client_wrapper/BUILD.gn +++ b/engine/src/flutter/shell/platform/glfw/client_wrapper/BUILD.gn @@ -52,6 +52,8 @@ source_set("client_wrapper_library_stubs_glfw") { "testing/stub_flutter_glfw_api.h", ] + defines = [ "FLUTTER_DESKTOP_LIBRARY" ] + public_deps = [ "$flutter_root/shell/platform/glfw:flutter_glfw_headers", ] diff --git a/engine/src/flutter/testing/run_tests.sh b/engine/src/flutter/testing/run_tests.sh index 66126634646..621743aa809 100755 --- a/engine/src/flutter/testing/run_tests.sh +++ b/engine/src/flutter/testing/run_tests.sh @@ -38,6 +38,12 @@ echo "Running runtime_unittests..." echo "Running shell_unittests..." "$HOST_DIR/shell_unittests" +echo "Running client_wrapper_unittests..." +"$HOST_DIR/client_wrapper_unittests" + +echo "Running client_wrapper_glfw_unittests..." +"$HOST_DIR/client_wrapper_glfw_unittests" + echo "Running txt_unittests..." "$HOST_DIR/txt_unittests" --font-directory="$BUILDROOT_DIR/flutter/third_party/txt/third_party/fonts"