From 66e6cd880d5a270fc67acea8addc909002d2a775 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 3 Aug 2022 01:09:48 +0100 Subject: [PATCH] [Windows] Fix incorrect public C API argument type (flutter/engine#35106) FlutterDesktopEngineGetTextureRegistrar is used to get the texture registrar associated with an engine object and therefore should take a FlutterDesktopEngineRef parameter. This bug was initially identified and fixed by @knopp in: https://github.com/flutter/engine/pull/27522 This patch replaces that one and adds the simplest possible unit test to get it landed. This also adds an initial unit test for the public Windows C API used to implement the C++ client wrapper. In order to fully test this API, we'll want to support test fixtures similar to what we do in the embedder API tests. See: https://github.com/flutter/flutter/issues/87299 Fixes: https://github.com/flutter/flutter/issues/86617 --- .../ci/licenses_golden/licenses_flutter | 1 + .../flutter/shell/platform/windows/BUILD.gn | 1 + .../windows/flutter_windows_unittests.cc | 25 +++++++++++++++++++ .../platform/windows/public/flutter_windows.h | 3 +-- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 engine/src/flutter/shell/platform/windows/flutter_windows_unittests.cc diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 58281df1d5..2cfa26d896 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -2401,6 +2401,7 @@ FILE: ../../../flutter/shell/platform/windows/flutter_windows_engine_unittests.c FILE: ../../../flutter/shell/platform/windows/flutter_windows_texture_registrar.cc FILE: ../../../flutter/shell/platform/windows/flutter_windows_texture_registrar.h FILE: ../../../flutter/shell/platform/windows/flutter_windows_texture_registrar_unittests.cc +FILE: ../../../flutter/shell/platform/windows/flutter_windows_unittests.cc FILE: ../../../flutter/shell/platform/windows/flutter_windows_view.cc FILE: ../../../flutter/shell/platform/windows/flutter_windows_view.h FILE: ../../../flutter/shell/platform/windows/flutter_windows_view_unittests.cc diff --git a/engine/src/flutter/shell/platform/windows/BUILD.gn b/engine/src/flutter/shell/platform/windows/BUILD.gn index 5531f8a413..c83e5f2fdb 100644 --- a/engine/src/flutter/shell/platform/windows/BUILD.gn +++ b/engine/src/flutter/shell/platform/windows/BUILD.gn @@ -173,6 +173,7 @@ executable("flutter_windows_unittests") { "flutter_window_unittests.cc", "flutter_windows_engine_unittests.cc", "flutter_windows_texture_registrar_unittests.cc", + "flutter_windows_unittests.cc", "flutter_windows_view_unittests.cc", "keyboard_key_channel_handler_unittests.cc", "keyboard_key_embedder_handler_unittests.cc", diff --git a/engine/src/flutter/shell/platform/windows/flutter_windows_unittests.cc b/engine/src/flutter/shell/platform/windows/flutter_windows_unittests.cc new file mode 100644 index 0000000000..e0b87dd781 --- /dev/null +++ b/engine/src/flutter/shell/platform/windows/flutter_windows_unittests.cc @@ -0,0 +1,25 @@ +// 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 "flutter/shell/platform/windows/public/flutter_windows.h" + +#include + +#include "gtest/gtest.h" + +namespace flutter { + +TEST(FlutterWindowsTest, GetTextureRegistrar) { + FlutterDesktopEngineProperties properties; + memset(&properties, 0, sizeof(FlutterDesktopEngineProperties)); + properties.assets_path = L""; + properties.icu_data_path = L"icudtl.dat"; + auto engine = FlutterDesktopEngineCreate(&properties); + ASSERT_NE(engine, nullptr); + auto texture_registrar = FlutterDesktopEngineGetTextureRegistrar(engine); + EXPECT_NE(texture_registrar, nullptr); + FlutterDesktopEngineDestroy(engine); +} + +} // namespace flutter diff --git a/engine/src/flutter/shell/platform/windows/public/flutter_windows.h b/engine/src/flutter/shell/platform/windows/public/flutter_windows.h index ad03dd3a12..b5d2738778 100644 --- a/engine/src/flutter/shell/platform/windows/public/flutter_windows.h +++ b/engine/src/flutter/shell/platform/windows/public/flutter_windows.h @@ -169,8 +169,7 @@ FlutterDesktopEngineGetMessenger(FlutterDesktopEngineRef engine); // Returns the texture registrar associated with the engine. FLUTTER_EXPORT FlutterDesktopTextureRegistrarRef -FlutterDesktopEngineGetTextureRegistrar( - FlutterDesktopTextureRegistrarRef texture_registrar); +FlutterDesktopEngineGetTextureRegistrar(FlutterDesktopEngineRef engine); // ========== View ==========