Flutter Engine
 
Loading...
Searching...
No Matches
windows_lifecycle_manager_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
6
9#include "gtest/gtest.h"
10
11namespace flutter {
12namespace testing {
13
15
17 while (manager.IsUpdateStateScheduled()) {
18 ::MSG msg;
19 if (::GetMessage(&msg, nullptr, 0, 0)) {
20 ::TranslateMessage(&msg);
22 }
23 }
24}
25
27 FlutterWindowsEngineBuilder builder{GetContext()};
28 std::unique_ptr<FlutterWindowsEngine> engine = builder.Build();
29
31 HWND win1 = reinterpret_cast<HWND>(1);
32 HWND win2 = reinterpret_cast<HWND>(2);
33
34 // Hidden to inactive upon window shown.
35 manager.SetLifecycleState(AppLifecycleState::kHidden);
36 manager.OnWindowStateEvent(win1, WindowStateEvent::kShow);
38 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
39
40 // Showing a second window does not change state.
41 manager.OnWindowStateEvent(win2, WindowStateEvent::kShow);
43 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
44
45 // Inactive to resumed upon window focus.
46 manager.OnWindowStateEvent(win2, WindowStateEvent::kFocus);
48 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
49
50 // Showing a second window does not change state.
51 manager.OnWindowStateEvent(win1, WindowStateEvent::kFocus);
53 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
54
55 // Unfocusing one window does not change state while another is focused.
56 manager.OnWindowStateEvent(win1, WindowStateEvent::kUnfocus);
58 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
59
60 // Unfocusing final remaining focused window transitions to inactive.
61 manager.OnWindowStateEvent(win2, WindowStateEvent::kUnfocus);
63 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
64
65 // Hiding one of two visible windows does not change state.
66 manager.OnWindowStateEvent(win2, WindowStateEvent::kHide);
68 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
69
70 // Hiding only visible window transitions to hidden.
71 manager.OnWindowStateEvent(win1, WindowStateEvent::kHide);
73 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kHidden);
74
75 // Transition directly from resumed to hidden when the window is hidden.
76 manager.OnWindowStateEvent(win1, WindowStateEvent::kShow);
77 manager.OnWindowStateEvent(win1, WindowStateEvent::kFocus);
78 manager.OnWindowStateEvent(win1, WindowStateEvent::kHide);
80 EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kHidden);
81}
82
83} // namespace testing
84} // namespace flutter
FlutterEngine engine
Definition main.cc:84
TEST_F(DisplayListTest, Defaults)
static void WaitUntilUpdated(const WindowsLifecycleManager &manager)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font manager
struct tagMSG MSG
#define GetMessage
#define DispatchMessage