Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

@chunhtai chunhtai Oct 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The windows unit test requires opengl to run, I updated it to use a gui version of image

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
Copy link
Contributor Author

@chunhtai chunhtai Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of the unit tests fail on windows platform, I think only run relevant tests should be enough

- 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