Chromium Code Reviews| 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) { | |
|
tdanderson
2014/04/14 16:58:39
Be sure to put these new test names in the coderev
Nina
2014/04/14 17:59:17
Done.
| |
| 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 Cycle(WindowSelector::FORWARD); | |
| 1101 unsigned int children = root_window->children().size(); | |
| 1102 FireOverviewStartTimer(); | |
| 1103 // There should be two more windows, one for the close button and one for the | |
| 1104 // label. | |
| 1105 EXPECT_TRUE(children + 2 == root_window->children().size()) | |
|
tdanderson
2014/04/14 16:58:39
Use EXPECT_EQ here instead of EXPECT_TRUE.
Nina
2014/04/14 17:59:17
Done.
| |
| 1106 << root_window->children().size() - children | |
| 1107 << " windows have been added instead of the expected 2."; | |
| 1108 // The window that contains the label is always the last one in the windows | |
| 1109 // vector. | |
| 1110 aura::Window* label_window = root_window->children().back(); | |
| 1111 aura::WindowDelegate* delegate = label_window->delegate(); | |
| 1112 views::NativeWidgetAura* native_delegate = | |
| 1113 static_cast<views::NativeWidgetAura*>(delegate); | |
| 1114 views::Widget* widget = native_delegate->GetWidget(); | |
| 1115 ASSERT(widget); | |
| 1116 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); | |
| 1117 EXPECT_EQ(label->text(), window_title); | |
| 1118 StopCycling(); | |
| 1119 } | |
| 1120 | |
| 1121 // Test that a label is created under the panel on entering overview mode. | |
| 1122 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) { | |
| 1123 scoped_ptr<aura::Window> panel(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); | |
| 1124 base::string16 panel_title = base::UTF8ToUTF16("My panel"); | |
| 1125 panel->set_title(panel_title); | |
| 1126 aura::Window* root_window = Shell::GetContainer( | |
| 1127 panel->GetRootWindow(), | |
| 1128 ash::kShellWindowId_OverlayContainer); | |
| 1129 Cycle(WindowSelector::FORWARD); | |
| 1130 unsigned int children = root_window->children().size(); | |
| 1131 FireOverviewStartTimer(); | |
| 1132 // There should be only one additional window, since panels don't have close | |
| 1133 // buttons. | |
| 1134 EXPECT_TRUE(children + 1 == root_window->children().size()) | |
|
tdanderson
2014/04/14 16:58:39
EXPECT_EQ
Nina
2014/04/14 17:59:17
Done.
| |
| 1135 << root_window->children().size() - children | |
| 1136 << " windows have been added instead of the expected 1."; | |
| 1137 // The window that contains the label is always the last one in the windows | |
| 1138 // vector. | |
| 1139 aura::Window* label_window = root_window->children().back(); | |
| 1140 aura::WindowDelegate* delegate = label_window->delegate(); | |
| 1141 views::NativeWidgetAura* native_delegate = | |
| 1142 static_cast<views::NativeWidgetAura*>(delegate); | |
| 1143 views::Widget* widget = native_delegate->GetWidget(); | |
| 1144 ASSERT(widget); | |
| 1145 views::Label* label = static_cast<views::Label*>(widget->GetContentsView()); | |
| 1146 EXPECT_EQ(label->text(), panel_title); | |
| 1147 StopCycling(); | |
| 1148 } | |
| 1149 | |
| 1090 } // namespace ash | 1150 } // namespace ash |
| OLD | NEW |