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/wm/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
6 | 6 |
7 #include "ash/public/cpp/config.h" | 7 #include "ash/public/cpp/config.h" |
8 #include "ash/public/cpp/shelf_types.h" | 8 #include "ash/public/cpp/shelf_types.h" |
9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/public/cpp/window_properties.h" |
10 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
11 #include "ash/shelf/shelf_button.h" | 12 #include "ash/shelf/shelf_button.h" |
12 #include "ash/shelf/shelf_layout_manager.h" | 13 #include "ash/shelf/shelf_layout_manager.h" |
13 #include "ash/shelf/shelf_model.h" | 14 #include "ash/shelf/shelf_model.h" |
14 #include "ash/shelf/shelf_view.h" | 15 #include "ash/shelf/shelf_view.h" |
15 #include "ash/shelf/shelf_widget.h" | 16 #include "ash/shelf/shelf_widget.h" |
16 #include "ash/shelf/wm_shelf.h" | 17 #include "ash/shelf/wm_shelf.h" |
17 #include "ash/shell.h" | 18 #include "ash/shell.h" |
18 #include "ash/system/web_notification/web_notification_tray.h" | 19 #include "ash/system/web_notification/web_notification_tray.h" |
19 #include "ash/test/ash_test_base.h" | 20 #include "ash/test/ash_test_base.h" |
20 #include "ash/test/shelf_view_test_api.h" | 21 #include "ash/test/shelf_view_test_api.h" |
21 #include "ash/wm/mru_window_tracker.h" | 22 #include "ash/wm/mru_window_tracker.h" |
22 #include "ash/wm/window_properties.h" | |
23 #include "ash/wm/window_state.h" | 23 #include "ash/wm/window_state.h" |
24 #include "ash/wm/window_state_aura.h" | 24 #include "ash/wm/window_state_aura.h" |
25 #include "ash/wm/window_util.h" | 25 #include "ash/wm/window_util.h" |
26 #include "ash/wm_window.h" | 26 #include "ash/wm_window.h" |
27 #include "base/command_line.h" | 27 #include "base/command_line.h" |
28 #include "base/compiler_specific.h" | 28 #include "base/compiler_specific.h" |
29 #include "base/i18n/rtl.h" | 29 #include "base/i18n/rtl.h" |
30 #include "base/run_loop.h" | 30 #include "base/run_loop.h" |
31 #include "base/strings/string_number_conversions.h" | 31 #include "base/strings/string_number_conversions.h" |
32 #include "ui/aura/client/aura_constants.h" | 32 #include "ui/aura/client/aura_constants.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 | 83 |
84 aura::Window* CreateNormalWindow(const gfx::Rect& bounds) { | 84 aura::Window* CreateNormalWindow(const gfx::Rect& bounds) { |
85 return CreateTestWindowInShellWithBounds(bounds); | 85 return CreateTestWindowInShellWithBounds(bounds); |
86 } | 86 } |
87 | 87 |
88 aura::Window* CreatePanelWindowWithDelegate(aura::WindowDelegate* delegate, | 88 aura::Window* CreatePanelWindowWithDelegate(aura::WindowDelegate* delegate, |
89 const gfx::Rect& bounds) { | 89 const gfx::Rect& bounds) { |
90 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( | 90 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( |
91 delegate, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); | 91 delegate, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); |
| 92 static int id = 0; |
| 93 window->SetProperty(kShelfIDKey, new ShelfID(base::IntToString(id++))); |
92 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); | 94 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); |
93 return window; | 95 return window; |
94 } | 96 } |
95 | 97 |
96 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { | 98 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { |
97 return CreatePanelWindowWithDelegate(NULL, bounds); | 99 return CreatePanelWindowWithDelegate(nullptr, bounds); |
98 } | 100 } |
99 | 101 |
100 aura::Window* GetPanelContainer(aura::Window* panel) { | 102 aura::Window* GetPanelContainer(aura::Window* panel) { |
101 return Shell::GetContainer(panel->GetRootWindow(), | 103 return Shell::GetContainer(panel->GetRootWindow(), |
102 kShellWindowId_PanelContainer); | 104 kShellWindowId_PanelContainer); |
103 } | 105 } |
104 | 106 |
105 views::Widget* GetCalloutWidgetForPanel(aura::Window* panel) { | 107 views::Widget* GetCalloutWidgetForPanel(aura::Window* panel) { |
106 WmWindow* wm_panel = WmWindow::Get(panel); | 108 WmWindow* wm_panel = WmWindow::Get(panel); |
107 PanelLayoutManager* manager = PanelLayoutManager::Get(wm_panel); | 109 PanelLayoutManager* manager = PanelLayoutManager::Get(wm_panel); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 207 } |
206 } | 208 } |
207 | 209 |
208 bool IsPanelCalloutVisible(aura::Window* panel) { | 210 bool IsPanelCalloutVisible(aura::Window* panel) { |
209 views::Widget* widget = GetCalloutWidgetForPanel(panel); | 211 views::Widget* widget = GetCalloutWidgetForPanel(panel); |
210 return widget->IsVisible(); | 212 return widget->IsVisible(); |
211 } | 213 } |
212 | 214 |
213 test::ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); } | 215 test::ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); } |
214 | 216 |
215 // Clicks the shelf items on |shelf_view| that is associated with given | 217 // Clicks the shelf item on |shelf_view| associated with the given |window|. |
216 // |window|. | |
217 void ClickShelfItemForWindow(ShelfView* shelf_view, aura::Window* window) { | 218 void ClickShelfItemForWindow(ShelfView* shelf_view, aura::Window* window) { |
218 test::ShelfViewTestAPI test_api(shelf_view); | 219 test::ShelfViewTestAPI test_api(shelf_view); |
219 test_api.SetAnimationDuration(1); | 220 test_api.SetAnimationDuration(1); |
220 test_api.RunMessageLoopUntilAnimationsDone(); | 221 test_api.RunMessageLoopUntilAnimationsDone(); |
221 int index = Shell::Get()->shelf_model()->ItemIndexByID( | 222 ShelfID* shelf_id = window->GetProperty(kShelfIDKey); |
222 window->GetProperty(kShelfIDKey)); | 223 DCHECK(shelf_id); |
| 224 int index = Shell::Get()->shelf_model()->ItemIndexByID(*shelf_id); |
223 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); | 225 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); |
224 | 226 |
225 ui::test::EventGenerator& event_generator = GetEventGenerator(); | 227 ui::test::EventGenerator& event_generator = GetEventGenerator(); |
226 event_generator.MoveMouseTo(bounds.CenterPoint()); | 228 event_generator.MoveMouseTo(bounds.CenterPoint()); |
227 event_generator.ClickLeftButton(); | 229 event_generator.ClickLeftButton(); |
228 | 230 |
229 test_api.RunMessageLoopUntilAnimationsDone(); | 231 test_api.RunMessageLoopUntilAnimationsDone(); |
230 } | 232 } |
231 | 233 |
232 WmShelf* GetShelfForWindow(aura::Window* window) { | 234 WmShelf* GetShelfForWindow(aura::Window* window) { |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); | 928 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); |
927 target = targeter->FindTargetForEvent(root, &touch); | 929 target = targeter->FindTargetForEvent(root, &touch); |
928 EXPECT_NE(w.get(), target); | 930 EXPECT_NE(w.get(), target); |
929 } | 931 } |
930 | 932 |
931 INSTANTIATE_TEST_CASE_P(LtrRtl, | 933 INSTANTIATE_TEST_CASE_P(LtrRtl, |
932 PanelLayoutManagerTextDirectionTest, | 934 PanelLayoutManagerTextDirectionTest, |
933 testing::Bool()); | 935 testing::Bool()); |
934 | 936 |
935 } // namespace ash | 937 } // namespace ash |
OLD | NEW |