Flutter Windows Embedder
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 
7 #include "flutter/shell/platform/windows/testing/windows_test.h"
8 #include "gtest/gtest.h"
9 
10 namespace flutter {
11 namespace testing {
12 
13 class WindowsLifecycleManagerTest : public WindowsTest {};
14 
15 TEST_F(WindowsLifecycleManagerTest, StateTransitions) {
16  WindowsLifecycleManager manager(nullptr);
17  HWND win1 = reinterpret_cast<HWND>(1);
18  HWND win2 = reinterpret_cast<HWND>(2);
19 
20  // Hidden to inactive upon window shown.
23  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
24 
25  // Showing a second window does not change state.
27  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
28 
29  // Inactive to resumed upon window focus.
31  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
32 
33  // Showing a second window does not change state.
35  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
36 
37  // Unfocusing one window does not change state while another is focused.
39  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kResumed);
40 
41  // Unfocusing final remaining focused window transitions to inactive.
43  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
44 
45  // Hiding one of two visible windows does not change state.
47  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kInactive);
48 
49  // Hiding only visible window transitions to hidden.
51  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kHidden);
52 
53  // Transition directly from resumed to hidden when the window is hidden.
57  EXPECT_EQ(manager.GetLifecycleState(), AppLifecycleState::kHidden);
58 }
59 
60 } // namespace testing
61 } // namespace flutter
flutter::WindowsLifecycleManager::GetLifecycleState
AppLifecycleState GetLifecycleState()
Definition: windows_lifecycle_manager.h:75
flutter::AppLifecycleState::kHidden
@ kHidden
flutter::WindowStateEvent::kHide
@ kHide
windows_lifecycle_manager.h
flutter::testing::WindowsLifecycleManagerTest
Definition: windows_lifecycle_manager_unittests.cc:13
flutter::WindowsLifecycleManager::SetLifecycleState
virtual void SetLifecycleState(AppLifecycleState state)
Definition: windows_lifecycle_manager.cc:195
flutter::WindowStateEvent::kFocus
@ kFocus
flutter::AppLifecycleState::kInactive
@ kInactive
flutter::WindowStateEvent::kShow
@ kShow
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::WindowsLifecycleManager::OnWindowStateEvent
virtual void OnWindowStateEvent(HWND hwnd, WindowStateEvent event)
Definition: windows_lifecycle_manager.cc:208
flutter::AppLifecycleState::kResumed
@ kResumed
flutter::WindowStateEvent::kUnfocus
@ kUnfocus
flutter::testing::TEST_F
TEST_F(CompositorOpenGLTest, CreateBackingStore)
Definition: compositor_opengl_unittests.cc:125
flutter::WindowsLifecycleManager
Definition: windows_lifecycle_manager.h:37