1 // Copyright 2015 The Chromium 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.
6 #include "ash/shell_window_ids.h"
7 #include "ash/test/ash_test_base.h"
8 #include "ash/wm/session_state_animator.h"
9 #include "ash/wm/session_state_animator_impl.h"
10 #include "ui/aura/client/aura_constants.h"
12 typedef ash::test::AshTestBase SessionStateAnimatiorImplContainersTest
;
17 bool ParentHasWindowWithId(const aura::Window
* window
, int id
) {
18 return window
->parent()->id() == id
;
21 bool ContainersHaveWindowWithId(const aura::Window::Windows windows
, int id
) {
22 for (const aura::Window
* window
: windows
) {
23 if (window
->id() == id
)
31 TEST_F(SessionStateAnimatiorImplContainersTest
, ContainersHaveIdTest
) {
32 aura::Window::Windows containers
;
34 // Test ROOT_CONTAINER mask.
35 aura::Window
* root_window
= Shell::GetPrimaryRootWindow();
36 SessionStateAnimatorImpl::GetContainers(SessionStateAnimator::ROOT_CONTAINER
,
38 EXPECT_EQ(root_window
, containers
[0]);
42 SessionStateAnimatorImpl::GetContainers(
43 SessionStateAnimator::DESKTOP_BACKGROUND
, &containers
);
44 EXPECT_TRUE(ContainersHaveWindowWithId(
45 containers
, kShellWindowId_DesktopBackgroundContainer
));
49 // Check for shelf in launcher.
50 SessionStateAnimatorImpl::GetContainers(SessionStateAnimator::LAUNCHER
,
53 ContainersHaveWindowWithId(containers
, kShellWindowId_ShelfContainer
));
57 SessionStateAnimatorImpl::GetContainers(
58 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS
, &containers
);
59 EXPECT_TRUE(ParentHasWindowWithId(
60 containers
[0], kShellWindowId_NonLockScreenContainersContainer
));
64 // Check for lock screen containers.
65 SessionStateAnimatorImpl::GetContainers(
66 SessionStateAnimator::LOCK_SCREEN_BACKGROUND
, &containers
);
67 EXPECT_TRUE(ContainersHaveWindowWithId(
68 containers
, kShellWindowId_LockScreenBackgroundContainer
));
72 // Check for the lock screen containers container.
73 SessionStateAnimatorImpl::GetContainers(
74 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS
, &containers
);
75 EXPECT_TRUE(ContainersHaveWindowWithId(
76 containers
, kShellWindowId_LockScreenRelatedContainersContainer
));
78 // Empty mask should clear the container.
79 SessionStateAnimatorImpl::GetContainers(0, &containers
);
80 EXPECT_TRUE(containers
.empty());