forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflutter_window_controller_unittests.cc
More file actions
54 lines (41 loc) · 1.5 KB
/
flutter_window_controller_unittests.cc
File metadata and controls
54 lines (41 loc) · 1.5 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
// 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_controller.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|
bool Init() override {
init_called_ = true;
return true;
}
// |flutter::testing::StubFlutterGlfwApi|
void Terminate() override { terminate_called_ = true; }
bool init_called() { return init_called_; }
bool terminate_called() { return terminate_called_; }
private:
bool init_called_ = false;
bool terminate_called_ = false;
};
} // namespace
TEST(FlutterViewControllerTest, CreateDestroy) {
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());
{
FlutterWindowController controller(icu_data_path);
EXPECT_EQ(test_api->init_called(), true);
EXPECT_EQ(test_api->terminate_called(), false);
}
EXPECT_EQ(test_api->init_called(), true);
EXPECT_EQ(test_api->terminate_called(), true);
}
} // namespace flutter