Flutter Engine
Loading...
Searching...
No Matches
flutter_view_unittests.cc
Go to the documentation of this file.
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 <memory>
6
#include <string>
7
8
#include "
flutter/shell/platform/windows/client_wrapper/include/flutter/flutter_view.h
"
9
#include "
flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.h
"
10
#include "gtest/gtest.h"
11
12
namespace
flutter
{
13
14
namespace
{
15
16
// Stub implementation to validate calls to the API.
17
class
TestWindowsApi :
public
testing::StubFlutterWindowsApi {
18
HWND ViewGetHWND()
override
{
return
reinterpret_cast<
HWND
>
(7); }
19
20
IDXGIAdapter* ViewGetGraphicsAdapter()
override
{
21
return
reinterpret_cast<
IDXGIAdapter*
>
(8);
22
}
23
};
24
25
}
// namespace
26
27
TEST
(
FlutterViewTest
, HwndAccessPassesThrough) {
28
testing::ScopedStubFlutterWindowsApi
scoped_api_stub(
29
std::make_unique<TestWindowsApi>());
30
auto
test_api =
static_cast<
TestWindowsApi*
>
(scoped_api_stub.
stub
());
31
FlutterView
view
(
reinterpret_cast<
FlutterDesktopViewRef
>
(2));
32
EXPECT_EQ(
view
.GetNativeWindow(),
reinterpret_cast<
HWND
>
(7));
33
}
34
35
TEST
(
FlutterViewTest
, GraphicsAdapterAccessPassesThrough) {
36
testing::ScopedStubFlutterWindowsApi
scoped_api_stub(
37
std::make_unique<TestWindowsApi>());
38
auto
test_api =
static_cast<
TestWindowsApi*
>
(scoped_api_stub.
stub
());
39
FlutterView
view
(
reinterpret_cast<
FlutterDesktopViewRef
>
(2));
40
41
IDXGIAdapter* adapter =
view
.GetGraphicsAdapter();
42
EXPECT_EQ(adapter,
reinterpret_cast<
IDXGIAdapter*
>
(8));
43
}
44
45
}
// namespace flutter
flutter::FlutterView
Definition
flutter_view.h:16
flutter::testing::ScopedStubFlutterWindowsApi
Definition
stub_flutter_windows_api.h:122
flutter::testing::ScopedStubFlutterWindowsApi::stub
StubFlutterWindowsApi * stub()
Definition
stub_flutter_windows_api.h:130
view
FlView * view
Definition
fl_application.cc:36
flutter_view.h
FlutterDesktopViewRef
struct FlutterDesktopView * FlutterDesktopViewRef
Definition
flutter_windows.h:29
FlutterViewTest
Definition
FlutterViewTest.mm:41
flutter
Definition
asset_manager.cc:10
flutter::TEST
TEST(FrameTimingsRecorderTest, RecordVsync)
Definition
frame_timings_recorder_unittests.cc:22
stub_flutter_windows_api.h
shell
platform
windows
client_wrapper
flutter_view_unittests.cc
Generated on Thu Nov 6 2025 16:11:28 for Flutter Engine by
1.9.8