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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "ash/root_window_controller.h" | 23 #include "ash/root_window_controller.h" |
24 #include "ash/shelf/shelf.h" | 24 #include "ash/shelf/shelf.h" |
25 #include "ash/shelf/shelf_layout_manager_observer.h" | 25 #include "ash/shelf/shelf_layout_manager_observer.h" |
26 #include "ash/shelf/shelf_locking_manager.h" | 26 #include "ash/shelf/shelf_locking_manager.h" |
27 #include "ash/shelf/shelf_view.h" | 27 #include "ash/shelf/shelf_view.h" |
28 #include "ash/shelf/shelf_widget.h" | 28 #include "ash/shelf/shelf_widget.h" |
29 #include "ash/shell.h" | 29 #include "ash/shell.h" |
30 #include "ash/test/ash_test_base.h" | 30 #include "ash/test/ash_test_base.h" |
31 #include "ash/test/display_manager_test_api.h" | 31 #include "ash/test/display_manager_test_api.h" |
32 #include "ash/test/shelf_test_api.h" | 32 #include "ash/test/shelf_test_api.h" |
| 33 #include "ash/test/test_system_tray_item.h" |
33 #include "ash/wm/window_state_aura.h" | 34 #include "ash/wm/window_state_aura.h" |
34 #include "ash/wm/window_util.h" | 35 #include "ash/wm/window_util.h" |
35 #include "base/command_line.h" | 36 #include "base/command_line.h" |
36 #include "base/strings/utf_string_conversions.h" | |
37 #include "ui/aura/client/aura_constants.h" | 37 #include "ui/aura/client/aura_constants.h" |
38 #include "ui/aura/client/window_tree_client.h" | 38 #include "ui/aura/client/window_tree_client.h" |
39 #include "ui/aura/window.h" | 39 #include "ui/aura/window.h" |
40 #include "ui/aura/window_event_dispatcher.h" | 40 #include "ui/aura/window_event_dispatcher.h" |
41 #include "ui/compositor/layer.h" | 41 #include "ui/compositor/layer.h" |
42 #include "ui/compositor/layer_animator.h" | 42 #include "ui/compositor/layer_animator.h" |
43 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 43 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
44 #include "ui/display/display.h" | 44 #include "ui/display/display.h" |
45 #include "ui/display/manager/display_layout.h" | 45 #include "ui/display/manager/display_layout.h" |
46 #include "ui/display/screen.h" | 46 #include "ui/display/screen.h" |
47 #include "ui/events/gesture_detection/gesture_configuration.h" | 47 #include "ui/events/gesture_detection/gesture_configuration.h" |
48 #include "ui/events/test/event_generator.h" | 48 #include "ui/events/test/event_generator.h" |
49 #include "ui/views/controls/label.h" | |
50 #include "ui/views/layout/fill_layout.h" | |
51 #include "ui/views/view.h" | 49 #include "ui/views/view.h" |
52 #include "ui/views/widget/widget.h" | 50 #include "ui/views/widget/widget.h" |
53 | 51 |
54 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
55 #include "base/win/windows_version.h" | 53 #include "base/win/windows_version.h" |
56 #endif | 54 #endif |
57 | 55 |
58 namespace ash { | 56 namespace ash { |
59 namespace { | 57 namespace { |
60 | 58 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 // ShelfLayoutManagerObserver: | 254 // ShelfLayoutManagerObserver: |
257 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override { | 255 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override { |
258 changed_auto_hide_state_ = true; | 256 changed_auto_hide_state_ = true; |
259 } | 257 } |
260 | 258 |
261 bool changed_auto_hide_state_; | 259 bool changed_auto_hide_state_; |
262 | 260 |
263 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); | 261 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); |
264 }; | 262 }; |
265 | 263 |
266 // Trivial item implementation that tracks its views for testing. | |
267 class TestItem : public SystemTrayItem { | |
268 public: | |
269 TestItem() | |
270 : SystemTrayItem(GetSystemTray()), | |
271 tray_view_(nullptr), | |
272 default_view_(nullptr), | |
273 detailed_view_(nullptr), | |
274 notification_view_(nullptr) {} | |
275 | |
276 views::View* CreateTrayView(LoginStatus status) override { | |
277 tray_view_ = new views::View; | |
278 // Add a label so it has non-zero width. | |
279 tray_view_->SetLayoutManager(new views::FillLayout); | |
280 tray_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Tray"))); | |
281 return tray_view_; | |
282 } | |
283 | |
284 views::View* CreateDefaultView(LoginStatus status) override { | |
285 default_view_ = new views::View; | |
286 default_view_->SetLayoutManager(new views::FillLayout); | |
287 default_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Default"))); | |
288 return default_view_; | |
289 } | |
290 | |
291 views::View* CreateDetailedView(LoginStatus status) override { | |
292 detailed_view_ = new views::View; | |
293 detailed_view_->SetLayoutManager(new views::FillLayout); | |
294 detailed_view_->AddChildView( | |
295 new views::Label(base::UTF8ToUTF16("Detailed"))); | |
296 return detailed_view_; | |
297 } | |
298 | |
299 views::View* CreateNotificationView(LoginStatus status) override { | |
300 notification_view_ = new views::View; | |
301 return notification_view_; | |
302 } | |
303 | |
304 void DestroyTrayView() override { tray_view_ = nullptr; } | |
305 | |
306 void DestroyDefaultView() override { default_view_ = nullptr; } | |
307 | |
308 void DestroyDetailedView() override { detailed_view_ = nullptr; } | |
309 | |
310 void DestroyNotificationView() override { notification_view_ = nullptr; } | |
311 | |
312 void UpdateAfterLoginStatusChange(LoginStatus status) override {} | |
313 | |
314 views::View* tray_view() const { return tray_view_; } | |
315 views::View* default_view() const { return default_view_; } | |
316 views::View* detailed_view() const { return detailed_view_; } | |
317 views::View* notification_view() const { return notification_view_; } | |
318 | |
319 private: | |
320 views::View* tray_view_; | |
321 views::View* default_view_; | |
322 views::View* detailed_view_; | |
323 views::View* notification_view_; | |
324 | |
325 DISALLOW_COPY_AND_ASSIGN(TestItem); | |
326 }; | |
327 | |
328 } // namespace | 264 } // namespace |
329 | 265 |
330 class ShelfLayoutManagerTest : public test::AshTestBase { | 266 class ShelfLayoutManagerTest : public test::AshTestBase { |
331 public: | 267 public: |
332 ShelfLayoutManagerTest() {} | 268 ShelfLayoutManagerTest() {} |
333 | 269 |
334 // Calls the private SetState() function. | 270 // Calls the private SetState() function. |
335 void SetState(ShelfLayoutManager* layout_manager, | 271 void SetState(ShelfLayoutManager* layout_manager, |
336 ShelfVisibilityState state) { | 272 ShelfVisibilityState state) { |
337 layout_manager->SetState(state); | 273 layout_manager->SetState(state); |
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 status_area_widget->GetWindowBoundsInScreen().CenterPoint(); | 2053 status_area_widget->GetWindowBoundsInScreen().CenterPoint(); |
2118 generator.MoveMouseTo(center.x(), center.y()); | 2054 generator.MoveMouseTo(center.x(), center.y()); |
2119 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 2055 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
2120 EXPECT_TRUE(layout_manager->IsVisible()); | 2056 EXPECT_TRUE(layout_manager->IsVisible()); |
2121 if (!i) { | 2057 if (!i) { |
2122 // In our first iteration we make sure there is no bubble. | 2058 // In our first iteration we make sure there is no bubble. |
2123 tray->CloseSystemBubble(); | 2059 tray->CloseSystemBubble(); |
2124 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2060 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
2125 } else { | 2061 } else { |
2126 // In our second iteration we show a bubble. | 2062 // In our second iteration we show a bubble. |
2127 TestItem* item = new TestItem; | 2063 test::TestSystemTrayItem* item = new test::TestSystemTrayItem(); |
2128 tray->AddTrayItem(item); | 2064 tray->AddTrayItem(item); |
2129 tray->ShowNotificationView(item); | 2065 tray->ShowNotificationView(item); |
2130 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2066 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
2131 } | 2067 } |
2132 // Move the pointer over the edge of the shelf. | 2068 // Move the pointer over the edge of the shelf. |
2133 generator.MoveMouseTo( | 2069 generator.MoveMouseTo( |
2134 center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8); | 2070 center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8); |
2135 layout_manager->UpdateVisibilityState(); | 2071 layout_manager->UpdateVisibilityState(); |
2136 if (i) { | 2072 if (i) { |
2137 EXPECT_TRUE(layout_manager->IsVisible()); | 2073 EXPECT_TRUE(layout_manager->IsVisible()); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2282 ->shelf_widget() | 2218 ->shelf_widget() |
2283 ->status_area_widget(); | 2219 ->status_area_widget(); |
2284 EXPECT_TRUE(status_area_widget->IsVisible()); | 2220 EXPECT_TRUE(status_area_widget->IsVisible()); |
2285 // Shelf should be in the first display's area. | 2221 // Shelf should be in the first display's area. |
2286 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 2222 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
2287 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 2223 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
2288 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 2224 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
2289 } | 2225 } |
2290 | 2226 |
2291 } // namespace ash | 2227 } // namespace ash |
OLD | NEW |