OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/drag_drop/drag_drop_controller.h" | 5 #include "ash/drag_drop/drag_drop_controller.h" |
6 #include "ash/root_window_controller.h" | 6 #include "ash/root_window_controller.h" |
7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/shell_window_ids.h" |
11 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/shelf_test_api.h" | 13 #include "ash/test/shelf_test_api.h" |
13 #include "ash/test/shelf_view_test_api.h" | 14 #include "ash/test/shelf_view_test_api.h" |
14 #include "ash/test/shell_test_api.h" | |
15 #include "ash/test/test_shelf_delegate.h" | 15 #include "ash/test/test_shelf_delegate.h" |
16 #include "ash/wm/mru_window_tracker.h" | 16 #include "ash/wm/mru_window_tracker.h" |
17 #include "ash/wm/overview/window_selector.h" | 17 #include "ash/wm/overview/window_selector.h" |
18 #include "ash/wm/overview/window_selector_controller.h" | 18 #include "ash/wm/overview/window_selector_controller.h" |
19 #include "ash/wm/window_state.h" | 19 #include "ash/wm/window_state.h" |
20 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
21 #include "ash/wm/wm_event.h" | 21 #include "ash/wm/wm_event.h" |
22 #include "base/basictypes.h" | 22 #include "base/basictypes.h" |
23 #include "base/compiler_specific.h" | 23 #include "base/compiler_specific.h" |
24 #include "base/memory/scoped_vector.h" | 24 #include "base/memory/scoped_vector.h" |
25 #include "base/run_loop.h" | 25 #include "base/run_loop.h" |
26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
27 #include "ui/aura/client/aura_constants.h" | 27 #include "ui/aura/client/aura_constants.h" |
28 #include "ui/aura/client/cursor_client.h" | 28 #include "ui/aura/client/cursor_client.h" |
29 #include "ui/aura/client/focus_client.h" | 29 #include "ui/aura/client/focus_client.h" |
30 #include "ui/aura/test/event_generator.h" | 30 #include "ui/aura/test/event_generator.h" |
31 #include "ui/aura/test/test_window_delegate.h" | 31 #include "ui/aura/test/test_window_delegate.h" |
32 #include "ui/aura/test/test_windows.h" | 32 #include "ui/aura/test/test_windows.h" |
33 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
34 #include "ui/aura/window_event_dispatcher.h" | 34 #include "ui/aura/window_event_dispatcher.h" |
35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
36 #include "ui/gfx/rect_conversions.h" | 36 #include "ui/gfx/rect_conversions.h" |
37 #include "ui/gfx/transform.h" | 37 #include "ui/gfx/transform.h" |
| 38 #include "ui/views/controls/label.h" |
| 39 #include "ui/views/widget/native_widget_aura.h" |
38 #include "ui/wm/core/window_util.h" | 40 #include "ui/wm/core/window_util.h" |
39 #include "ui/wm/public/activation_delegate.h" | 41 #include "ui/wm/public/activation_delegate.h" |
40 | 42 |
41 namespace ash { | 43 namespace ash { |
42 namespace { | 44 namespace { |
43 | 45 |
44 class NonActivatableActivationDelegate | 46 class NonActivatableActivationDelegate |
45 : public aura::client::ActivationDelegate { | 47 : public aura::client::ActivationDelegate { |
46 public: | 48 public: |
47 virtual bool ShouldActivate() const OVERRIDE { | 49 virtual bool ShouldActivate() const OVERRIDE { |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 | 1082 |
1081 for (size_t p = 0; p < arraysize(points); ++p) { | 1083 for (size_t p = 0; p < arraysize(points); ++p) { |
1082 ui::MouseEvent event(ui::ET_MOUSE_MOVED, points[p], points[p], | 1084 ui::MouseEvent event(ui::ET_MOUSE_MOVED, points[p], points[p], |
1083 ui::EF_NONE, ui::EF_NONE); | 1085 ui::EF_NONE, ui::EF_NONE); |
1084 EXPECT_EQ(windows[w], | 1086 EXPECT_EQ(windows[w], |
1085 targeter->FindTargetForEvent(root_target, &event)); | 1087 targeter->FindTargetForEvent(root_target, &event)); |
1086 } | 1088 } |
1087 } | 1089 } |
1088 } | 1090 } |
1089 | 1091 |
| 1092 // Test that a label is created under the window on entering overview mode. |
| 1093 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) { |
| 1094 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100))); |
| 1095 base::string16 window_title = base::UTF8ToUTF16("My window"); |
| 1096 window->set_title(window_title); |
| 1097 aura::Window* root_window = Shell::GetContainer( |
| 1098 window->GetRootWindow(), |
| 1099 ash::kShellWindowId_OverlayContainer); |
| 1100 unsigned int children = root_window->children().size(); |
| 1101 ToggleOverview(); |
| 1102 // There should be two more windows, one for the close button and one for the |
| 1103 // label. |
| 1104 EXPECT_EQ(children + 2, root_window->children().size()) |
| 1105 << root_window->children().size() - children |
| 1106 << " windows have been added instead of the expected 2."; |
| 1107 // The window that contains the label is always the last one in the windows |
| 1108 // vector. |
| 1109 aura::Window* label_window = root_window->children().back(); |
| 1110 aura::WindowDelegate* delegate = label_window->delegate(); |
| 1111 views::NativeWidgetAura* native_delegate = |
| 1112 static_cast<views::NativeWidgetAura*>(delegate); |
| 1113 views::Widget* widget = native_delegate->GetWidget(); |
| 1114 ASSERT_TRUE(widget); |
| 1115 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); |
| 1116 EXPECT_EQ(label->text(), window_title); |
| 1117 StopCycling(); |
| 1118 } |
| 1119 |
| 1120 // Test that a label is created under the panel on entering overview mode. |
| 1121 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) { |
| 1122 scoped_ptr<aura::Window> panel(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); |
| 1123 base::string16 panel_title = base::UTF8ToUTF16("My panel"); |
| 1124 panel->set_title(panel_title); |
| 1125 aura::Window* root_window = Shell::GetContainer( |
| 1126 panel->GetRootWindow(), |
| 1127 ash::kShellWindowId_OverlayContainer); |
| 1128 Cycle(WindowSelector::FORWARD); |
| 1129 unsigned int children = root_window->children().size(); |
| 1130 FireOverviewStartTimer(); |
| 1131 // There should be only one additional window, since panels don't have close |
| 1132 // buttons. |
| 1133 EXPECT_EQ(children + 1, root_window->children().size()) |
| 1134 << root_window->children().size() - children |
| 1135 << " windows have been added instead of the expected 1."; |
| 1136 // The window that contains the label is always the last one in the windows |
| 1137 // vector. |
| 1138 aura::Window* label_window = root_window->children().back(); |
| 1139 aura::WindowDelegate* delegate = label_window->delegate(); |
| 1140 views::NativeWidgetAura* native_delegate = |
| 1141 static_cast<views::NativeWidgetAura*>(delegate); |
| 1142 views::Widget* widget = native_delegate->GetWidget(); |
| 1143 ASSERT_TRUE(widget); |
| 1144 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); |
| 1145 EXPECT_EQ(label->text(), panel_title); |
| 1146 StopCycling(); |
| 1147 } |
| 1148 |
1090 } // namespace ash | 1149 } // namespace ash |
OLD | NEW |