forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflutter_window_unittests.cc
More file actions
57 lines (41 loc) · 1.64 KB
/
flutter_window_unittests.cc
File metadata and controls
57 lines (41 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/glfw/client_wrapper/include/flutter/flutter_window.h"
#include <memory>
#include <string>
#include "flutter/shell/platform/glfw/client_wrapper/testing/stub_flutter_glfw_api.h"
#include "gtest/gtest.h"
namespace flutter {
namespace {
// Stub implementation to validate calls to the API.
class TestGlfwApi : public testing::StubFlutterGlfwApi {
public:
// |flutter::testing::StubFlutterGlfwApi|
void SetSizeLimits(FlutterDesktopSize minimum_size,
FlutterDesktopSize maximum_size) override {
set_size_limits_called_ = true;
}
bool set_size_limits_called() { return set_size_limits_called_; }
private:
bool set_size_limits_called_ = false;
};
} // namespace
TEST(FlutterWindowTest, SetSizeLimits) {
const std::string icu_data_path = "fake/path/to/icu";
testing::ScopedStubFlutterGlfwApi scoped_api_stub(
std::make_unique<TestGlfwApi>());
auto test_api = static_cast<TestGlfwApi*>(scoped_api_stub.stub());
// This is not actually used so any non-zero value works.
auto raw_window = reinterpret_cast<FlutterDesktopWindowRef>(1);
auto window = std::make_unique<FlutterWindow>(raw_window);
FlutterDesktopSize minimum_size = {};
minimum_size.width = 100;
minimum_size.height = 100;
FlutterDesktopSize maximum_size = {};
maximum_size.width = -1;
maximum_size.height = -1;
window->SetSizeLimits(minimum_size, maximum_size);
EXPECT_EQ(test_api->set_size_limits_called(), true);
}
} // namespace flutter