OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/launcher/launcher_context_menu.h" | 5 #include "ash/launcher/launcher_context_menu.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
9 #include "ash/wm/property_util.h" | 9 #include "ash/wm/property_util.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/base/ui_base_types.h" | 13 #include "ui/base/ui_base_types.h" |
14 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
15 | 15 |
16 namespace ash { | 16 namespace ash { |
17 | 17 |
18 typedef test::AshTestBase LauncherContextMenuTest; | 18 typedef test::AshTestBase LauncherContextMenuTest; |
19 | 19 |
20 // Various assertions around IsAutoHideMenuHideChecked() and | 20 // Various assertions around IsAutoHideMenuHideChecked() and |
21 // ToggleAutoHideMenu(). | 21 // ToggleAutoHideMenu(). |
22 TEST_F(LauncherContextMenuTest, ToggleAutoHide) { | 22 TEST_F(LauncherContextMenuTest, ToggleAutoHide) { |
23 scoped_ptr<aura::Window> window(new aura::Window(NULL)); | 23 scoped_ptr<aura::Window> window(new aura::Window(NULL)); |
24 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 24 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
25 window->SetType(aura::client::WINDOW_TYPE_NORMAL); | 25 window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
26 window->Init(ui::LAYER_TEXTURED); | 26 window->Init(ui::LAYER_TEXTURED); |
27 window->SetParent(NULL); | 27 window->SetParent(NULL); |
28 window->Show(); | 28 window->Show(); |
| 29 wm::ActivateWindow(window.get()); |
29 | 30 |
30 Shell* shell = Shell::GetInstance(); | 31 Shell* shell = Shell::GetInstance(); |
31 // If the auto-hide behavior isn't DEFAULT, the rest of the tests don't make | 32 // If the auto-hide behavior isn't DEFAULT, the rest of the tests don't make |
32 // sense. | 33 // sense. |
33 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT, | 34 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT, |
34 shell->GetShelfAutoHideBehavior()); | 35 shell->GetShelfAutoHideBehavior()); |
35 EXPECT_FALSE(LauncherContextMenu::IsAutoHideMenuHideChecked()); | 36 EXPECT_FALSE(LauncherContextMenu::IsAutoHideMenuHideChecked()); |
36 shell->SetShelfAutoHideBehavior( | 37 shell->SetShelfAutoHideBehavior( |
37 LauncherContextMenu::GetToggledAutoHideBehavior()); | 38 LauncherContextMenu::GetToggledAutoHideBehavior()); |
38 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, | 39 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
39 shell->GetShelfAutoHideBehavior()); | 40 shell->GetShelfAutoHideBehavior()); |
40 shell->SetShelfAutoHideBehavior( | 41 shell->SetShelfAutoHideBehavior( |
41 LauncherContextMenu::GetToggledAutoHideBehavior()); | 42 LauncherContextMenu::GetToggledAutoHideBehavior()); |
42 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT, | 43 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT, |
43 shell->GetShelfAutoHideBehavior()); | 44 shell->GetShelfAutoHideBehavior()); |
44 | 45 |
45 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 46 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
46 EXPECT_TRUE(LauncherContextMenu::IsAutoHideMenuHideChecked()); | 47 EXPECT_TRUE(LauncherContextMenu::IsAutoHideMenuHideChecked()); |
47 shell->SetShelfAutoHideBehavior( | 48 shell->SetShelfAutoHideBehavior( |
48 LauncherContextMenu::GetToggledAutoHideBehavior()); | 49 LauncherContextMenu::GetToggledAutoHideBehavior()); |
49 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, | 50 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
50 shell->GetShelfAutoHideBehavior()); | 51 shell->GetShelfAutoHideBehavior()); |
51 shell->SetShelfAutoHideBehavior( | 52 shell->SetShelfAutoHideBehavior( |
52 LauncherContextMenu::GetToggledAutoHideBehavior()); | 53 LauncherContextMenu::GetToggledAutoHideBehavior()); |
53 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT, | 54 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT, |
54 shell->GetShelfAutoHideBehavior()); | 55 shell->GetShelfAutoHideBehavior()); |
55 } | 56 } |
56 | 57 |
57 } // namespace ash | 58 } // namespace ash |
OLD | NEW |