Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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
10#include "gtest/gtest.h"
11
12namespace flutter {
13
14namespace {
15
16// Stub implementation to validate calls to the API.
17class 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 bool EngineGetGraphicsAdapter(IDXGIAdapter** adapter_out) override {
25 *adapter_out = reinterpret_cast<IDXGIAdapter*>(9);
26 return true;
27 }
28};
29
30} // namespace
31
32TEST(FlutterViewTest, HwndAccessPassesThrough) {
34 std::make_unique<TestWindowsApi>());
35 auto test_api = static_cast<TestWindowsApi*>(scoped_api_stub.stub());
36 FlutterView view(reinterpret_cast<FlutterDesktopViewRef>(2));
37 EXPECT_EQ(view.GetNativeWindow(), reinterpret_cast<HWND>(7));
38}
39
40TEST(FlutterViewTest, GraphicsAdapterAccessPassesThrough) {
42 std::make_unique<TestWindowsApi>());
43 auto test_api = static_cast<TestWindowsApi*>(scoped_api_stub.stub());
44 FlutterView view(reinterpret_cast<FlutterDesktopViewRef>(2));
45
46 IDXGIAdapter* adapter = view.GetGraphicsAdapter();
47 EXPECT_EQ(adapter, reinterpret_cast<IDXGIAdapter*>(8));
48}
49
50} // namespace flutter
FlView * view
struct FlutterDesktopView * FlutterDesktopViewRef
TEST(FrameTimingsRecorderTest, RecordVsync)