Skip to content

Commit daf1eb9

Browse files
authored
add windows embedding test (flutter#12423)
1 parent 1c21698 commit daf1eb9

File tree

12 files changed

+123
-7
lines changed

12 files changed

+123
-7
lines changed

.cirrus.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ task:
9090
task:
9191
gce_instance:
9292
image_project: flutter-cirrus
93-
image_name: flutter-engine-windows-server-2016-core
93+
image_name: flutter-engine-windows-server-2016
9494
zone: us-central1-a
9595
platform: windows
9696
cpu: 32
@@ -109,11 +109,14 @@ task:
109109
cd %ENGINE_PATH%/src
110110
gclient sync
111111
matrix:
112-
- name: build_windows_unopt_debug
112+
- name: build_and_test_windows_unopt_debug
113113
compile_host_script: |
114114
cd %ENGINE_PATH%/src
115115
python flutter/tools/gn --runtime-mode debug --unoptimized
116116
ninja -C out/host_debug_unopt
117+
test_host_script: |
118+
cd %ENGINE_PATH%/src
119+
python flutter/testing/run_tests.py --type=engine --engine-filter=flutter_windows_unittests,client_wrapper_windows_unittests
117120
- name: build_windows_opt_debug
118121
compile_host_script: |
119122
cd %ENGINE_PATH%/src

BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ group("flutter") {
7272
]
7373

7474
if (is_win) {
75-
public_deps += [ "$flutter_root/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests" ]
75+
public_deps += [
76+
"$flutter_root/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests",
77+
"$flutter_root/shell/platform/windows:flutter_windows_unittests"
78+
]
7679
}
7780

7881
if (!is_win) {

ci/docker/windows_build/prepare_windows_server_2016_core.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The following powershell script prepares the VM image
2-
# flutter-engine-windows-server-2016-core used by Flutter engine's
2+
# flutter-engine-windows-server-2016 used by Flutter engine's
33
# build_windows presubmit tests (see .cirrus.yml).
44
#
55
# The exact step of generating the VM image is:

ci/licenses_golden/licenses_flutter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.cc
10291029
FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.h
10301030
FILE: ../../../flutter/shell/platform/windows/win32_window.cc
10311031
FILE: ../../../flutter/shell/platform/windows/win32_window.h
1032+
FILE: ../../../flutter/shell/platform/windows/win32_window_unittests.cc
10321033
FILE: ../../../flutter/shell/platform/windows/window_state.h
10331034
FILE: ../../../flutter/shell/version/version.cc
10341035
FILE: ../../../flutter/shell/version/version.h

shell/platform/common/cpp/client_wrapper/BUILD.gn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ executable("client_wrapper_unittests") {
6363
":client_wrapper_library_stubs",
6464
"$flutter_root/testing",
6565

66-
# TODO: Consider refactoring flutter_root/testing so that there's a testing
66+
# TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing
6767
# target that doesn't require a Dart runtime to be linked in.
68+
# https://github.com/flutter/flutter/issues/41414.
6869
"//third_party/dart/runtime:libdart_jit",
6970
]
7071
}

shell/platform/glfw/client_wrapper/BUILD.gn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ executable("client_wrapper_glfw_unittests") {
8484
"$flutter_root/shell/platform/common/cpp/client_wrapper:client_wrapper_library_stubs",
8585
"$flutter_root/testing",
8686

87-
# TODO: Consider refactoring flutter_root/testing so that there's a testing
87+
# TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing
8888
# target that doesn't require a Dart runtime to be linked in.
89+
# https://github.com/flutter/flutter/issues/41414.
8990
"//third_party/dart/runtime:libdart_jit",
9091
]
9192
}

shell/platform/windows/BUILD.gn

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
assert(is_win)
66

77
import("$flutter_root/shell/platform/glfw/config.gni")
8+
import("$flutter_root/testing/testing.gni")
89

910
_public_headers = [ "public/flutter_windows.h" ]
1011

@@ -100,6 +101,34 @@ shared_library("flutter_windows") {
100101
public_configs = [ "$flutter_root:config" ]
101102
}
102103

