Skip to content

Commit

Permalink
Add desktop shell unittests to test script (flutter#8600)
Browse files Browse the repository at this point in the history
Builds the unit test on all platforms, and adds them to the aggregate test script.
  • Loading branch information
stuartmorgan authored Apr 17, 2019
1 parent 8156268 commit 4266f85
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
9 changes: 2 additions & 7 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions shell/platform/common/cpp/client_wrapper/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -170,15 +170,15 @@ TEST(EncodableValueTest, List) {
TEST(EncodableValueTest, Map) {
EncodableMap encodables = {
{EncodableValue(), EncodableValue(std::vector<int32_t>{1, 2, 3})},
{EncodableValue(1), EncodableValue(10000l)},
{EncodableValue(1), EncodableValue(INT64_C(10000))},
{EncodableValue("two"), EncodableValue(7)},
};
EncodableValue value(encodables);
VerifyType(value, EncodableValue::Type::kMap);

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.
Expand All @@ -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);
Expand Down Expand Up @@ -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),
Expand All @@ -243,11 +244,11 @@ TEST(EncodableValueTest, Comparison) {
EncodableValue(std::vector<int32_t>{0, 1}),
EncodableValue(std::vector<int32_t>{0, 100}),
// LongList
EncodableValue(std::vector<int64_t>{0, 1l}),
EncodableValue(std::vector<int64_t>{0, 100l}),
EncodableValue(std::vector<int64_t>{0, INT64_C(1)}),
EncodableValue(std::vector<int64_t>{0, INT64_C(100)}),
// DoubleList
EncodableValue(std::vector<int64_t>{0, 1l}),
EncodableValue(std::vector<int64_t>{0, 100l}),
EncodableValue(std::vector<int64_t>{0, INT64_C(1)}),
EncodableValue(std::vector<int64_t>{0, INT64_C(100)}),
// List
EncodableValue(EncodableList{EncodableValue(), EncodableValue(true)}),
EncodableValue(EncodableList{EncodableValue(), EncodableValue(1.0)}),
Expand Down Expand Up @@ -289,7 +290,7 @@ TEST(EncodableValueTest, DeepCopy) {
EncodableList encodables = {
EncodableValue(EncodableMap{
{EncodableValue(), EncodableValue(std::vector<int32_t>{1, 2, 3})},
{EncodableValue(1), EncodableValue(10000l)},
{EncodableValue(1), EncodableValue(INT64_C(0000))},
{EncodableValue("two"), EncodableValue(7)},
}),
EncodableValue(EncodableList{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ TEST(StandardMessageCodec, CanEncodeAndDecodeInt32) {
TEST(StandardMessageCodec, CanEncodeAndDecodeInt64) {
std::vector<uint8_t> bytes = {0x04, 0xef, 0xcd, 0xab, 0x90,
0x78, 0x56, 0x34, 0x12};
CheckEncodeDecode(EncodableValue(0x1234567890abcdef), bytes);
CheckEncodeDecode(EncodableValue(INT64_C(0x1234567890abcdef)), bytes);
}

TEST(StandardMessageCodec, CanEncodeAndDecodeDouble) {
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/glfw/client_wrapper/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down
6 changes: 6 additions & 0 deletions testing/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 4266f85

Please sign in to comment.