Skip to content

Commit

Permalink
add windows embedding test (flutter#12423)
Browse files Browse the repository at this point in the history
  • Loading branch information
chunhtai authored Oct 3, 2019
1 parent 1c21698 commit daf1eb9
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 7 deletions.
7 changes: 5 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/common/cpp/client_wrapper/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
3 changes: 2 additions & 1 deletion shell/platform/glfw/client_wrapper/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
29 changes: 29 additions & 0 deletions shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]

Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/windows/client_wrapper/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
20 changes: 20 additions & 0 deletions shell/platform/windows/testing/win32_flutter_window_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "flutter/shell/platform/windows/testing/win32_flutter_window_test.h"
#include <iostream>

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
31 changes: 31 additions & 0 deletions shell/platform/windows/testing/win32_flutter_window_test.h
Original file line number Diff line number Diff line change
@@ -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 <windowsx.h>

#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
22 changes: 22 additions & 0 deletions shell/platform/windows/win32_window_unittests.cc
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit daf1eb9

Please sign in to comment.