diff --git a/.cirrus.yml b/.cirrus.yml index b452e61f9e37e..3a77c86308a1d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -90,7 +90,7 @@ task: task: gce_instance: image_project: flutter-cirrus - image_name: flutter-engine-windows-server-2016-core + image_name: flutter-engine-windows-server-2016 zone: us-central1-a platform: windows cpu: 32 @@ -109,11 +109,14 @@ task: cd %ENGINE_PATH%/src gclient sync matrix: - - name: build_windows_unopt_debug + - name: build_and_test_windows_unopt_debug compile_host_script: | cd %ENGINE_PATH%/src python flutter/tools/gn --runtime-mode debug --unoptimized ninja -C out/host_debug_unopt + test_host_script: | + cd %ENGINE_PATH%/src + python flutter/testing/run_tests.py --type=engine --engine-filter=flutter_windows_unittests,client_wrapper_windows_unittests - name: build_windows_opt_debug compile_host_script: | cd %ENGINE_PATH%/src diff --git a/BUILD.gn b/BUILD.gn index 3e6eef501f7e6..b894fe26f0e37 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -72,7 +72,10 @@ group("flutter") { ] if (is_win) { - public_deps += [ "$flutter_root/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests" ] + public_deps += [ + "$flutter_root/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests", + "$flutter_root/shell/platform/windows:flutter_windows_unittests" + ] } if (!is_win) { diff --git a/ci/docker/windows_build/prepare_windows_server_2016_core.ps1 b/ci/docker/windows_build/prepare_windows_server_2016_core.ps1 index f11c1b7a53e37..1a310aa9e3df9 100644 --- a/ci/docker/windows_build/prepare_windows_server_2016_core.ps1 +++ b/ci/docker/windows_build/prepare_windows_server_2016_core.ps1 @@ -1,5 +1,5 @@ # The following powershell script prepares the VM image -# flutter-engine-windows-server-2016-core used by Flutter engine's +# flutter-engine-windows-server-2016 used by Flutter engine's # build_windows presubmit tests (see .cirrus.yml). # # The exact step of generating the VM image is: diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index cccbe6a7537c7..2f76b8683b20b 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1029,6 +1029,7 @@ FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.cc FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.h FILE: ../../../flutter/shell/platform/windows/win32_window.cc FILE: ../../../flutter/shell/platform/windows/win32_window.h +FILE: ../../../flutter/shell/platform/windows/win32_window_unittests.cc FILE: ../../../flutter/shell/platform/windows/window_state.h FILE: ../../../flutter/shell/version/version.cc FILE: ../../../flutter/shell/version/version.h diff --git a/shell/platform/common/cpp/client_wrapper/BUILD.gn b/shell/platform/common/cpp/client_wrapper/BUILD.gn index 5858f86899139..8040eab9a19f9 100644 --- a/shell/platform/common/cpp/client_wrapper/BUILD.gn +++ b/shell/platform/common/cpp/client_wrapper/BUILD.gn @@ -63,8 +63,9 @@ executable("client_wrapper_unittests") { ":client_wrapper_library_stubs", "$flutter_root/testing", - # TODO: Consider refactoring flutter_root/testing so that there's a testing + # TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing # target that doesn't require a Dart runtime to be linked in. + # https://github.com/flutter/flutter/issues/41414. "//third_party/dart/runtime:libdart_jit", ] } diff --git a/shell/platform/glfw/client_wrapper/BUILD.gn b/shell/platform/glfw/client_wrapper/BUILD.gn index 72bcf4f971f2d..18dd862993c0a 100644 --- a/shell/platform/glfw/client_wrapper/BUILD.gn +++ b/shell/platform/glfw/client_wrapper/BUILD.gn @@ -84,8 +84,9 @@ executable("client_wrapper_glfw_unittests") { "$flutter_root/shell/platform/common/cpp/client_wrapper:client_wrapper_library_stubs", "$flutter_root/testing", - # TODO: Consider refactoring flutter_root/testing so that there's a testing + # TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing # target that doesn't require a Dart runtime to be linked in. + # https://github.com/flutter/flutter/issues/41414. "//third_party/dart/runtime:libdart_jit", ] } diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index 3eda081ddffea..7f94225e984a9 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -5,6 +5,7 @@ assert(is_win) import("$flutter_root/shell/platform/glfw/config.gni") +import("$flutter_root/testing/testing.gni") _public_headers = [ "public/flutter_windows.h" ] @@ -100,6 +101,34 @@ shared_library("flutter_windows") { public_configs = [ "$flutter_root:config" ] } +test_fixtures("flutter_windows_fixtures") { + fixtures = [] +} + +executable("flutter_windows_unittests") { + testonly = true + + sources = [ + "win32_window_unittests.cc", + "testing/win32_flutter_window_test.h", + "testing/win32_flutter_window_test.cc", + ] + + public_configs = [ "$flutter_root:config" ] + + deps = [ + ":flutter_windows_source", + ":flutter_windows_headers", + "//third_party/rapidjson", + ":flutter_windows_fixtures", + "$flutter_root/testing", + # TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing + # target that doesn't require a Dart runtime to be linked in. + # https://github.com/flutter/flutter/issues/41414. + "//third_party/dart/runtime:libdart_jit", + ] +} + shared_library("flutter_windows_glfw") { deps = [ "$flutter_root/shell/platform/glfw:flutter_glfw", diff --git a/shell/platform/windows/client_wrapper/BUILD.gn b/shell/platform/windows/client_wrapper/BUILD.gn index f1a41f8c196da..4a62ffb8fe723 100644 --- a/shell/platform/windows/client_wrapper/BUILD.gn +++ b/shell/platform/windows/client_wrapper/BUILD.gn @@ -78,8 +78,9 @@ executable("client_wrapper_windows_unittests") { "$flutter_root/shell/platform/common/cpp/client_wrapper:client_wrapper_library_stubs", "$flutter_root/testing", - # TODO: Consider refactoring flutter_root/testing so that there's a testing + # TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing # target that doesn't require a Dart runtime to be linked in. + # https://github.com/flutter/flutter/issues/41414. "//third_party/dart/runtime:libdart_jit", ] } diff --git a/shell/platform/windows/testing/win32_flutter_window_test.cc b/shell/platform/windows/testing/win32_flutter_window_test.cc new file mode 100644 index 0000000000000..080262ae4bf88 --- /dev/null +++ b/shell/platform/windows/testing/win32_flutter_window_test.cc @@ -0,0 +1,20 @@ +#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h" +#include + +namespace flutter { +namespace testing { + +Win32FlutterWindowTest::Win32FlutterWindowTest(int width, int height) + : Win32FlutterWindow(width, height){}; + +Win32FlutterWindowTest::~Win32FlutterWindowTest() = default; + +void Win32FlutterWindowTest::OnFontChange() { + on_font_change_called_ = true; +} + +bool Win32FlutterWindowTest::OnFontChangeWasCalled() { + return on_font_change_called_; +} +} // namespace testing +} // namespace flutter diff --git a/shell/platform/windows/testing/win32_flutter_window_test.h b/shell/platform/windows/testing/win32_flutter_window_test.h new file mode 100644 index 0000000000000..361a6960a5fc6 --- /dev/null +++ b/shell/platform/windows/testing/win32_flutter_window_test.h @@ -0,0 +1,31 @@ +// 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 + +#include "flutter/fml/macros.h" +#include "flutter/shell/platform/windows/win32_flutter_window.h" + +namespace flutter { +namespace testing { + +class Win32FlutterWindowTest : public Win32FlutterWindow { + public: + Win32FlutterWindowTest(int width, int height); + + ~Win32FlutterWindowTest(); + + // |Win32Window| + void OnFontChange() override; + + bool OnFontChangeWasCalled(); + + private: + bool on_font_change_called_ = false; + + FML_DISALLOW_COPY_AND_ASSIGN(Win32FlutterWindowTest); +}; + +} // namespace testing +} // namespace flutter diff --git a/shell/platform/windows/win32_window_unittests.cc b/shell/platform/windows/win32_window_unittests.cc new file mode 100644 index 0000000000000..d04458492dff1 --- /dev/null +++ b/shell/platform/windows/win32_window_unittests.cc @@ -0,0 +1,22 @@ +#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h" +#include "gtest/gtest.h" + +namespace flutter { +namespace testing { + +TEST(Win32FlutterWindowTest, CreateDestroy) { + Win32FlutterWindowTest window(800, 600); + ASSERT_TRUE(TRUE); +} + +TEST(Win32FlutterWindowTest, CanFontChange) { + Win32FlutterWindowTest window(800, 600); + HWND hwnd = window.GetWindowHandle(); + LRESULT result = SendMessage(hwnd, WM_FONTCHANGE, NULL, NULL); + ASSERT_EQ(result, 0); + ASSERT_TRUE(window.OnFontChangeWasCalled()); + ASSERT_TRUE(TRUE); +} + +} // namespace testing +} // namespace flutter diff --git a/testing/run_tests.py b/testing/run_tests.py index 421e265952f76..fbcd858ce5049 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -83,6 +83,10 @@ def RunCCTests(build_dir, filter): # https://github.com/flutter/flutter/issues/36294 if not IsWindows(): RunEngineExecutable(build_dir, 'embedder_unittests', filter, shuffle_flags) + else: + RunEngineExecutable(build_dir, 'flutter_windows_unittests', filter, shuffle_flags) + + RunEngineExecutable(build_dir, 'client_wrapper_windows_unittests', filter, shuffle_flags) flow_flags = ['--gtest_filter=-PerformanceOverlayLayer.Gold'] if IsLinux():