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

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
« no previous file with comments | « athena/wm/window_manager_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window()); 132 EXPECT_EQ(third.get(), wm_api.GetSplitViewController()->right_window());
133 EXPECT_EQ(second->bounds().size().ToString(), 133 EXPECT_EQ(second->bounds().size().ToString(),
134 third->bounds().size().ToString()); 134 third->bounds().size().ToString());
135 } 135 }
136 136
137 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) { 137 TEST_F(WindowManagerTest, BezelGestureToSwitchBetweenWindows) {
138 aura::test::TestWindowDelegate delegate; 138 aura::test::TestWindowDelegate delegate;
139 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 139 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
140 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 140 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
141 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 141 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
142 first->Hide();
143 second->Hide();
142 144
143 test::WindowManagerImplTestApi wm_api; 145 test::WindowManagerImplTestApi wm_api;
144 aura::client::ParentWindowWithContext( 146 aura::client::ParentWindowWithContext(
145 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 147 first.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
146 aura::client::ParentWindowWithContext( 148 aura::client::ParentWindowWithContext(
147 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 149 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
148 aura::client::ParentWindowWithContext( 150 aura::client::ParentWindowWithContext(
149 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 151 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
150 152
151 EXPECT_EQ(third.get(), 153 EXPECT_EQ(third.get(),
152 wm_api.GetWindowListProvider()->GetWindowList().back()); 154 wm_api.GetWindowListProvider()->GetWindowList().back());
153 155
154 // Do a two-finger swipe from the left bezel. 156 // Do a two-finger swipe from the left bezel.
155 ui::test::EventGenerator generator(root_window()); 157 ui::test::EventGenerator generator(root_window());
156 const gfx::Point left_bezel_points[2] = { 158 const gfx::Point left_bezel_points[2] = {
157 gfx::Point(2, 10), gfx::Point(4, 20), 159 gfx::Point(2, 10), gfx::Point(4, 20),
158 }; 160 };
159 const int kEventTimeSepration = 16; 161 const int kEventTimeSepration = 16;
160 int width = root_window()->bounds().width(); 162 int width = root_window()->bounds().width();
161 generator.GestureMultiFingerScroll( 163 generator.GestureMultiFingerScroll(
162 2, left_bezel_points, kEventTimeSepration, 1, width, 0); 164 2, left_bezel_points, kEventTimeSepration, 1, width, 0);
163 EXPECT_TRUE(wm::IsActiveWindow(second.get())); 165 EXPECT_TRUE(wm::IsActiveWindow(second.get()));
164 EXPECT_EQ(second.get(), 166 EXPECT_EQ(second.get(),
165 wm_api.GetWindowListProvider()->GetWindowList().back()); 167 wm_api.GetWindowListProvider()->GetWindowList().back());
168 EXPECT_FALSE(first->IsVisible());
169 EXPECT_TRUE(second->IsVisible());
170 EXPECT_FALSE(third->IsVisible());
166 } 171 }
167 172
168 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) { 173 TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) {
169 aura::test::TestWindowDelegate delegate; 174 aura::test::TestWindowDelegate delegate;
170 delegate.set_window_component(HTCAPTION); 175 delegate.set_window_component(HTCAPTION);
171 scoped_ptr<aura::Window> first(CreateWindow(&delegate)); 176 scoped_ptr<aura::Window> first(CreateWindow(&delegate));
172 scoped_ptr<aura::Window> second(CreateWindow(&delegate)); 177 scoped_ptr<aura::Window> second(CreateWindow(&delegate));
173 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 178 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
174 179
175 test::WindowManagerImplTestApi wm_api; 180 test::WindowManagerImplTestApi wm_api;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 298 second.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
294 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString()); 299 EXPECT_EQ(first->bounds().ToString(), second->bounds().ToString());
295 300
296 // Get into split view. 301 // Get into split view.
297 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL); 302 wm_api.GetSplitViewController()->ActivateSplitMode(NULL, NULL);
298 const gfx::Rect left_bounds = 303 const gfx::Rect left_bounds =
299 wm_api.GetSplitViewController()->left_window()->bounds(); 304 wm_api.GetSplitViewController()->left_window()->bounds();
300 EXPECT_NE(work_area.ToString(), 305 EXPECT_NE(work_area.ToString(),
301 left_bounds.size().ToString()); 306 left_bounds.size().ToString());
302 307
308 // A new window should replace the left window when in split view.
303 scoped_ptr<aura::Window> third(CreateWindow(&delegate)); 309 scoped_ptr<aura::Window> third(CreateWindow(&delegate));
304 aura::client::ParentWindowWithContext( 310 aura::client::ParentWindowWithContext(
305 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect()); 311 third.get(), ScreenManager::Get()->GetContext(), gfx::Rect());
306 EXPECT_NE(wm_api.GetSplitViewController()->left_window(), third.get()); 312 EXPECT_EQ(wm_api.GetSplitViewController()->left_window(), third.get());
307 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString()); 313 EXPECT_EQ(left_bounds.ToString(), third->bounds().ToString());
308
309 third->Hide();
310 EXPECT_EQ(
311 left_bounds.ToString(),
312 wm_api.GetSplitViewController()->left_window()->bounds().ToString());
313 } 314 }
314 315
315 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) { 316 TEST_F(WindowManagerTest, SplitModeActivationByShortcut) {
316 test::WindowManagerImplTestApi wm_api; 317 test::WindowManagerImplTestApi wm_api;
317 318
318 aura::test::TestWindowDelegate delegate; 319 aura::test::TestWindowDelegate delegate;
319 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect())); 320 scoped_ptr<aura::Window> w1(CreateTestWindow(&delegate, gfx::Rect()));
320 w1->Show(); 321 w1->Show();
321 322
322 ui::test::EventGenerator generator(root_window()); 323 ui::test::EventGenerator generator(root_window());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 WindowOverviewModeDelegate* overview_delegate = wm_api.wm(); 366 WindowOverviewModeDelegate* overview_delegate = wm_api.wm();
366 overview_delegate->OnSelectWindow(w1.get()); 367 overview_delegate->OnSelectWindow(w1.get());
367 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive()); 368 EXPECT_FALSE(wm_api.GetSplitViewController()->IsSplitViewModeActive());
368 EXPECT_TRUE(w1->IsVisible()); 369 EXPECT_TRUE(w1->IsVisible());
369 // Make sure the windows that were in split-view mode are hidden. 370 // Make sure the windows that were in split-view mode are hidden.
370 EXPECT_FALSE(w2->IsVisible()); 371 EXPECT_FALSE(w2->IsVisible());
371 EXPECT_FALSE(w3->IsVisible()); 372 EXPECT_FALSE(w3->IsVisible());
372 } 373 }
373 374
374 } // namespace athena 375 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/window_manager_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698