Flutter Engine
flutter_window_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 "flutter/shell/platform/glfw/client_wrapper/include/flutter/flutter_window.h"
6 
7 #include <memory>
8 #include <string>
9 
10 #include "flutter/shell/platform/glfw/client_wrapper/testing/stub_flutter_glfw_api.h"
11 #include "gtest/gtest.h"
12 
13 namespace flutter {
14 
15 namespace {
16 
17 // Stub implementation to validate calls to the API.
18 class TestGlfwApi : public testing::StubFlutterGlfwApi {
19  public:
20  // |flutter::testing::StubFlutterGlfwApi|
21  void SetSizeLimits(FlutterDesktopSize minimum_size,
22  FlutterDesktopSize maximum_size) override {
23  set_size_limits_called_ = true;
24  }
25 
26  bool set_size_limits_called() { return set_size_limits_called_; }
27 
28  private:
29  bool set_size_limits_called_ = false;
30 };
31 
32 } // namespace
33 
34 TEST(FlutterWindowTest, SetSizeLimits) {
35  const std::string icu_data_path = "fake/path/to/icu";
36  testing::ScopedStubFlutterGlfwApi scoped_api_stub(
37  std::make_unique<TestGlfwApi>());
38  auto test_api = static_cast<TestGlfwApi*>(scoped_api_stub.stub());
39  // This is not actually used so any non-zero value works.
40  auto raw_window = reinterpret_cast<FlutterDesktopWindowRef>(1);
41 
42  auto window = std::make_unique<FlutterWindow>(raw_window);
43 
44  FlutterDesktopSize minimum_size = {};
45  minimum_size.width = 100;
46  minimum_size.height = 100;
47 
48  FlutterDesktopSize maximum_size = {};
49  maximum_size.width = -1;
50  maximum_size.height = -1;
51 
52  window->SetSizeLimits(minimum_size, maximum_size);
53 
54  EXPECT_EQ(test_api->set_size_limits_called(), true);
55 }
56 
57 } // namespace flutter
TEST(DartServiceIsolateTest, CanAddAndRemoveHandles)