#include "flutter/shell/platform/linux/fl_window_state_monitor.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_string_codec.h"
#include "flutter/shell/platform/linux/testing/fl_test.h"
#include "flutter/shell/platform/linux/testing/mock_binary_messenger.h"
#include "flutter/shell/platform/linux/testing/mock_window.h"
#include "gtest/gtest.h"
Go to the source code of this file.
|
::testing::Matcher< GBytes * > | LifecycleString (const std::string &value) |
|
| TEST (FlWindowStateMonitorTest, GainFocus) |
|
| TEST (FlWindowStateMonitorTest, LoseFocus) |
|
| TEST (FlWindowStateMonitorTest, EnterIconified) |
|
| TEST (FlWindowStateMonitorTest, LeaveIconified) |
|
| TEST (FlWindowStateMonitorTest, LeaveIconifiedFocused) |
|
| TEST (FlWindowStateMonitorTest, EnterWithdrawn) |
|
| TEST (FlWindowStateMonitorTest, LeaveWithdrawn) |
|
| TEST (FlWindowStateMonitorTest, LeaveWithdrawnFocused) |
|
◆ LifecycleString()
::testing::Matcher<GBytes*> LifecycleString |
( |
const std::string & |
value | ) |
|
◆ TEST() [1/8]
TEST |
( |
FlWindowStateMonitorTest |
, |
|
|
EnterIconified |
|
|
) |
| |
Definition at line 106 of file fl_window_state_monitor_test.cc.
107 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
108 ::testing::NiceMock<flutter::testing::MockWindow> mock_window;
110 gtk_init(0,
nullptr);
112 EXPECT_CALL(mock_window, gdk_window_get_state)
113 .WillOnce(::testing::Return(
static_cast<GdkWindowState
>(0)));
115 ::testing::Eq<FlBinaryMessenger*>(messenger),
116 ::testing::StrEq(
"flutter/lifecycle"),
118 ::testing::_, ::testing::_, ::testing::_));
120 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
121 gtk_widget_show(GTK_WIDGET(window));
122 g_autoptr(FlWindowStateMonitor) monitor =
126 .window_state = {.new_window_state = GDK_WINDOW_STATE_ICONIFIED}};
128 g_signal_emit_by_name(window,
"window-state-event", &
event, &handled);
References event, fl_binary_messenger_send_on_channel(), fl_window_state_monitor_new(), and LifecycleString().
◆ TEST() [2/8]
TEST |
( |
FlWindowStateMonitorTest |
, |
|
|
EnterWithdrawn |
|
|
) |
| |
Definition at line 182 of file fl_window_state_monitor_test.cc.
183 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
184 ::testing::NiceMock<flutter::testing::MockWindow> mock_window;
186 gtk_init(0,
nullptr);
188 EXPECT_CALL(mock_window, gdk_window_get_state)
189 .WillOnce(::testing::Return(
static_cast<GdkWindowState
>(0)));
191 ::testing::Eq<FlBinaryMessenger*>(messenger),
192 ::testing::StrEq(
"flutter/lifecycle"),
194 ::testing::_, ::testing::_, ::testing::_));
196 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
197 gtk_widget_show(GTK_WIDGET(window));
198 g_autoptr(FlWindowStateMonitor) monitor =
202 .window_state = {.new_window_state = GDK_WINDOW_STATE_WITHDRAWN}};
204 g_signal_emit_by_name(window,
"window-state-event", &
event, &handled);
References event, fl_binary_messenger_send_on_channel(), fl_window_state_monitor_new(), and LifecycleString().
◆ TEST() [3/8]
TEST |
( |
FlWindowStateMonitorTest |
, |
|
|
GainFocus |
|
|
) |
| |
Definition at line 56 of file fl_window_state_monitor_test.cc.
57 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
58 ::testing::NiceMock<flutter::testing::MockWindow> mock_window;
62 EXPECT_CALL(mock_window, gdk_window_get_state)
63 .WillOnce(::testing::Return(
static_cast<GdkWindowState
>(0)));
65 ::testing::Eq<FlBinaryMessenger*>(messenger),
66 ::testing::StrEq(
"flutter/lifecycle"),
68 ::testing::_, ::testing::_, ::testing::_));
70 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
71 gtk_widget_show(GTK_WIDGET(window));
72 g_autoptr(FlWindowStateMonitor) monitor =
76 .window_state = {.new_window_state = GDK_WINDOW_STATE_FOCUSED}};
78 g_signal_emit_by_name(window,
"window-state-event", &
event, &handled);
References event, fl_binary_messenger_send_on_channel(), fl_window_state_monitor_new(), and LifecycleString().
◆ TEST() [4/8]
TEST |
( |
FlWindowStateMonitorTest |
, |
|
|
LeaveIconified |
|
|
) |
| |
Definition at line 131 of file fl_window_state_monitor_test.cc.
132 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
133 ::testing::NiceMock<flutter::testing::MockWindow> mock_window;
135 gtk_init(0,
nullptr);
137 EXPECT_CALL(mock_window, gdk_window_get_state)
138 .WillOnce(::testing::Return(GDK_WINDOW_STATE_ICONIFIED));
140 ::testing::Eq<FlBinaryMessenger*>(messenger),
141 ::testing::StrEq(
"flutter/lifecycle"),
143 ::testing::_, ::testing::_, ::testing::_));
145 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
146 gtk_widget_show(GTK_WIDGET(window));
147 g_autoptr(FlWindowStateMonitor) monitor =
151 .window_state = {.new_window_state =
static_cast<GdkWindowState
>(0)}};
153 g_signal_emit_by_name(window,
"window-state-event", &
event, &handled);
References event, fl_binary_messenger_send_on_channel(), fl_window_state_monitor_new(), and LifecycleString().
◆ TEST() [5/8]
TEST |
( |
FlWindowStateMonitorTest |
, |
|
|
LeaveIconifiedFocused |
|
|
) |
| |
Definition at line 156 of file fl_window_state_monitor_test.cc.
157 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
158 ::testing::NiceMock<flutter::testing::MockWindow> mock_window;
160 gtk_init(0,
nullptr);
162 EXPECT_CALL(mock_window, gdk_window_get_state)
163 .WillOnce(::testing::Return(GDK_WINDOW_STATE_ICONIFIED));
165 ::testing::Eq<FlBinaryMessenger*>(messenger),
166 ::testing::StrEq(
"flutter/lifecycle"),
168 ::testing::_, ::testing::_, ::testing::_));
170 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
171 gtk_widget_show(GTK_WIDGET(window));
172 g_autoptr(FlWindowStateMonitor) monitor =
176 .window_state = {.new_window_state =
static_cast<GdkWindowState
>(
177 GDK_WINDOW_STATE_FOCUSED)}};
179 g_signal_emit_by_name(window,
"window-state-event", &
event, &handled);
References event, fl_binary_messenger_send_on_channel(), fl_window_state_monitor_new(), and LifecycleString().
◆ TEST() [6/8]
TEST |
( |
FlWindowStateMonitorTest |
, |
|
|
LeaveWithdrawn |
|
|
) |
| |
Definition at line 207 of file fl_window_state_monitor_test.cc.
208 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
209 ::testing::NiceMock<flutter::testing::MockWindow> mock_window;
211 gtk_init(0,
nullptr);
213 EXPECT_CALL(mock_window, gdk_window_get_state)
214 .WillOnce(::testing::Return(GDK_WINDOW_STATE_WITHDRAWN));
216 ::testing::Eq<FlBinaryMessenger*>(messenger),
217 ::testing::StrEq(
"flutter/lifecycle"),
219 ::testing::_, ::testing::_, ::testing::_));
221 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
222 gtk_widget_show(GTK_WIDGET(window));
223 g_autoptr(FlWindowStateMonitor) monitor =
227 .window_state = {.new_window_state =
static_cast<GdkWindowState
>(0)}};
229 g_signal_emit_by_name(window,
"window-state-event", &
event, &handled);
References event, fl_binary_messenger_send_on_channel(), fl_window_state_monitor_new(), and LifecycleString().
◆ TEST() [7/8]
TEST |
( |
FlWindowStateMonitorTest |
, |
|
|
LeaveWithdrawnFocused |
|
|
) |
| |
Definition at line 232 of file fl_window_state_monitor_test.cc.
233 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
234 ::testing::NiceMock<flutter::testing::MockWindow> mock_window;
236 gtk_init(0,
nullptr);
238 EXPECT_CALL(mock_window, gdk_window_get_state)
239 .WillOnce(::testing::Return(GDK_WINDOW_STATE_WITHDRAWN));
241 ::testing::Eq<FlBinaryMessenger*>(messenger),
242 ::testing::StrEq(
"flutter/lifecycle"),
244 ::testing::_, ::testing::_, ::testing::_));
246 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
247 gtk_widget_show(GTK_WIDGET(window));
248 g_autoptr(FlWindowStateMonitor) monitor =
252 .window_state = {.new_window_state =
static_cast<GdkWindowState
>(
253 GDK_WINDOW_STATE_FOCUSED)}};
255 g_signal_emit_by_name(window,
"window-state-event", &
event, &handled);
References event, fl_binary_messenger_send_on_channel(), fl_window_state_monitor_new(), and LifecycleString().
◆ TEST() [8/8]
TEST |
( |
FlWindowStateMonitorTest |
, |
|
|
LoseFocus |
|
|
) |
| |
Definition at line 81 of file fl_window_state_monitor_test.cc.
82 ::testing::NiceMock<flutter::testing::MockBinaryMessenger> messenger;
83 ::testing::NiceMock<flutter::testing::MockWindow> mock_window;
87 EXPECT_CALL(mock_window, gdk_window_get_state)
88 .WillOnce(::testing::Return(GDK_WINDOW_STATE_FOCUSED));
90 ::testing::Eq<FlBinaryMessenger*>(messenger),
91 ::testing::StrEq(
"flutter/lifecycle"),
93 ::testing::_, ::testing::_, ::testing::_));
95 GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
96 gtk_widget_show(GTK_WIDGET(window));
97 g_autoptr(FlWindowStateMonitor) monitor =
101 .window_state = {.new_window_state =
static_cast<GdkWindowState
>(0)}};
103 g_signal_emit_by_name(window,
"window-state-event", &
event, &handled);
References event, fl_binary_messenger_send_on_channel(), fl_window_state_monitor_new(), and LifecycleString().