1// Copyright 2013 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.
4
5#include "ash/shell.h"
6#include "ash/shell_window_ids.h"
7#include "ash/test/ash_test_base.h"
8#include "ash/test/test_shell_delegate.h"
9#include "ash/wm/window_util.h"
10#include "base/memory/scoped_ptr.h"
11#include "ui/aura/test/test_windows.h"
12#include "ui/aura/window.h"
13
14namespace ash {
15
16typedef test::AshTestBase AppListControllerTest;
17
18// Tests that app launcher hides when focus moves to a normal window.
19TEST_F(AppListControllerTest, HideOnFocusOut) {
20  Shell::GetInstance()->ToggleAppList(NULL);
21  EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility());
22
23  scoped_ptr<aura::Window> window(CreateTestWindowInShellWithId(0));
24  wm::ActivateWindow(window.get());
25
26  EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility());
27}
28
29// Tests that app launcher remains visible when focus is moved to a different
30// window in kShellWindowId_AppListContainer.
31TEST_F(AppListControllerTest, RemainVisibleWhenFocusingToApplistContainer) {
32  Shell::GetInstance()->ToggleAppList(NULL);
33  EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility());
34
35  aura::Window* applist_container = Shell::GetContainer(
36      Shell::GetPrimaryRootWindow(),
37      internal::kShellWindowId_AppListContainer);
38  scoped_ptr<aura::Window> window(
39      aura::test::CreateTestWindowWithId(0, applist_container));
40  wm::ActivateWindow(window.get());
41
42  EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility());
43}
44
45}  // namespace ash
46