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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
ash / user_education / welcome_tour / welcome_tour_window_minimizer_unittest.cc [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/user_education/welcome_tour/welcome_tour_window_minimizer.h"
#include "ash/user_education/user_education_ash_test_base.h"
#include "ash/user_education/welcome_tour/welcome_tour_test_util.h"
#include "ash/wm/window_state.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ash {
namespace {
// Aliases ---------------------------------------------------------------------
using ::testing::Eq;
} // namespace
// WelcomeTourWindowMinimizerTest ----------------------------------------------
// Base class for tests of the `WelcomeTourWindowMinimizer`.
using WelcomeTourWindowMinimizerTest = UserEducationAshTestBase;
// Tests -----------------------------------------------------------------------
// Verifies that minimization only occurs when `WelcomeTourWindowMinimizer` is
// in scope.
TEST_F(WelcomeTourWindowMinimizerTest, Scope) {
std::unique_ptr<aura::Window> window_1 = CreateAppWindow();
std::unique_ptr<aura::Window> window_2;
// Initial state. Windows should not be minimized by default.
EXPECT_THAT(window_1, Minimized(Eq(false)));
{
// Case: In scope. Any previously existing windows should be minimized, as
// well as any newly created ones.
WelcomeTourWindowMinimizer minimizer;
EXPECT_TRUE(WaitUntilMinimized(window_1.get()));
window_2 = CreateAppWindow();
EXPECT_TRUE(WaitUntilMinimized(window_2.get()));
}
// Case: Out of scope.
EXPECT_THAT(window_1, Minimized(Eq(true)));
EXPECT_THAT(window_2, Minimized(Eq(true)));
// Case: Window created out of scope.
auto window_3 = CreateAppWindow();
EXPECT_THAT(window_3, Minimized(Eq(false)));
}
// Verifies that windows will be minimized on displays added after the minimizer
// is initialized.
TEST_F(WelcomeTourWindowMinimizerTest, NewDisplay) {
WelcomeTourWindowMinimizer minimizer;
UpdateDisplay("500x400,500x400");
auto window = CreateAppWindow(GetSecondaryDisplay().bounds());
EXPECT_TRUE(WaitUntilMinimized(window.get()));
}
// Verifies that if a window is unminimized through user action or
// programmatically, it is immediately reminimized.
TEST_F(WelcomeTourWindowMinimizerTest, SquelchUnminimization) {
WelcomeTourWindowMinimizer minimizer;
auto window = CreateAppWindow();
EXPECT_TRUE(WaitUntilMinimized(window.get()));
auto* state = WindowState::Get(window.get());
ASSERT_TRUE(state);
state->Unminimize();
EXPECT_TRUE(WaitUntilMinimized(window.get()));
}
} // namespace ash