9 #include "flutter/shell/platform/windows/client_wrapper/testing/stub_flutter_windows_api.h"
10 #include "gtest/gtest.h"
17 class TestWindowsApi :
public testing::StubFlutterWindowsApi {
28 void ViewControllerDestroy()
override { view_controller_destroyed_ =
true; }
31 void ViewControllerForceRedraw()
override {
32 view_controller_force_redrawed_ =
true;
42 bool EngineDestroy()
override {
43 engine_destroyed_ =
true;
47 bool engine_destroyed() {
return engine_destroyed_; }
48 bool view_controller_destroyed() {
return view_controller_destroyed_; }
49 bool view_controller_force_redrawed() {
50 return view_controller_force_redrawed_;
54 bool engine_destroyed_ =
false;
55 bool view_controller_destroyed_ =
false;
56 bool view_controller_force_redrawed_ =
false;
61 TEST(FlutterViewControllerTest, CreateDestroy) {
63 testing::ScopedStubFlutterWindowsApi scoped_api_stub(
64 std::make_unique<TestWindowsApi>());
65 auto test_api =
static_cast<TestWindowsApi*
>(scoped_api_stub.stub());
67 EXPECT_TRUE(test_api->view_controller_destroyed());
70 EXPECT_FALSE(test_api->engine_destroyed());
73 TEST(FlutterViewControllerTest, GetViewId) {
75 testing::ScopedStubFlutterWindowsApi scoped_api_stub(
76 std::make_unique<TestWindowsApi>());
77 auto test_api =
static_cast<TestWindowsApi*
>(scoped_api_stub.stub());
79 EXPECT_EQ(controller.
view_id(), 1);
82 TEST(FlutterViewControllerTest, GetEngine) {
84 testing::ScopedStubFlutterWindowsApi scoped_api_stub(
85 std::make_unique<TestWindowsApi>());
86 auto test_api =
static_cast<TestWindowsApi*
>(scoped_api_stub.stub());
88 EXPECT_NE(controller.
engine(),
nullptr);
91 TEST(FlutterViewControllerTest, GetView) {
93 testing::ScopedStubFlutterWindowsApi scoped_api_stub(
94 std::make_unique<TestWindowsApi>());
95 auto test_api =
static_cast<TestWindowsApi*
>(scoped_api_stub.stub());
97 EXPECT_NE(controller.
view(),
nullptr);
100 TEST(FlutterViewControllerTest, ForceRedraw) {
102 testing::ScopedStubFlutterWindowsApi scoped_api_stub(
103 std::make_unique<TestWindowsApi>());
104 auto test_api =
static_cast<TestWindowsApi*
>(scoped_api_stub.stub());
108 EXPECT_TRUE(test_api->view_controller_force_redrawed());