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

Side by Side Diff: ash/wm/panels/panel_layout_manager_unittest.cc

Issue 2878133002: mash: Serialize ShelfIDs for property conversion and transport. (Closed)
Patch Set: Remove |user_windows_with_items_| entries in workaround; disable a test in mash. Created 3 years, 7 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 (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/public/cpp/window_properties.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
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; 92 static int id = 0;
93 window->SetProperty(kShelfIDKey, new ShelfID(base::IntToString(id++))); 93 std::string shelf_id(ash::ShelfID(base::IntToString(id++)).Serialize());
James Cook 2017/05/15 16:37:23 Am I missing something obvious about ash:: for She
msw 2017/05/15 19:21:32 Nope, I was just copy-pasting and missed the names
94 window->SetProperty(kShelfIDKey, new std::string(shelf_id));
94 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 95 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
95 return window; 96 return window;
96 } 97 }
97 98
98 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { 99 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) {
99 return CreatePanelWindowWithDelegate(nullptr, bounds); 100 return CreatePanelWindowWithDelegate(nullptr, bounds);
100 } 101 }
101 102
102 aura::Window* GetPanelContainer(aura::Window* panel) { 103 aura::Window* GetPanelContainer(aura::Window* panel) {
103 return Shell::GetContainer(panel->GetRootWindow(), 104 return Shell::GetContainer(panel->GetRootWindow(),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 return widget->IsVisible(); 213 return widget->IsVisible();
213 } 214 }
214 215
215 test::ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); } 216 test::ShelfViewTestAPI* shelf_view_test() { return shelf_view_test_.get(); }
216 217
217 // Clicks the shelf item on |shelf_view| associated with the given |window|. 218 // Clicks the shelf item on |shelf_view| associated with the given |window|.
218 void ClickShelfItemForWindow(ShelfView* shelf_view, aura::Window* window) { 219 void ClickShelfItemForWindow(ShelfView* shelf_view, aura::Window* window) {
219 test::ShelfViewTestAPI test_api(shelf_view); 220 test::ShelfViewTestAPI test_api(shelf_view);
220 test_api.SetAnimationDuration(1); 221 test_api.SetAnimationDuration(1);
221 test_api.RunMessageLoopUntilAnimationsDone(); 222 test_api.RunMessageLoopUntilAnimationsDone();
222 ShelfID* shelf_id = window->GetProperty(kShelfIDKey); 223 ShelfID shelf_id = ShelfID::Deserialize(window->GetProperty(kShelfIDKey));
223 DCHECK(shelf_id); 224 DCHECK(!shelf_id.IsNull());
224 int index = Shell::Get()->shelf_model()->ItemIndexByID(*shelf_id); 225 int index = Shell::Get()->shelf_model()->ItemIndexByID(shelf_id);
226 DCHECK_GE(index, 0);
225 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen(); 227 gfx::Rect bounds = test_api.GetButton(index)->GetBoundsInScreen();
226 228
227 ui::test::EventGenerator& event_generator = GetEventGenerator(); 229 ui::test::EventGenerator& event_generator = GetEventGenerator();
228 event_generator.MoveMouseTo(bounds.CenterPoint()); 230 event_generator.MoveMouseTo(bounds.CenterPoint());
229 event_generator.ClickLeftButton(); 231 event_generator.ClickLeftButton();
230 232
231 test_api.RunMessageLoopUntilAnimationsDone(); 233 test_api.RunMessageLoopUntilAnimationsDone();
232 } 234 }
233 235
234 WmShelf* GetShelfForWindow(aura::Window* window) { 236 WmShelf* GetShelfForWindow(aura::Window* window) {
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5)); 930 touch.set_location(gfx::Point(bounds.x() - 1, bounds.y() + 5));
929 target = targeter->FindTargetForEvent(root, &touch); 931 target = targeter->FindTargetForEvent(root, &touch);
930 EXPECT_NE(w.get(), target); 932 EXPECT_NE(w.get(), target);
931 } 933 }
932 934
933 INSTANTIATE_TEST_CASE_P(LtrRtl, 935 INSTANTIATE_TEST_CASE_P(LtrRtl,
934 PanelLayoutManagerTextDirectionTest, 936 PanelLayoutManagerTextDirectionTest,
935 testing::Bool()); 937 testing::Bool());
936 938
937 } // namespace ash 939 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698