104+
test_fixtures("flutter_windows_fixtures") {
105+
fixtures = []
106+
}
107+
108+
executable("flutter_windows_unittests") {
109+
testonly = true
110+
111+
sources = [
112+
"win32_window_unittests.cc",
113+
"testing/win32_flutter_window_test.h",
114+
"testing/win32_flutter_window_test.cc",
115+
]
116+
117+
public_configs = [ "$flutter_root:config" ]
118+
119+
deps = [
120+
":flutter_windows_source",
121+
":flutter_windows_headers",
122+
"//third_party/rapidjson",
123+
":flutter_windows_fixtures",
124+
"$flutter_root/testing",
125+
# TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing
126+
# target that doesn't require a Dart runtime to be linked in.
127+
# https://github.com/flutter/flutter/issues/41414.
128+
"//third_party/dart/runtime:libdart_jit",
129+
]
130+
}
131+
103132
shared_library("flutter_windows_glfw") {
104133
deps = [
105134
"$flutter_root/shell/platform/glfw:flutter_glfw",

shell/platform/windows/client_wrapper/BUILD.gn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ executable("client_wrapper_windows_unittests") {
7878
"$flutter_root/shell/platform/common/cpp/client_wrapper:client_wrapper_library_stubs",
7979
"$flutter_root/testing",
8080

81-
# TODO: Consider refactoring flutter_root/testing so that there's a testing
81+
# TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing
8282
# target that doesn't require a Dart runtime to be linked in.
83+
# https://github.com/flutter/flutter/issues/41414.
8384
"//third_party/dart/runtime:libdart_jit",
8485
]
8586
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h"
2+
#include <iostream>
3+
4+
namespace flutter {
5+
namespace testing {
6+
7+
Win32FlutterWindowTest::Win32FlutterWindowTest(int width, int height)
8+
: Win32FlutterWindow(width, height){};
9+
10+
Win32FlutterWindowTest::~Win32FlutterWindowTest() = default;
11+
12+
void Win32FlutterWindowTest::OnFontChange() {
13+
on_font_change_called_ = true;
14+
}
15+
16+
bool Win32FlutterWindowTest::OnFontChangeWasCalled() {
17+
return on_font_change_called_;
18+
}
19+
} // namespace testing
20+
} // namespace flutter
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include <windowsx.h>
6+
7+
#include "flutter/fml/macros.h"
8+
#include "flutter/shell/platform/windows/win32_flutter_window.h"
9+
10+
namespace flutter {
11+
namespace testing {
12+
13+
class Win32FlutterWindowTest : public Win32FlutterWindow {
14+
public:
15+
Win32FlutterWindowTest(int width, int height);
16+
17+
~Win32FlutterWindowTest();
18+
19+
// |Win32Window|
20+
void OnFontChange() override;
21+
22+
bool OnFontChangeWasCalled();
23+
24+
private:
25+
bool on_font_change_called_ = false;
26+
27+
FML_DISALLOW_COPY_AND_ASSIGN(Win32FlutterWindowTest);
28+
};
29+
30+
} // namespace testing
31+
} // namespace flutter
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h"
2+
#include "gtest/gtest.h"
3+
4+
namespace flutter {
5+
namespace testing {
6+
7+
TEST(Win32FlutterWindowTest, CreateDestroy) {
8+
Win32FlutterWindowTest window(800, 600);
9+
ASSERT_TRUE(TRUE);
10+
}
11+
12+
TEST(Win32FlutterWindowTest, CanFontChange) {
13+
Win32FlutterWindowTest window(800, 600);
14+
HWND hwnd = window.GetWindowHandle();
15+
LRESULT result = SendMessage(hwnd, WM_FONTCHANGE, NULL, NULL);
16+
ASSERT_EQ(result, 0);
17+
ASSERT_TRUE(window.OnFontChangeWasCalled());
18+
ASSERT_TRUE(TRUE);
19+
}
20+
21+
} // namespace testing
22+
} // namespace flutter

testing/run_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ def RunCCTests(build_dir, filter):
8383
# https://github.com/flutter/flutter/issues/36294
8484
if not IsWindows():
8585
RunEngineExecutable(build_dir, 'embedder_unittests', filter, shuffle_flags)
86+
else:
87+
RunEngineExecutable(build_dir, 'flutter_windows_unittests', filter, shuffle_flags)
88+
89+
RunEngineExecutable(build_dir, 'client_wrapper_windows_unittests', filter, shuffle_flags)
8690

8791
flow_flags = ['--gtest_filter=-PerformanceOverlayLayer.Gold']
8892
if IsLinux():

0 commit comments

Comments
 (0)