• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_window_controller.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  public:
19   // |flutter::testing::StubFlutterWindowsApi|
Init()20   bool Init() override {
21     init_called_ = true;
22     return true;
23   }
24 
25   // |flutter::testing::StubFlutterWindowsApi|
Terminate()26   void Terminate() override { terminate_called_ = true; }
27 
init_called()28   bool init_called() { return init_called_; }
29 
terminate_called()30   bool terminate_called() { return terminate_called_; }
31 
32  private:
33   bool init_called_ = false;
34   bool terminate_called_ = false;
35 };
36 
37 }  // namespace
38 
TEST(FlutterViewControllerTest,CreateDestroy)39 TEST(FlutterViewControllerTest, CreateDestroy) {
40   const std::string icu_data_path = "fake/path/to/icu";
41   testing::ScopedStubFlutterWindowsApi scoped_api_stub(
42       std::make_unique<TestWindowsApi>());
43   auto test_api = static_cast<TestWindowsApi*>(scoped_api_stub.stub());
44   {
45     FlutterWindowController controller(icu_data_path);
46     EXPECT_EQ(test_api->init_called(), true);
47     EXPECT_EQ(test_api->terminate_called(), false);
48   }
49   EXPECT_EQ(test_api->init_called(), true);
50   EXPECT_EQ(test_api->terminate_called(), true);
51 }
52 
53 }  // namespace flutter
54