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/shell_test_api.h" |
15 #include "ash/test/test_shelf_delegate.h" | 16 #include "ash/test/test_shelf_delegate.h" |
16 #include "ash/wm/mru_window_tracker.h" | 17 #include "ash/wm/mru_window_tracker.h" |
17 #include "ash/wm/overview/window_selector.h" | 18 #include "ash/wm/overview/window_selector.h" |
18 #include "ash/wm/overview/window_selector_controller.h" | 19 #include "ash/wm/overview/window_selector_controller.h" |
20 #include "ash/wm/overview/window_selector_item.h" | |
19 #include "ash/wm/window_state.h" | 21 #include "ash/wm/window_state.h" |
20 #include "ash/wm/window_util.h" | 22 #include "ash/wm/window_util.h" |
21 #include "ash/wm/wm_event.h" | 23 #include "ash/wm/wm_event.h" |
22 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
23 #include "base/compiler_specific.h" | 25 #include "base/compiler_specific.h" |
24 #include "base/memory/scoped_vector.h" | 26 #include "base/memory/scoped_vector.h" |
25 #include "base/run_loop.h" | 27 #include "base/run_loop.h" |
26 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
27 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
28 #include "ui/aura/client/cursor_client.h" | 30 #include "ui/aura/client/cursor_client.h" |
29 #include "ui/aura/client/focus_client.h" | 31 #include "ui/aura/client/focus_client.h" |
30 #include "ui/aura/test/event_generator.h" | 32 #include "ui/aura/test/event_generator.h" |
31 #include "ui/aura/test/test_window_delegate.h" | 33 #include "ui/aura/test/test_window_delegate.h" |
32 #include "ui/aura/test/test_windows.h" | 34 #include "ui/aura/test/test_windows.h" |
33 #include "ui/aura/window.h" | 35 #include "ui/aura/window.h" |
34 #include "ui/aura/window_event_dispatcher.h" | 36 #include "ui/aura/window_event_dispatcher.h" |
35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 37 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
36 #include "ui/gfx/rect_conversions.h" | 38 #include "ui/gfx/rect_conversions.h" |
37 #include "ui/gfx/transform.h" | 39 #include "ui/gfx/transform.h" |
40 #include "ui/views/controls/label.h" | |
41 #include "ui/views/widget/native_widget_aura.h" | |
38 #include "ui/wm/core/window_util.h" | 42 #include "ui/wm/core/window_util.h" |
39 #include "ui/wm/public/activation_delegate.h" | 43 #include "ui/wm/public/activation_delegate.h" |
40 | 44 |
41 namespace ash { | 45 namespace ash { |
42 namespace { | 46 namespace { |
43 | 47 |
44 class NonActivatableActivationDelegate | 48 class NonActivatableActivationDelegate |
45 : public aura::client::ActivationDelegate { | 49 : public aura::client::ActivationDelegate { |
46 public: | 50 public: |
47 virtual bool ShouldActivate() const OVERRIDE { | 51 virtual bool ShouldActivate() const OVERRIDE { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 } | 222 } |
219 | 223 |
220 bool IsSelecting() { | 224 bool IsSelecting() { |
221 return ash::Shell::GetInstance()->window_selector_controller()-> | 225 return ash::Shell::GetInstance()->window_selector_controller()-> |
222 IsSelecting(); | 226 IsSelecting(); |
223 } | 227 } |
224 | 228 |
225 aura::Window* GetFocusedWindow() { | 229 aura::Window* GetFocusedWindow() { |
226 return aura::client::GetFocusClient( | 230 return aura::client::GetFocusClient( |
227 Shell::GetPrimaryRootWindow())->GetFocusedWindow(); | 231 Shell::GetPrimaryRootWindow())->GetFocusedWindow(); |
232 } | |
233 | |
234 ScopedVector<WindowSelectorItem>* GetWindowItems() { | |
235 return &(ash::Shell::GetInstance()->window_selector_controller()-> | |
236 window_selector_->windows_); | |
237 } | |
238 | |
239 views::Widget* GetLabelWidget(ash::WindowSelectorItem* window) { | |
240 return window->window_label_.get(); | |
228 } | 241 } |
229 | 242 |
230 test::ShelfViewTestAPI* shelf_view_test() { | 243 test::ShelfViewTestAPI* shelf_view_test() { |
231 return shelf_view_test_.get(); | 244 return shelf_view_test_.get(); |
232 } | 245 } |
233 | 246 |
234 private: | 247 private: |
235 aura::test::TestWindowDelegate delegate_; | 248 aura::test::TestWindowDelegate delegate_; |
236 NonActivatableActivationDelegate non_activatable_activation_delegate_; | 249 NonActivatableActivationDelegate non_activatable_activation_delegate_; |
237 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 250 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1080 | 1093 |
1081 for (size_t p = 0; p < arraysize(points); ++p) { | 1094 for (size_t p = 0; p < arraysize(points); ++p) { |
1082 ui::MouseEvent event(ui::ET_MOUSE_MOVED, points[p], points[p], | 1095 ui::MouseEvent event(ui::ET_MOUSE_MOVED, points[p], points[p], |
1083 ui::EF_NONE, ui::EF_NONE); | 1096 ui::EF_NONE, ui::EF_NONE); |
1084 EXPECT_EQ(windows[w], | 1097 EXPECT_EQ(windows[w], |
1085 targeter->FindTargetForEvent(root_target, &event)); | 1098 targeter->FindTargetForEvent(root_target, &event)); |
1086 } | 1099 } |
1087 } | 1100 } |
1088 } | 1101 } |
1089 | 1102 |
1103 // Test that a label is created under the window on entering overview mode. | |
1104 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) { | |
1105 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100))); | |
1106 base::string16 window_title = base::UTF8ToUTF16("My window"); | |
1107 window->set_title(window_title); | |
1108 ToggleOverview(); | |
1109 WindowSelectorItem* window_item = GetWindowItems()->back(); | |
1110 views::Widget* widget = GetLabelWidget(window_item); | |
1111 // Has the label widget been created? | |
1112 ASSERT_TRUE(widget); | |
1113 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); | |
1114 // Verify the label matches the window title. | |
1115 EXPECT_EQ(label->text(), window_title); | |
1116 // Labels are located based on target_bounds, not the actual window item | |
1117 // bounds. | |
1118 gfx::Rect target_bounds(window_item->target_bounds()); | |
1119 gfx::Rect expected_label_bounds(target_bounds.x(), | |
1120 target_bounds.y() + target_bounds.height(), | |
1121 target_bounds.width(), | |
1122 20); | |
1123 gfx::Rect real_label_bounds = widget->GetNativeWindow()->bounds(); | |
1124 EXPECT_EQ(widget->GetNativeWindow()->bounds(), real_label_bounds); | |
1125 } | |
1126 | |
1127 // Test that a label is created under the panel on entering overview mode. | |
flackr
2014/04/17 03:44:29
I think the only thing that's special about panels
Nina
2014/04/17 15:02:19
Done.
| |
1128 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) { | |
1129 scoped_ptr<aura::Window> window(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); | |
1130 base::string16 window_title = base::UTF8ToUTF16("My panel"); | |
1131 window->set_title(window_title); | |
1132 ToggleOverview(); | |
1133 WindowSelectorItem* window_item = GetWindowItems()->back(); | |
1134 views::Widget* widget = GetLabelWidget(window_item); | |
1135 // Has the label widget been created? | |
1136 ASSERT_TRUE(widget); | |
1137 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); | |
1138 // Verify the label matches the window title. | |
1139 EXPECT_EQ(label->text(), window_title); | |
1140 } | |
1141 | |
1090 } // namespace ash | 1142 } // namespace ash |
OLD | NEW |