Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Side by Side Diff: ash/wm/overview/window_selector_unittest.cc

Issue 231643002: Added labels under the windows in OverviewMode displaying their current name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed latest issues Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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.bottom(),
1121 target_bounds.width(),
1122 label->GetPreferredSize().height());
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 15:08:33 nit: Update comment here: Tests that a label is cr
1128 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) {
1129 scoped_ptr<aura::Window> panel1(CreatePanelWindow(gfx::Rect(0, 0, 100, 100)));
1130 scoped_ptr<aura::Window> panel2(CreatePanelWindow(gfx::Rect(0, 0, 100, 100)));
1131 base::string16 panel1_title = base::UTF8ToUTF16("My panel");
1132 base::string16 panel2_title = base::UTF8ToUTF16("Another panel");
1133 panel1->set_title(panel1_title);
1134 panel2->set_title(panel2_title);
1135 wm::ActivateWindow(panel1.get());
1136 ToggleOverview();
1137 WindowSelectorItem* window_item = GetWindowItems()->back();
1138 views::Widget* widget = GetLabelWidget(window_item);
1139 // Has the label widget been created?
1140 ASSERT_TRUE(widget);
1141 views::Label* label = static_cast<views::Label*>(widget->GetContentsView());
1142 // Verify the label matches the active window title.
1143 EXPECT_EQ(label->text(), panel1_title);
1144 }
1145
1090 } // namespace ash 1146 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698