Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a6ee021

Browse files
committed
add windows embedding test
1 parent 18aa6c9 commit a6ee021

File tree

8 files changed

+129
-4
lines changed

8 files changed

+129
-4
lines changed

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) {

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: 58 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,63 @@ 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+
"angle_surface_manager.cc",
116+
"angle_surface_manager.h",
117+
"flutter_windows.cc",
118+
"key_event_handler.cc",
119+
"key_event_handler.h",
120+
"keyboard_hook_handler.h",
121+
"platform_handler.cc",
122+
"platform_handler.h",
123+
"text_input_plugin.cc",
124+
"text_input_plugin.h",
125+
"win32_dpi_helper.cc",
126+
"win32_dpi_helper.h",
127+
"win32_flutter_window.cc",
128+
"win32_flutter_window.h",
129+
"win32_window.cc",
130+
"win32_window.h",
131+
"window_state.h",
132+
]
133+
134+
defines = [ "USE_RAPID_JSON" ]
135+
136+
configs += [
137+
"$flutter_root/shell/platform/common/cpp:desktop_library_implementation",
138+
"//third_party/angle:gl_prototypes",
139+
]
140+
141+
public_configs = [ ":relative_angle_headers" ]
142+
143+
deps = [
144+
":flutter_windows_headers",
145+
"$flutter_root/shell/platform/common/cpp:common_cpp",
146+
"$flutter_root/shell/platform/common/cpp/client_wrapper:client_wrapper",
147+
"$flutter_root/shell/platform/embedder:embedder_with_symbol_prefix",
148+
"$flutter_root/shell/platform/windows/client_wrapper:client_wrapper_windows",
149+
"//third_party/angle:libEGL_static", # the order of libEGL_static and libGLESv2_static is important.. if reversed, will cause a linker error DllMain already defined in LIBCMTD.lib
150+
"//third_party/angle:libGLESv2_static",
151+
"//third_party/rapidjson",
152+
":flutter_windows_fixtures",
153+
"$flutter_root/testing",
154+
# TODO(chunhtai): Consider refactoring flutter_root/testing so that there's a testing
155+
# target that doesn't require a Dart runtime to be linked in.
156+
# https://github.com/flutter/flutter/issues/41414.
157+
"//third_party/dart/runtime:libdart_jit",
158+
]
159+
}
160+
103161
shared_library("flutter_windows_glfw") {
104162
deps = [
105163
"$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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h"
2+
#include <iostream>
3+
4+
namespace flutter {
5+
namespace testing {
6+
void Win32FlutterWindowTest::OnFontChange() {
7+
on_font_change_called_ = true;
8+
}
9+
10+
bool OnFontChangeIsCalled() {
11+
return on_font_change_called_;
12+
}
13+
} // namespace testing
14+
} // namespace flutter
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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/shell/platform/windows/win32_flutter_window.h"
8+
9+
namespace flutter {
10+
namespace testing {
11+
12+
class Win32FlutterWindowTest : public Win32FlutterWindow {
13+
public:
14+
Win32FlutterWindowTest(int width, int height) : Win32FlutterWindow(width, height) { };
15+
16+
// |Win32Window|
17+
void OnFontChange() override;
18+
19+
bool OnFontChangeIsCalled();
20+
21+
private:
22+
bool on_font_change_called_ = false;
23+
};
24+
25+
} // namespace testing
26+
} // namespace flutter
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "gtest/gtest.h"
2+
#include "flutter/shell/platform/windows/win32_flutter_window.h"
3+
#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h"
4+
5+
namespace flutter {
6+
namespace testing {
7+
8+
TEST(Win32FlutterWindowTest, CreateDestroy) {
9+
Win32FlutterWindow window(800, 600);
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.OnFontChangeIsCalled());
18+
}
19+
20+
}
21+
}

0 commit comments

Comments
 (0)