OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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/system/overview/overview_button_tray.h" | |
6 | |
7 #include "ash/display/display_manager.h" | |
8 #include "ash/root_window_controller.h" | |
9 #include "ash/shelf/shelf_types.h" | |
10 #include "ash/shelf/shelf_widget.h" | |
11 #include "ash/shell.h" | |
12 #include "ash/system/status_area_widget.h" | |
13 #include "ash/test/ash_test_base.h" | |
14 #include "ash/wm/overview/window_selector_controller.h" | |
15 #include "base/time/time.h" | |
16 #include "ui/events/event.h" | |
17 #include "ui/events/event_constants.h" | |
18 #include "ui/events/gestures/gesture_types.h" | |
19 #include "ui/views/controls/image_view.h" | |
20 | |
21 namespace ash { | |
22 | |
23 namespace { | |
24 | |
25 OverviewButtonTray* GetTray() { | |
26 return Shell::GetPrimaryRootWindowController()->shelf()-> | |
27 status_area_widget()->overview_button_tray(); | |
28 } | |
29 | |
30 OverviewButtonTray* GetSecondaryTray() { | |
31 internal::RootWindowController* primary_controller = | |
32 Shell::GetPrimaryRootWindowController(); | |
33 Shell::RootWindowControllerList controllers = | |
34 Shell::GetAllRootWindowControllers(); | |
35 for (size_t i = 0; i < controllers.size(); ++i) { | |
36 if (controllers[i] != primary_controller) { | |
37 return controllers[i]->shelf()-> | |
38 status_area_widget()->overview_button_tray(); | |
39 } | |
40 } | |
41 | |
42 return NULL; | |
43 } | |
44 | |
45 } // namespace | |
46 | |
47 class OverviewButtonTrayTest : public test::AshTestBase { | |
48 public: | |
49 OverviewButtonTrayTest() {} | |
50 virtual ~OverviewButtonTrayTest() {} | |
51 | |
52 protected: | |
53 views::ImageView* GetImageView(OverviewButtonTray* tray) { | |
54 return tray->icon_; | |
55 } | |
56 | |
57 private: | |
58 DISALLOW_COPY_AND_ASSIGN(OverviewButtonTrayTest); | |
59 }; | |
60 | |
61 // Ensures that creation doesn't cause any crashes and adds the image icon. | |
62 TEST_F(OverviewButtonTrayTest, BasicConstruction) { | |
63 EXPECT_TRUE(GetImageView(GetTray()) != NULL); | |
64 } | |
65 | |
66 // Test that maximize mode toggle changes visibility. | |
67 // OverviewButtonTray should only be visible when MaximizeMode is enabled. | |
68 // By default the system should not have MaximizeMode enabled. | |
69 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { | |
70 ASSERT_FALSE(GetTray()->visible()); | |
71 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | |
72 EXPECT_TRUE(GetTray()->visible()); | |
73 | |
74 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | |
75 EXPECT_FALSE(GetTray()->visible()); | |
76 } | |
77 | |
78 // Tests that activating this control brings up window selection mode. | |
79 TEST_F(OverviewButtonTrayTest, PerformAction) { | |
80 ASSERT_FALSE(Shell::GetInstance()->window_selector_controller()-> | |
81 IsSelecting()); | |
82 | |
83 // Overview Mode only works when there is a window | |
84 scoped_ptr<aura::Window> window( | |
85 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | |
86 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), | |
87 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0.0f, 0.0f), 0); | |
88 GetTray()->PerformAction(tap); | |
89 EXPECT_TRUE(Shell::GetInstance()->window_selector_controller()-> | |
90 IsSelecting()); | |
jonross
2014/03/13 13:39:13
My concern is that I do not reset the window_selec
| |
91 } | |
92 | |
93 // Tests that a second OverviewButtonTray has been created, and only shows | |
94 // when MaximizeMode has been enabled, when we are using multiple displays. | |
95 // By default the DisplayManger is in extended mode. | |
96 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { | |
97 if (!SupportsMultipleDisplays()) | |
98 return; | |
99 | |
100 UpdateDisplay("400x400,200x200"); | |
101 EXPECT_FALSE(GetTray()->visible()); | |
102 EXPECT_FALSE(GetSecondaryTray()->visible()); | |
103 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | |
104 EXPECT_TRUE(GetTray()->visible()); | |
105 EXPECT_TRUE(GetSecondaryTray()->visible()); | |
106 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | |
107 } | |
108 | |
109 // Tests if Maximize Mode is enabled before a secondary display is attached | |
110 // that the second OverviewButtonTray should be created in a visible state. | |
111 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) { | |
112 if (!SupportsMultipleDisplays()) | |
113 return; | |
114 | |
115 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); | |
116 UpdateDisplay("400x400,200x200"); | |
117 EXPECT_TRUE(GetSecondaryTray()->visible()); | |
118 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | |
119 } | |
120 | |
121 } // namespace ash | |
OLD | NEW |