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

Side by Side Diff: athena/wm/window_manager_unittest.cc

Issue 513313003: Fix crash when using title drag on a window opened while split view is active (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/wm/public/window_manager.h" 5 #include "athena/wm/public/window_manager.h"
6 6
7 #include "athena/screen/public/screen_manager.h" 7 #include "athena/screen/public/screen_manager.h"
8 #include "athena/test/athena_test_base.h" 8 #include "athena/test/athena_test_base.h"
9 #include "athena/wm/public/window_list_provider.h" 9 #include "athena/wm/public/window_list_provider.h"
10 #include "athena/wm/split_view_controller.h" 10 #include "athena/wm/split_view_controller.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); 100 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window());
101 EXPECT_EQ(second->bounds().size().ToString(), 101 EXPECT_EQ(second->bounds().size().ToString(),
102 third->bounds().size().ToString()); 102 third->bounds().size().ToString());
103 } 103 }
104 104
105 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { 105 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) {
106 aura::test::TestWindowDelegate delegate; 106 aura::test::TestWindowDelegate delegate;
107 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 107 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
108 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 108 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
109 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 109 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
110 first->Hide();
111 second->Hide();
110 112
111 test::WindowManagerImplTestApi wm_api; 113 test::WindowManagerImplTestApi wm_api;
112 aura::client::ParentWindowWithContext( 114 aura::client::ParentWindowWithContext(
113 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 115 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
114 aura::client::ParentWindowWithContext( 116 aura::client::ParentWindowWithContext(
115 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 117 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
116 aura::client::ParentWindowWithContext( 118 aura::client::ParentWindowWithContext(
117 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 119 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
118 120
119 EXPECT_EQ(third.get(), 121 EXPECT_EQ(third.get(),
120 wm_api.GetWindowListProvider()->GetWindowList().back()); 122 wm_api.GetWindowListProvider()->GetWindowList().back());
121 123
122 // Do a two-finger swipe from the left bezel. 124 // Do a two-finger swipe from the left bezel.
123 ui::test::EventGenerator generator(root_window()); 125 ui::test::EventGenerator generator(root_window());
124 const gfx::Point left_bezel_points[2] = { 126 const gfx::Point left_bezel_points[2] = {
125 gfx::Point(2, 10), gfx::Point(4, 20), 127 gfx::Point(2, 10), gfx::Point(4, 20),
126 }; 128 };
127 const int kEventTimeSepration = 16; 129 const int kEventTimeSepration = 16;
128 int width = root_window()->bounds().width(); 130 int width = root_window()->bounds().width();
129 generator.GestureMultiFingerScroll( 131 generator.GestureMultiFingerScroll(
130 2, left_bezel_points, kEventTimeSepration, 1, width, 0); 132 2, left_bezel_points, kEventTimeSepration, 1, width, 0);
131 EXPECT_TRUE(wm::IsActiveWindow(second.get())); 133 EXPECT_TRUE(wm::IsActiveWindow(second.get()));
132 EXPECT_EQ(second.get(), 134 EXPECT_EQ(second.get(),
133 wm_api.GetWindowListProvider()->GetWindowList().back()); 135 wm_api.GetWindowListProvider()->GetWindowList().back());
136 EXPECT_FALSE(first->IsVisible());
137 EXPECT_TRUE(second->IsVisible());
138 EXPECT_FALSE(third->IsVisible());
134 } 139 }
135 140
136 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { 141 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) {
137 aura::test::TestWindowDelegate delegate; 142 aura::test::TestWindowDelegate delegate;
138 delegate.set_window_component(HTCAPTION); 143 delegate.set_window_component(HTCAPTION);
139 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 144 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
140 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 145 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
141 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 146 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
142 147
143 test::WindowManagerImplTestApi wm_api; 148 test::WindowManagerImplTestApi wm_api;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 266 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
262 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); 267 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString());
263 268
264 // Get into split view. 269 // Get into split view.
265 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); 270 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL);
266 const gfx::Rect left_bounds = 271 const gfx::Rect left_bounds =
267 wm_api.GetSplitViewController()->left_window()->bounds(); 272 wm_api.GetSplitViewController()->left_window()->bounds();
268 EXPECT_NE(work_area.ToString(), 273 EXPECT_NE(work_area.ToString(),
269 left_bounds.size().ToString()); 274 left_bounds.size().ToString());
270 275
276 // A new window should replace the left window when in split view.
271 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 277 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
272 aura::client::ParentWindowWithContext( 278 aura::client::ParentWindowWithContext(
273 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 279 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
274 EXPECT_NE(wm_api.GetSplitViewController()->left_window(), third.get()); 280 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get());
275 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); 281 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString());
276
277 third->Hide();
278 EXPECT_EQ(
279 left_bounds.ToString(),
280 wm_api.GetSplitViewController()->left_window()->bounds().ToString());
281 } 282 }
282 283
283 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { 284 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) {
284 test::WindowManagerImplTestApi wm_api; 285 test::WindowManagerImplTestApi wm_api;
285 286
286 aura::test::TestWindowDelegate delegate; 287 aura::test::TestWindowDelegate delegate;
287 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); 288 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect()));
288 w1->Show(); 289 w1->Show();
289 290
290 ui::test::EventGenerator generator(root_window()); 291 ui::test::EventGenerator generator(root_window());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 330 EXPECT_TRUE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
330 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window()); 331 EXPECT_EQ(w3.get(), wm_api.GetSplitViewController()->left_window());
331 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window()); 332 EXPECT_EQ(w2.get(), wm_api.GetSplitViewController()->right_window());
332 333
333 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); 334 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
334 overview_delegate->OnSelectWindow(w1.get()); 335 overview_delegate->OnSelectWindow(w1.get());
335 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 336 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
336 } 337 }
337 338
338 } // namespace athena 339 } // namespace athena
OLDNEW
« athena/wm/window_manager_impl.cc ('K') | « athena/wm/window_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698