Chromium Code Reviews| 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/custom_frame_view_ash.h" | 5 #include "ash/wm/custom_frame_view_ash.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" | 10 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" |
| 11 #include "ash/wm/caption_buttons/frame_maximize_button.h" | 11 #include "ash/wm/caption_buttons/frame_maximize_button.h" |
| 12 #include "ash/wm/caption_buttons/maximize_bubble_controller.h" | 12 #include "ash/wm/caption_buttons/maximize_bubble_controller.h" |
| 13 #include "ash/wm/property_util.h" | 13 #include "ash/wm/window_state.h" |
| 14 #include "ash/wm/window_util.h" | 14 #include "ash/wm/window_util.h" |
| 15 #include "ash/wm/workspace/snap_sizer.h" | 15 #include "ash/wm/workspace/snap_sizer.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "ui/aura/client/aura_constants.h" | 17 #include "ui/aura/client/aura_constants.h" |
| 18 #include "ui/aura/client/focus_client.h" | 18 #include "ui/aura/client/focus_client.h" |
| 19 #include "ui/aura/test/event_generator.h" | 19 #include "ui/aura/test/event_generator.h" |
| 20 #include "ui/aura/root_window.h" | 20 #include "ui/aura/root_window.h" |
| 21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/base/events/event_utils.h" | 22 #include "ui/base/events/event_utils.h" |
| 23 #include "ui/base/gestures/gesture_configuration.h" | 23 #include "ui/base/gestures/gesture_configuration.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 private: | 139 private: |
| 140 views::Widget* widget_; | 140 views::Widget* widget_; |
| 141 FrameMaximizeButton* maximize_button_; | 141 FrameMaximizeButton* maximize_button_; |
| 142 | 142 |
| 143 DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAshTest); | 143 DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAshTest); |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 // Tests that clicking on the resize-button toggles between maximize and normal | 146 // Tests that clicking on the resize-button toggles between maximize and normal |
| 147 // state. | 147 // state. |
| 148 TEST_F(CustomFrameViewAshTest, ResizeButtonToggleMaximize) { | 148 TEST_F(CustomFrameViewAshTest, ResizeButtonToggleMaximize) { |
| 149 aura::Window* window = widget()->GetNativeWindow(); | 149 wm::WindowState* window_state = |
| 150 wm::GetWindowState(widget()->GetNativeWindow()); | |
| 150 views::View* view = maximize_button(); | 151 views::View* view = maximize_button(); |
| 151 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); | 152 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); |
| 152 | 153 |
| 153 aura::test::EventGenerator generator(window->GetRootWindow(), center); | 154 aura::test::EventGenerator generator( |
| 155 window_state->window()->GetRootWindow(), center); | |
| 154 | 156 |
| 155 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 157 EXPECT_FALSE(window_state->IsMaximized()); |
| 156 | 158 |
| 157 generator.ClickLeftButton(); | 159 generator.ClickLeftButton(); |
| 158 RunAllPendingInMessageLoop(); | 160 RunAllPendingInMessageLoop(); |
| 159 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 161 EXPECT_TRUE(window_state->IsMaximized()); |
| 160 | 162 |
| 161 center = view->GetBoundsInScreen().CenterPoint(); | 163 center = view->GetBoundsInScreen().CenterPoint(); |
| 162 generator.MoveMouseTo(center); | 164 generator.MoveMouseTo(center); |
| 163 generator.ClickLeftButton(); | 165 generator.ClickLeftButton(); |
| 164 RunAllPendingInMessageLoop(); | 166 RunAllPendingInMessageLoop(); |
| 165 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 167 EXPECT_FALSE(window_state->IsMaximized()); |
| 166 | 168 |
| 167 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint()); | 169 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint()); |
| 168 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 170 EXPECT_TRUE(window_state->IsMaximized()); |
| 169 | 171 |
| 170 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint()); | 172 generator.GestureTapAt(view->GetBoundsInScreen().CenterPoint()); |
| 171 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 173 EXPECT_FALSE(window_state->IsMaximized()); |
| 172 | 174 |
| 173 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint()); | 175 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint()); |
| 174 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 176 EXPECT_TRUE(window_state->IsMaximized()); |
| 175 | 177 |
| 176 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint()); | 178 generator.GestureTapDownAndUp(view->GetBoundsInScreen().CenterPoint()); |
| 177 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 179 EXPECT_FALSE(window_state->IsMaximized()); |
| 178 } | 180 } |
| 179 | 181 |
| 180 #if defined(OS_WIN) | 182 #if defined(OS_WIN) |
| 181 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 183 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 182 #define MAYBE_ResizeButtonDrag DISABLED_ResizeButtonDrag | 184 #define MAYBE_ResizeButtonDrag DISABLED_ResizeButtonDrag |
| 183 #else | 185 #else |
| 184 #define MAYBE_ResizeButtonDrag ResizeButtonDrag | 186 #define MAYBE_ResizeButtonDrag ResizeButtonDrag |
| 185 #endif | 187 #endif |
| 186 | 188 |
| 187 // Tests that click+dragging on the resize-button tiles or minimizes the window. | 189 // Tests that click+dragging on the resize-button tiles or minimizes the window. |
| 188 TEST_F(CustomFrameViewAshTest, MAYBE_ResizeButtonDrag) { | 190 TEST_F(CustomFrameViewAshTest, MAYBE_ResizeButtonDrag) { |
| 189 aura::Window* window = widget()->GetNativeWindow(); | 191 aura::Window* window = widget()->GetNativeWindow(); |
| 190 views::View* view = maximize_button(); | 192 views::View* view = maximize_button(); |
| 191 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); | 193 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); |
| 192 | 194 |
| 193 aura::test::EventGenerator generator(window->GetRootWindow(), center); | 195 aura::test::EventGenerator generator(window->GetRootWindow(), center); |
| 194 | 196 |
| 195 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 197 wm::WindowState* window_state = wm::GetWindowState(window); |
| 198 EXPECT_TRUE(window_state->IsNormal()); | |
| 196 | 199 |
| 197 // Snap right. | 200 // Snap right. |
| 198 { | 201 { |
| 199 generator.PressLeftButton(); | 202 generator.PressLeftButton(); |
| 200 generator.MoveMouseBy(10, 0); | 203 generator.MoveMouseBy(10, 0); |
| 201 generator.ReleaseLeftButton(); | 204 generator.ReleaseLeftButton(); |
| 202 RunAllPendingInMessageLoop(); | 205 RunAllPendingInMessageLoop(); |
| 203 | 206 |
| 204 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 207 EXPECT_FALSE(window_state->IsMaximized()); |
| 205 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 208 EXPECT_FALSE(window_state->IsMinimized()); |
| 206 internal::SnapSizer sizer(window, center, | 209 internal::SnapSizer sizer(window, center, |
| 207 internal::SnapSizer::RIGHT_EDGE, | 210 internal::SnapSizer::RIGHT_EDGE, |
| 208 internal::SnapSizer::OTHER_INPUT); | 211 internal::SnapSizer::OTHER_INPUT); |
| 209 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 212 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
| 210 } | 213 } |
| 211 | 214 |
| 212 // Snap left. | 215 // Snap left. |
| 213 { | 216 { |
| 214 center = view->GetBoundsInScreen().CenterPoint(); | 217 center = view->GetBoundsInScreen().CenterPoint(); |
| 215 generator.MoveMouseTo(center); | 218 generator.MoveMouseTo(center); |
| 216 generator.PressLeftButton(); | 219 generator.PressLeftButton(); |
| 217 generator.MoveMouseBy(-10, 0); | 220 generator.MoveMouseBy(-10, 0); |
| 218 generator.ReleaseLeftButton(); | 221 generator.ReleaseLeftButton(); |
| 219 RunAllPendingInMessageLoop(); | 222 RunAllPendingInMessageLoop(); |
| 220 | 223 |
| 221 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 224 EXPECT_FALSE(window_state->IsMaximized()); |
| 222 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 225 EXPECT_FALSE(window_state->IsMinimized()); |
| 223 internal::SnapSizer sizer(window, center, | 226 internal::SnapSizer sizer(window, center, |
| 224 internal::SnapSizer::LEFT_EDGE, | 227 internal::SnapSizer::LEFT_EDGE, |
| 225 internal::SnapSizer::OTHER_INPUT); | 228 internal::SnapSizer::OTHER_INPUT); |
| 226 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 229 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
| 227 } | 230 } |
| 228 | 231 |
| 229 // Minimize. | 232 // Minimize. |
| 230 { | 233 { |
| 231 center = view->GetBoundsInScreen().CenterPoint(); | 234 center = view->GetBoundsInScreen().CenterPoint(); |
| 232 generator.MoveMouseTo(center); | 235 generator.MoveMouseTo(center); |
| 233 generator.PressLeftButton(); | 236 generator.PressLeftButton(); |
| 234 generator.MoveMouseBy(0, 10); | 237 generator.MoveMouseBy(0, 10); |
| 235 generator.ReleaseLeftButton(); | 238 generator.ReleaseLeftButton(); |
| 236 RunAllPendingInMessageLoop(); | 239 RunAllPendingInMessageLoop(); |
| 237 | 240 |
| 238 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); | 241 EXPECT_TRUE(window_state->IsMinimized()); |
| 239 } | 242 } |
| 240 | 243 |
| 241 ash::wm::RestoreWindow(window); | 244 window_state->Restore(); |
| 242 | 245 |
| 243 // Now test the same behaviour for gesture events. | 246 // Now test the same behaviour for gesture events. |
| 244 | 247 |
| 245 // Snap right. | 248 // Snap right. |
| 246 { | 249 { |
| 247 center = view->GetBoundsInScreen().CenterPoint(); | 250 center = view->GetBoundsInScreen().CenterPoint(); |
| 248 gfx::Point end = center; | 251 gfx::Point end = center; |
| 249 end.Offset(80, 0); | 252 end.Offset(80, 0); |
| 250 generator.GestureScrollSequence(center, end, | 253 generator.GestureScrollSequence(center, end, |
| 251 base::TimeDelta::FromMilliseconds(100), | 254 base::TimeDelta::FromMilliseconds(100), |
| 252 3); | 255 3); |
| 253 RunAllPendingInMessageLoop(); | 256 RunAllPendingInMessageLoop(); |
| 254 | 257 |
| 255 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 258 EXPECT_FALSE(window_state->IsMaximized()); |
| 256 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 259 EXPECT_FALSE(window_state->IsMinimized()); |
| 257 // This is a short resizing distance and different touch behavior | 260 // This is a short resizing distance and different touch behavior |
| 258 // applies which leads in half of the screen being used. | 261 // applies which leads in half of the screen being used. |
| 259 EXPECT_EQ("400,0 400x553", window->bounds().ToString()); | 262 EXPECT_EQ("400,0 400x553", window->bounds().ToString()); |
| 260 } | 263 } |
| 261 | 264 |
| 262 // Snap left. | 265 // Snap left. |
| 263 { | 266 { |
| 264 center = view->GetBoundsInScreen().CenterPoint(); | 267 center = view->GetBoundsInScreen().CenterPoint(); |
| 265 gfx::Point end = center; | 268 gfx::Point end = center; |
| 266 end.Offset(-80, 0); | 269 end.Offset(-80, 0); |
| 267 generator.GestureScrollSequence(center, end, | 270 generator.GestureScrollSequence(center, end, |
| 268 base::TimeDelta::FromMilliseconds(100), | 271 base::TimeDelta::FromMilliseconds(100), |
| 269 3); | 272 3); |
| 270 RunAllPendingInMessageLoop(); | 273 RunAllPendingInMessageLoop(); |
| 271 | 274 |
| 272 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 275 EXPECT_FALSE(window_state->IsMaximized()); |
| 273 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 276 EXPECT_FALSE(window_state->IsMinimized()); |
| 274 internal::SnapSizer sizer(window, center, | 277 internal::SnapSizer sizer(window, center, |
| 275 internal::SnapSizer::LEFT_EDGE, | 278 internal::SnapSizer::LEFT_EDGE, |
| 276 internal::SnapSizer::OTHER_INPUT); | 279 internal::SnapSizer::OTHER_INPUT); |
| 277 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 280 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
| 278 } | 281 } |
| 279 | 282 |
| 280 // Minimize. | 283 // Minimize. |
| 281 { | 284 { |
| 282 center = view->GetBoundsInScreen().CenterPoint(); | 285 center = view->GetBoundsInScreen().CenterPoint(); |
| 283 gfx::Point end = center; | 286 gfx::Point end = center; |
| 284 end.Offset(0, 40); | 287 end.Offset(0, 40); |
| 285 generator.GestureScrollSequence(center, end, | 288 generator.GestureScrollSequence(center, end, |
| 286 base::TimeDelta::FromMilliseconds(100), | 289 base::TimeDelta::FromMilliseconds(100), |
| 287 3); | 290 3); |
| 288 RunAllPendingInMessageLoop(); | 291 RunAllPendingInMessageLoop(); |
| 289 | 292 |
| 290 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); | 293 EXPECT_TRUE(window_state->IsMinimized()); |
| 291 } | 294 } |
| 292 | 295 |
| 293 // Test with gesture events. | 296 // Test with gesture events. |
| 294 } | 297 } |
| 295 | 298 |
| 296 #if defined(OS_WIN) | 299 #if defined(OS_WIN) |
| 297 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 300 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 298 #define MAYBE_TouchDragResizeCloseToCornerDiffersFromMouse \ | 301 #define MAYBE_TouchDragResizeCloseToCornerDiffersFromMouse \ |
| 299 DISABLED_TouchDragResizeCloseToCornerDiffersFromMouse | 302 DISABLED_TouchDragResizeCloseToCornerDiffersFromMouse |
| 300 #else | 303 #else |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 312 gfx::Rect work_area = widget()->GetWorkAreaBoundsInScreen(); | 315 gfx::Rect work_area = widget()->GetWorkAreaBoundsInScreen(); |
| 313 gfx::Rect bounds = window->bounds(); | 316 gfx::Rect bounds = window->bounds(); |
| 314 bounds.set_x(work_area.width() - bounds.width()); | 317 bounds.set_x(work_area.width() - bounds.width()); |
| 315 widget()->SetBounds(bounds); | 318 widget()->SetBounds(bounds); |
| 316 | 319 |
| 317 gfx::Point start_point = view->GetBoundsInScreen().CenterPoint(); | 320 gfx::Point start_point = view->GetBoundsInScreen().CenterPoint(); |
| 318 // We want to move all the way to the right (the few pixels we have). | 321 // We want to move all the way to the right (the few pixels we have). |
| 319 gfx::Point end_point = gfx::Point(work_area.width(), start_point.y()); | 322 gfx::Point end_point = gfx::Point(work_area.width(), start_point.y()); |
| 320 | 323 |
| 321 aura::test::EventGenerator generator(window->GetRootWindow(), start_point); | 324 aura::test::EventGenerator generator(window->GetRootWindow(), start_point); |
| 325 wm::WindowState* window_state = wm::GetWindowState(window); | |
| 322 | 326 |
| 323 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 327 EXPECT_TRUE(window_state->IsNormal()); |
| 324 | 328 |
| 325 // Snap right with a touch drag. | 329 // Snap right with a touch drag. |
| 326 generator.GestureScrollSequence(start_point, | 330 generator.GestureScrollSequence(start_point, |
| 327 end_point, | 331 end_point, |
| 328 base::TimeDelta::FromMilliseconds(100), | 332 base::TimeDelta::FromMilliseconds(100), |
| 329 10); | 333 10); |
| 330 RunAllPendingInMessageLoop(); | 334 RunAllPendingInMessageLoop(); |
| 331 | 335 |
| 332 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 336 EXPECT_FALSE(window_state->IsMaximized()); |
| 333 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 337 EXPECT_FALSE(window_state->IsMinimized()); |
| 334 gfx::Rect touch_result = window->bounds(); | 338 gfx::Rect touch_result = window->bounds(); |
| 335 EXPECT_NE(bounds.ToString(), touch_result.ToString()); | 339 EXPECT_NE(bounds.ToString(), touch_result.ToString()); |
| 336 | 340 |
| 337 // Set the position back to where it was before and re-try with a mouse. | 341 // Set the position back to where it was before and re-try with a mouse. |
| 338 widget()->SetBounds(bounds); | 342 widget()->SetBounds(bounds); |
| 339 | 343 |
| 340 generator.MoveMouseTo(start_point); | 344 generator.MoveMouseTo(start_point); |
| 341 generator.PressLeftButton(); | 345 generator.PressLeftButton(); |
| 342 generator.MoveMouseTo(end_point, 10); | 346 generator.MoveMouseTo(end_point, 10); |
| 343 generator.ReleaseLeftButton(); | 347 generator.ReleaseLeftButton(); |
| 344 RunAllPendingInMessageLoop(); | 348 RunAllPendingInMessageLoop(); |
| 345 | 349 |
| 346 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 350 EXPECT_FALSE(window_state->IsMaximized()); |
| 347 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 351 EXPECT_FALSE(window_state->IsMinimized()); |
| 348 gfx::Rect mouse_result = window->bounds(); | 352 gfx::Rect mouse_result = window->bounds(); |
| 349 | 353 |
| 350 // The difference between the two operations should be that the mouse | 354 // The difference between the two operations should be that the mouse |
| 351 // operation should have just started to resize and the touch operation is | 355 // operation should have just started to resize and the touch operation is |
| 352 // already all the way down to the smallest possible size. | 356 // already all the way down to the smallest possible size. |
| 353 EXPECT_NE(mouse_result.ToString(), touch_result.ToString()); | 357 EXPECT_NE(mouse_result.ToString(), touch_result.ToString()); |
| 354 EXPECT_GT(mouse_result.width(), touch_result.width()); | 358 EXPECT_GT(mouse_result.width(), touch_result.width()); |
| 355 } | 359 } |
| 356 | 360 |
| 357 // Test that closing the (browser) window with an opened balloon does not | 361 // Test that closing the (browser) window with an opened balloon does not |
| 358 // crash the system. In other words: Make sure that shutting down the frame | 362 // crash the system. In other words: Make sure that shutting down the frame |
| 359 // destroys the opened balloon in an orderly fashion. | 363 // destroys the opened balloon in an orderly fashion. |
| 360 TEST_F(CustomFrameViewAshTest, MaximizeButtonExternalShutDown) { | 364 TEST_F(CustomFrameViewAshTest, MaximizeButtonExternalShutDown) { |
| 361 aura::Window* window = widget()->GetNativeWindow(); | 365 aura::Window* window = widget()->GetNativeWindow(); |
| 362 ash::FrameMaximizeButton* maximize_button = | 366 ash::FrameMaximizeButton* maximize_button = |
| 363 CustomFrameViewAshTest::maximize_button(); | 367 CustomFrameViewAshTest::maximize_button(); |
| 364 maximize_button->set_bubble_appearance_delay_ms(0); | 368 maximize_button->set_bubble_appearance_delay_ms(0); |
| 365 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 369 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 366 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 370 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
| 367 | 371 |
| 368 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 372 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
| 369 EXPECT_FALSE(maximize_button->maximizer()); | 373 EXPECT_FALSE(maximize_button->maximizer()); |
| 370 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 374 EXPECT_TRUE(wm::GetWindowState(window)->IsNormal()); |
| 371 | 375 |
| 372 // Move the mouse cursor over the button to bring up the maximizer bubble. | 376 // Move the mouse cursor over the button to bring up the maximizer bubble. |
| 373 generator.MoveMouseTo(button_pos); | 377 generator.MoveMouseTo(button_pos); |
| 374 EXPECT_TRUE(maximize_button->maximizer()); | 378 EXPECT_TRUE(maximize_button->maximizer()); |
| 375 | 379 |
| 376 // Even though the widget is closing the bubble menu should not crash upon | 380 // Even though the widget is closing the bubble menu should not crash upon |
| 377 // its delayed destruction. | 381 // its delayed destruction. |
| 378 CloseWidget(); | 382 CloseWidget(); |
| 379 } | 383 } |
| 380 | 384 |
| 381 // Test that maximizing the browser after hovering in does not crash the system | 385 // Test that maximizing the browser after hovering in does not crash the system |
| 382 // when the observer gets removed in the bubble destruction process. | 386 // when the observer gets removed in the bubble destruction process. |
| 383 TEST_F(CustomFrameViewAshTest, MaximizeOnHoverThenClick) { | 387 TEST_F(CustomFrameViewAshTest, MaximizeOnHoverThenClick) { |
| 384 aura::Window* window = widget()->GetNativeWindow(); | 388 aura::Window* window = widget()->GetNativeWindow(); |
| 385 ash::FrameMaximizeButton* maximize_button = | 389 ash::FrameMaximizeButton* maximize_button = |
| 386 CustomFrameViewAshTest::maximize_button(); | 390 CustomFrameViewAshTest::maximize_button(); |
| 387 maximize_button->set_bubble_appearance_delay_ms(0); | 391 maximize_button->set_bubble_appearance_delay_ms(0); |
| 388 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 392 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 389 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 393 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
| 390 | 394 |
| 391 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 395 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
| 392 EXPECT_FALSE(maximize_button->maximizer()); | 396 EXPECT_FALSE(maximize_button->maximizer()); |
| 393 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 397 EXPECT_TRUE(wm::GetWindowState(window)->IsNormal()); |
| 394 | 398 |
| 395 // Move the mouse cursor over the button to bring up the maximizer bubble. | 399 // Move the mouse cursor over the button to bring up the maximizer bubble. |
| 396 generator.MoveMouseTo(button_pos); | 400 generator.MoveMouseTo(button_pos); |
| 397 EXPECT_TRUE(maximize_button->maximizer()); | 401 EXPECT_TRUE(maximize_button->maximizer()); |
| 398 generator.ClickLeftButton(); | 402 generator.ClickLeftButton(); |
| 399 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 403 EXPECT_TRUE(wm::GetWindowState(window)->IsMaximized()); |
| 400 } | 404 } |
| 401 | 405 |
| 402 // Test that hovering over a button in the balloon dialog will show the phantom | 406 // Test that hovering over a button in the balloon dialog will show the phantom |
| 403 // window. Moving then away from the button will hide it again. Then check that | 407 // window. Moving then away from the button will hide it again. Then check that |
| 404 // pressing and dragging the button itself off the button will also release the | 408 // pressing and dragging the button itself off the button will also release the |
| 405 // phantom window. | 409 // phantom window. |
| 406 TEST_F(CustomFrameViewAshTest, MaximizeLeftButtonDragOut) { | 410 TEST_F(CustomFrameViewAshTest, MaximizeLeftButtonDragOut) { |
| 407 aura::Window* window = widget()->GetNativeWindow(); | 411 aura::Window* window = widget()->GetNativeWindow(); |
| 408 ash::FrameMaximizeButton* maximize_button = | 412 ash::FrameMaximizeButton* maximize_button = |
| 409 CustomFrameViewAshTest::maximize_button(); | 413 CustomFrameViewAshTest::maximize_button(); |
| 410 maximize_button->set_bubble_appearance_delay_ms(0); | 414 maximize_button->set_bubble_appearance_delay_ms(0); |
| 411 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 415 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 412 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 416 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
| 413 | 417 |
| 414 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 418 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
| 415 EXPECT_FALSE(maximize_button->maximizer()); | 419 EXPECT_FALSE(maximize_button->maximizer()); |
| 416 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 420 EXPECT_TRUE(wm::GetWindowState(window)->IsNormal()); |
| 417 EXPECT_FALSE(maximize_button->phantom_window_open()); | 421 EXPECT_FALSE(maximize_button->phantom_window_open()); |
| 418 | 422 |
| 419 // Move the mouse cursor over the button to bring up the maximizer bubble. | 423 // Move the mouse cursor over the button to bring up the maximizer bubble. |
| 420 generator.MoveMouseTo(button_pos); | 424 generator.MoveMouseTo(button_pos); |
| 421 EXPECT_TRUE(maximize_button->maximizer()); | 425 EXPECT_TRUE(maximize_button->maximizer()); |
| 422 | 426 |
| 423 // Move the mouse over the left maximize button. | 427 // Move the mouse over the left maximize button. |
| 424 gfx::Point left_max_pos = maximize_button->maximizer()-> | 428 gfx::Point left_max_pos = maximize_button->maximizer()-> |
| 425 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); | 429 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); |
| 426 | 430 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 451 TEST_F(CustomFrameViewAshTest, MaximizeLeftByButton) { | 455 TEST_F(CustomFrameViewAshTest, MaximizeLeftByButton) { |
| 452 aura::Window* window = widget()->GetNativeWindow(); | 456 aura::Window* window = widget()->GetNativeWindow(); |
| 453 ash::FrameMaximizeButton* maximize_button = | 457 ash::FrameMaximizeButton* maximize_button = |
| 454 CustomFrameViewAshTest::maximize_button(); | 458 CustomFrameViewAshTest::maximize_button(); |
| 455 maximize_button->set_bubble_appearance_delay_ms(0); | 459 maximize_button->set_bubble_appearance_delay_ms(0); |
| 456 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 460 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 457 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 461 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
| 458 | 462 |
| 459 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 463 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
| 460 EXPECT_FALSE(maximize_button->maximizer()); | 464 EXPECT_FALSE(maximize_button->maximizer()); |
| 461 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 465 EXPECT_TRUE(wm::GetWindowState(window)->IsNormal()); |
| 462 EXPECT_FALSE(maximize_button->phantom_window_open()); | 466 EXPECT_FALSE(maximize_button->phantom_window_open()); |
| 463 | 467 |
| 464 // Move the mouse cursor over the button to bring up the maximizer bubble. | 468 // Move the mouse cursor over the button to bring up the maximizer bubble. |
| 465 generator.MoveMouseTo(button_pos); | 469 generator.MoveMouseTo(button_pos); |
| 466 EXPECT_TRUE(maximize_button->maximizer()); | 470 EXPECT_TRUE(maximize_button->maximizer()); |
| 467 | 471 |
| 468 // Move the mouse over the left maximize button. | 472 // Move the mouse over the left maximize button. |
| 469 gfx::Point left_max_pos = maximize_button->maximizer()-> | 473 gfx::Point left_max_pos = maximize_button->maximizer()-> |
| 470 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); | 474 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); |
| 471 generator.MoveMouseTo(left_max_pos); | 475 generator.MoveMouseTo(left_max_pos); |
| 472 EXPECT_TRUE(maximize_button->phantom_window_open()); | 476 EXPECT_TRUE(maximize_button->phantom_window_open()); |
| 473 generator.ClickLeftButton(); | 477 generator.ClickLeftButton(); |
| 474 | 478 |
| 475 EXPECT_FALSE(maximize_button->maximizer()); | 479 EXPECT_FALSE(maximize_button->maximizer()); |
| 476 EXPECT_FALSE(maximize_button->phantom_window_open()); | 480 EXPECT_FALSE(maximize_button->phantom_window_open()); |
| 477 | 481 |
| 478 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 482 wm::WindowState* window_state =wm::GetWindowState(window); |
|
James Cook
2013/09/18 20:44:17
space after =
oshima
2013/09/19 01:52:01
Done.
| |
| 479 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 483 EXPECT_FALSE(window_state->IsMaximized()); |
| 484 EXPECT_FALSE(window_state->IsMinimized()); | |
| 480 internal::SnapSizer sizer(window, button_pos, | 485 internal::SnapSizer sizer(window, button_pos, |
| 481 internal::SnapSizer::LEFT_EDGE, | 486 internal::SnapSizer::LEFT_EDGE, |
| 482 internal::SnapSizer::OTHER_INPUT); | 487 internal::SnapSizer::OTHER_INPUT); |
| 483 sizer.SelectDefaultSizeAndDisableResize(); | 488 sizer.SelectDefaultSizeAndDisableResize(); |
| 484 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); | 489 EXPECT_EQ(sizer.target_bounds().ToString(), window->bounds().ToString()); |
| 485 } | 490 } |
| 486 | 491 |
| 487 // Test that the activation focus does not change when the bubble gets shown. | 492 // Test that the activation focus does not change when the bubble gets shown. |
| 488 TEST_F(CustomFrameViewAshTest, MaximizeKeepFocus) { | 493 TEST_F(CustomFrameViewAshTest, MaximizeKeepFocus) { |
| 489 aura::Window* window = widget()->GetNativeWindow(); | 494 aura::Window* window = widget()->GetNativeWindow(); |
| 490 ash::FrameMaximizeButton* maximize_button = | 495 ash::FrameMaximizeButton* maximize_button = |
| 491 CustomFrameViewAshTest::maximize_button(); | 496 CustomFrameViewAshTest::maximize_button(); |
| 492 maximize_button->set_bubble_appearance_delay_ms(0); | 497 maximize_button->set_bubble_appearance_delay_ms(0); |
| 493 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 498 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 494 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 499 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
| 495 | 500 |
| 496 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 501 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
| 497 EXPECT_FALSE(maximize_button->maximizer()); | 502 EXPECT_FALSE(maximize_button->maximizer()); |
| 498 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 503 EXPECT_TRUE(wm::GetWindowState(window)->IsNormal()); |
| 499 | 504 |
| 500 aura::Window* active = | 505 aura::Window* active = |
| 501 aura::client::GetFocusClient(window)->GetFocusedWindow(); | 506 aura::client::GetFocusClient(window)->GetFocusedWindow(); |
| 502 | 507 |
| 503 // Move the mouse cursor over the button to bring up the maximizer bubble. | 508 // Move the mouse cursor over the button to bring up the maximizer bubble. |
| 504 generator.MoveMouseTo(button_pos); | 509 generator.MoveMouseTo(button_pos); |
| 505 EXPECT_TRUE(maximize_button->maximizer()); | 510 EXPECT_TRUE(maximize_button->maximizer()); |
| 506 | 511 |
| 507 // Check that the focused window is still the same. | 512 // Check that the focused window is still the same. |
| 508 EXPECT_EQ(active, aura::client::GetFocusClient(window)->GetFocusedWindow()); | 513 EXPECT_EQ(active, aura::client::GetFocusClient(window)->GetFocusedWindow()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 TEST_F(CustomFrameViewAshTest, OnlyLeftButtonMaximizes) { | 546 TEST_F(CustomFrameViewAshTest, OnlyLeftButtonMaximizes) { |
| 542 aura::Window* window = widget()->GetNativeWindow(); | 547 aura::Window* window = widget()->GetNativeWindow(); |
| 543 ash::FrameMaximizeButton* maximize_button = | 548 ash::FrameMaximizeButton* maximize_button = |
| 544 CustomFrameViewAshTest::maximize_button(); | 549 CustomFrameViewAshTest::maximize_button(); |
| 545 maximize_button->set_bubble_appearance_delay_ms(0); | 550 maximize_button->set_bubble_appearance_delay_ms(0); |
| 546 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 551 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 547 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 552 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
| 548 | 553 |
| 549 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 554 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
| 550 EXPECT_FALSE(maximize_button->maximizer()); | 555 EXPECT_FALSE(maximize_button->maximizer()); |
| 551 EXPECT_TRUE(ash::wm::IsWindowNormal(window)); | 556 wm::WindowState* window_state = wm::GetWindowState(window); |
| 552 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 557 EXPECT_TRUE(window_state->IsNormal()); |
| 558 EXPECT_FALSE(window_state->IsMaximized()); | |
| 553 | 559 |
| 554 // Move the mouse cursor over the button. | 560 // Move the mouse cursor over the button. |
| 555 generator.MoveMouseTo(button_pos); | 561 generator.MoveMouseTo(button_pos); |
| 556 EXPECT_TRUE(maximize_button->maximizer()); | 562 EXPECT_TRUE(maximize_button->maximizer()); |
| 557 EXPECT_FALSE(maximize_button->phantom_window_open()); | 563 EXPECT_FALSE(maximize_button->phantom_window_open()); |
| 558 | 564 |
| 559 // After pressing the left button the button should get triggered. | 565 // After pressing the left button the button should get triggered. |
| 560 generator.PressLeftButton(); | 566 generator.PressLeftButton(); |
| 561 RunAllPendingInMessageLoop(); | 567 RunAllPendingInMessageLoop(); |
| 562 EXPECT_TRUE(maximize_button->is_snap_enabled()); | 568 EXPECT_TRUE(maximize_button->is_snap_enabled()); |
| 563 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 569 EXPECT_FALSE(window_state->IsMaximized()); |
| 564 | 570 |
| 565 // Pressing the right button then should cancel the operation. | 571 // Pressing the right button then should cancel the operation. |
| 566 generator.PressRightButton(); | 572 generator.PressRightButton(); |
| 567 RunAllPendingInMessageLoop(); | 573 RunAllPendingInMessageLoop(); |
| 568 EXPECT_FALSE(maximize_button->maximizer()); | 574 EXPECT_FALSE(maximize_button->maximizer()); |
| 569 | 575 |
| 570 // After releasing the second button the window shouldn't be maximized. | 576 // After releasing the second button the window shouldn't be maximized. |
| 571 generator.ReleaseRightButton(); | 577 generator.ReleaseRightButton(); |
| 572 generator.ReleaseLeftButton(); | 578 generator.ReleaseLeftButton(); |
| 573 RunAllPendingInMessageLoop(); | 579 RunAllPendingInMessageLoop(); |
| 574 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 580 EXPECT_FALSE(window_state->IsMaximized()); |
| 575 | 581 |
| 576 // Second experiment: Starting with right should also not trigger. | 582 // Second experiment: Starting with right should also not trigger. |
| 577 generator.MoveMouseTo(off_pos); | 583 generator.MoveMouseTo(off_pos); |
| 578 generator.MoveMouseTo(button_pos); | 584 generator.MoveMouseTo(button_pos); |
| 579 EXPECT_TRUE(maximize_button->maximizer()); | 585 EXPECT_TRUE(maximize_button->maximizer()); |
| 580 | 586 |
| 581 // Pressing first the right button should not activate. | 587 // Pressing first the right button should not activate. |
| 582 generator.PressRightButton(); | 588 generator.PressRightButton(); |
| 583 RunAllPendingInMessageLoop(); | 589 RunAllPendingInMessageLoop(); |
| 584 EXPECT_FALSE(maximize_button->is_snap_enabled()); | 590 EXPECT_FALSE(maximize_button->is_snap_enabled()); |
| 585 | 591 |
| 586 // Pressing then additionally the left button shouldn't activate either. | 592 // Pressing then additionally the left button shouldn't activate either. |
| 587 generator.PressLeftButton(); | 593 generator.PressLeftButton(); |
| 588 RunAllPendingInMessageLoop(); | 594 RunAllPendingInMessageLoop(); |
| 589 EXPECT_FALSE(maximize_button->is_snap_enabled()); | 595 EXPECT_FALSE(maximize_button->is_snap_enabled()); |
| 590 generator.ReleaseRightButton(); | 596 generator.ReleaseRightButton(); |
| 591 generator.ReleaseLeftButton(); | 597 generator.ReleaseLeftButton(); |
| 592 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 598 EXPECT_FALSE(window_state->IsMaximized()); |
| 593 } | 599 } |
| 594 | 600 |
| 595 // Click a button of window maximize functionality. | 601 // Click a button of window maximize functionality. |
| 596 // If |snap_type| is SNAP_NONE the FrameMaximizeButton gets clicked, otherwise | 602 // If |snap_type| is SNAP_NONE the FrameMaximizeButton gets clicked, otherwise |
| 597 // the associated snap button. | 603 // the associated snap button. |
| 598 // |Window| is the window which owns the maximize button. | 604 // |Window| is the window which owns the maximize button. |
| 599 // |maximize_button| is the FrameMaximizeButton which controls the window. | 605 // |maximize_button| is the FrameMaximizeButton which controls the window. |
| 600 void ClickMaxButton( | 606 void ClickMaxButton( |
| 601 ash::FrameMaximizeButton* maximize_button, | 607 ash::FrameMaximizeButton* maximize_button, |
| 602 aura::Window* window, | 608 aura::Window* window, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 627 | 633 |
| 628 // Test that the restore from left/right maximize is properly done. | 634 // Test that the restore from left/right maximize is properly done. |
| 629 TEST_F(CustomFrameViewAshTest, MaximizeLeftRestore) { | 635 TEST_F(CustomFrameViewAshTest, MaximizeLeftRestore) { |
| 630 aura::Window* window = widget()->GetNativeWindow(); | 636 aura::Window* window = widget()->GetNativeWindow(); |
| 631 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); | 637 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); |
| 632 ash::FrameMaximizeButton* maximize_button = | 638 ash::FrameMaximizeButton* maximize_button = |
| 633 CustomFrameViewAshTest::maximize_button(); | 639 CustomFrameViewAshTest::maximize_button(); |
| 634 maximize_button->set_bubble_appearance_delay_ms(0); | 640 maximize_button->set_bubble_appearance_delay_ms(0); |
| 635 | 641 |
| 636 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 642 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
| 643 wm::WindowState* window_state = wm::GetWindowState(window); | |
| 637 // The window should not be maximized. | 644 // The window should not be maximized. |
| 638 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 645 EXPECT_FALSE(window_state->IsMaximized()); |
| 639 // But the bounds should be different. | 646 // But the bounds should be different. |
| 640 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); | 647 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); |
| 641 EXPECT_EQ(0, new_bounds.x()); | 648 EXPECT_EQ(0, new_bounds.x()); |
| 642 EXPECT_EQ(0, new_bounds.y()); | 649 EXPECT_EQ(0, new_bounds.y()); |
| 643 | 650 |
| 644 // Now click the same button again to see that it restores. | 651 // Now click the same button again to see that it restores. |
| 645 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 652 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
| 646 // But the bounds should be restored. | 653 // But the bounds should be restored. |
| 647 new_bounds = widget()->GetWindowBoundsInScreen(); | 654 new_bounds = widget()->GetWindowBoundsInScreen(); |
| 648 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); | 655 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); |
| 649 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); | 656 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); |
| 650 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); | 657 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); |
| 651 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); | 658 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); |
| 652 // Make sure that there is no restore rectangle left. | 659 // Make sure that there is no restore rectangle left. |
| 653 EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window)); | 660 EXPECT_FALSE(window_state->HasRestoreBounds()); |
| 654 } | 661 } |
| 655 | 662 |
| 656 // Maximize, left/right maximize and then restore should works. | 663 // Maximize, left/right maximize and then restore should works. |
| 657 TEST_F(CustomFrameViewAshTest, MaximizeMaximizeLeftRestore) { | 664 TEST_F(CustomFrameViewAshTest, MaximizeMaximizeLeftRestore) { |
| 658 aura::Window* window = widget()->GetNativeWindow(); | 665 aura::Window* window = widget()->GetNativeWindow(); |
| 659 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); | 666 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); |
| 660 ash::FrameMaximizeButton* maximize_button = | 667 ash::FrameMaximizeButton* maximize_button = |
| 661 CustomFrameViewAshTest::maximize_button(); | 668 CustomFrameViewAshTest::maximize_button(); |
| 662 maximize_button->set_bubble_appearance_delay_ms(0); | 669 maximize_button->set_bubble_appearance_delay_ms(0); |
| 663 | 670 |
| 664 ClickMaxButton(maximize_button, window, SNAP_NONE); | 671 ClickMaxButton(maximize_button, window, SNAP_NONE); |
| 665 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 672 |
| 673 wm::WindowState* window_state = wm::GetWindowState(window); | |
| 674 EXPECT_TRUE(window_state->IsMaximized()); | |
| 666 | 675 |
| 667 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 676 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
| 668 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 677 EXPECT_FALSE(window_state->IsMaximized()); |
| 669 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); | 678 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); |
| 670 EXPECT_EQ(0, new_bounds.x()); | 679 EXPECT_EQ(0, new_bounds.x()); |
| 671 EXPECT_EQ(0, new_bounds.y()); | 680 EXPECT_EQ(0, new_bounds.y()); |
| 672 | 681 |
| 673 // Now click the same button again to see that it restores. | 682 // Now click the same button again to see that it restores. |
| 674 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 683 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
| 675 RunAllPendingInMessageLoop(); | 684 RunAllPendingInMessageLoop(); |
| 676 // But the bounds should be restored. | 685 // But the bounds should be restored. |
| 677 new_bounds = widget()->GetWindowBoundsInScreen(); | 686 new_bounds = widget()->GetWindowBoundsInScreen(); |
| 678 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); | 687 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); |
| 679 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); | 688 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); |
| 680 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); | 689 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); |
| 681 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); | 690 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); |
| 682 // Make sure that there is no restore rectangle left. | 691 // Make sure that there is no restore rectangle left. |
| 683 EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window)); | 692 EXPECT_FALSE(window_state->HasRestoreBounds()); |
| 684 } | 693 } |
| 685 | 694 |
| 686 // Left/right maximize, maximize and then restore should work. | 695 // Left/right maximize, maximize and then restore should work. |
| 687 TEST_F(CustomFrameViewAshTest, MaximizeLeftMaximizeRestore) { | 696 TEST_F(CustomFrameViewAshTest, MaximizeLeftMaximizeRestore) { |
| 688 aura::Window* window = widget()->GetNativeWindow(); | 697 aura::Window* window = widget()->GetNativeWindow(); |
| 689 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); | 698 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); |
| 690 ash::FrameMaximizeButton* maximize_button = | 699 ash::FrameMaximizeButton* maximize_button = |
| 691 CustomFrameViewAshTest::maximize_button(); | 700 CustomFrameViewAshTest::maximize_button(); |
| 692 maximize_button->set_bubble_appearance_delay_ms(0); | 701 maximize_button->set_bubble_appearance_delay_ms(0); |
| 693 | 702 |
| 694 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 703 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
| 695 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 704 |
| 705 wm::WindowState* window_state =wm::GetWindowState(window); | |
|
James Cook
2013/09/18 20:44:17
space after =
oshima
2013/09/19 01:52:01
Done.
| |
| 706 EXPECT_FALSE(window_state->IsMaximized()); | |
| 696 | 707 |
| 697 ClickMaxButton(maximize_button, window, SNAP_NONE); | 708 ClickMaxButton(maximize_button, window, SNAP_NONE); |
| 698 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 709 EXPECT_TRUE(window_state->IsMaximized()); |
| 699 | 710 |
| 700 ClickMaxButton(maximize_button, window, SNAP_NONE); | 711 ClickMaxButton(maximize_button, window, SNAP_NONE); |
| 701 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 712 EXPECT_FALSE(window_state->IsMaximized()); |
| 702 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); | 713 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); |
| 703 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); | 714 EXPECT_EQ(new_bounds.x(), initial_bounds.x()); |
| 704 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); | 715 EXPECT_EQ(new_bounds.y(), initial_bounds.x()); |
| 705 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); | 716 EXPECT_EQ(new_bounds.width(), initial_bounds.width()); |
| 706 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); | 717 EXPECT_EQ(new_bounds.height(), initial_bounds.height()); |
| 707 // Make sure that there is no restore rectangle left. | 718 // Make sure that there is no restore rectangle left. |
| 708 EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window)); | 719 EXPECT_FALSE(window_state->HasRestoreBounds()); |
| 709 } | 720 } |
| 710 | 721 |
| 711 // Starting with a window which has no restore bounds, maximize then left/right | 722 // Starting with a window which has no restore bounds, maximize then left/right |
| 712 // maximize should not be centered but left/right maximized. | 723 // maximize should not be centered but left/right maximized. |
| 713 TEST_F(CustomFrameViewAshTest, MaximizeThenLeftMaximize) { | 724 TEST_F(CustomFrameViewAshTest, MaximizeThenLeftMaximize) { |
| 714 aura::Window* window = widget()->GetNativeWindow(); | 725 aura::Window* window = widget()->GetNativeWindow(); |
| 715 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); | 726 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); |
| 716 ash::FrameMaximizeButton* maximize_button = | 727 ash::FrameMaximizeButton* maximize_button = |
| 717 CustomFrameViewAshTest::maximize_button(); | 728 CustomFrameViewAshTest::maximize_button(); |
| 718 maximize_button->set_bubble_appearance_delay_ms(0); | 729 maximize_button->set_bubble_appearance_delay_ms(0); |
| 730 | |
| 731 wm::WindowState* controller = wm::GetWindowState(window); | |
|
James Cook
2013/09/18 20:44:17
optional: controller -> window_state?
oshima
2013/09/19 01:52:01
This test is gone on tot.
| |
| 719 // Make sure that there is no restore rectangle. | 732 // Make sure that there is no restore rectangle. |
| 720 EXPECT_EQ(NULL, GetRestoreBoundsInScreen(window)); | 733 EXPECT_FALSE(controller->HasRestoreBounds()); |
| 721 | 734 |
| 722 ClickMaxButton(maximize_button, window, SNAP_NONE); | 735 ClickMaxButton(maximize_button, window, SNAP_NONE); |
| 723 EXPECT_TRUE(ash::wm::IsWindowMaximized(window)); | 736 EXPECT_TRUE(controller->IsMaximized()); |
| 724 | 737 |
| 725 ClickMaxButton(maximize_button, window, SNAP_LEFT); | 738 ClickMaxButton(maximize_button, window, SNAP_LEFT); |
| 726 EXPECT_FALSE(ash::wm::IsWindowMaximized(window)); | 739 EXPECT_FALSE(controller->IsMaximized()); |
| 727 | 740 |
| 728 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); | 741 gfx::Rect new_bounds = widget()->GetWindowBoundsInScreen(); |
| 729 EXPECT_EQ(new_bounds.x(), 0); | 742 EXPECT_EQ(new_bounds.x(), 0); |
| 730 EXPECT_EQ(new_bounds.y(), 0); | 743 EXPECT_EQ(new_bounds.y(), 0); |
| 731 // Make sure that the restore rectangle is the original rectangle. | 744 // Make sure that the restore rectangle is the original rectangle. |
| 732 EXPECT_EQ(initial_bounds.ToString(), | 745 EXPECT_EQ(initial_bounds.ToString(), |
| 733 GetRestoreBoundsInScreen(window)->ToString()); | 746 controller->GetRestoreBoundsInScreen().ToString()); |
| 734 } | 747 } |
| 735 | 748 |
| 736 // Test that minimizing the window per keyboard closes the maximize bubble. | 749 // Test that minimizing the window per keyboard closes the maximize bubble. |
| 737 TEST_F(CustomFrameViewAshTest, MinimizePerKeyClosesBubble) { | 750 TEST_F(CustomFrameViewAshTest, MinimizePerKeyClosesBubble) { |
| 738 aura::Window* window = widget()->GetNativeWindow(); | 751 aura::Window* window = widget()->GetNativeWindow(); |
| 739 ash::FrameMaximizeButton* maximize_button = | 752 ash::FrameMaximizeButton* maximize_button = |
| 740 CustomFrameViewAshTest::maximize_button(); | 753 CustomFrameViewAshTest::maximize_button(); |
| 741 | 754 |
| 742 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 755 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 743 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); | 756 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); |
| 744 | 757 |
| 745 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); | 758 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); |
| 746 generator.MoveMouseTo(off_pos); | 759 generator.MoveMouseTo(off_pos); |
| 747 EXPECT_FALSE(maximize_button->maximizer()); | 760 EXPECT_FALSE(maximize_button->maximizer()); |
| 748 | 761 |
| 749 // Move the mouse cursor over the maximize button. | 762 // Move the mouse cursor over the maximize button. |
| 750 generator.MoveMouseTo(button_pos); | 763 generator.MoveMouseTo(button_pos); |
| 751 EXPECT_TRUE(maximize_button->maximizer()); | 764 EXPECT_TRUE(maximize_button->maximizer()); |
| 752 | 765 |
| 753 // We simulate the keystroke by calling minimizeWindow directly. | 766 // We simulate the keystroke by calling minimizeWindow directly. |
| 754 wm::MinimizeWindow(window); | 767 wm::WindowState* window_state = wm::GetWindowState(window); |
| 768 window_state->Minimize(); | |
| 755 | 769 |
| 756 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); | 770 EXPECT_TRUE(window_state->IsMinimized()); |
| 757 EXPECT_FALSE(maximize_button->maximizer()); | 771 EXPECT_FALSE(maximize_button->maximizer()); |
| 758 } | 772 } |
| 759 | 773 |
| 760 // Tests that dragging down on the maximize button minimizes the window. | 774 // Tests that dragging down on the maximize button minimizes the window. |
| 761 TEST_F(CustomFrameViewAshTest, MaximizeButtonDragDownMinimizes) { | 775 TEST_F(CustomFrameViewAshTest, MaximizeButtonDragDownMinimizes) { |
| 762 aura::Window* window = widget()->GetNativeWindow(); | 776 aura::Window* window = widget()->GetNativeWindow(); |
| 763 ash::FrameMaximizeButton* maximize_button = | 777 ash::FrameMaximizeButton* maximize_button = |
| 764 CustomFrameViewAshTest::maximize_button(); | 778 CustomFrameViewAshTest::maximize_button(); |
| 765 | 779 |
| 780 wm::WindowState* window_state = wm::GetWindowState(window); | |
| 766 // Drag down on a maximized window. | 781 // Drag down on a maximized window. |
| 767 wm::MaximizeWindow(window); | 782 window_state->Maximize(); |
| 768 EXPECT_TRUE(wm::IsWindowMaximized(window)); | 783 EXPECT_TRUE(window_state->IsMaximized()); |
| 769 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 784 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 770 gfx::Point off_pos(button_pos.x(), button_pos.y() + 100); | 785 gfx::Point off_pos(button_pos.x(), button_pos.y() + 100); |
| 771 | 786 |
| 772 aura::test::EventGenerator generator(window->GetRootWindow()); | 787 aura::test::EventGenerator generator(window->GetRootWindow()); |
| 773 generator.GestureScrollSequence(button_pos, off_pos, | 788 generator.GestureScrollSequence(button_pos, off_pos, |
| 774 base::TimeDelta::FromMilliseconds(0), 1); | 789 base::TimeDelta::FromMilliseconds(0), 1); |
| 775 | 790 |
| 776 EXPECT_TRUE(wm::IsWindowMinimized(window)); | 791 EXPECT_TRUE(window_state->IsMinimized()); |
| 777 EXPECT_FALSE(maximize_button->maximizer()); | 792 EXPECT_FALSE(maximize_button->maximizer()); |
| 778 | 793 |
| 779 // Drag down on a restored window. | 794 // Drag down on a restored window. |
| 780 wm::RestoreWindow(window); | 795 window_state->Restore(); |
| 781 | 796 |
| 782 button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 797 button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
| 783 off_pos = gfx::Point(button_pos.x(), button_pos.y() + 200); | 798 off_pos = gfx::Point(button_pos.x(), button_pos.y() + 200); |
| 784 generator.GestureScrollSequence(button_pos, off_pos, | 799 generator.GestureScrollSequence(button_pos, off_pos, |
| 785 base::TimeDelta::FromMilliseconds(10), 1); | 800 base::TimeDelta::FromMilliseconds(10), 1); |
| 786 EXPECT_TRUE(wm::IsWindowMinimized(window)); | 801 EXPECT_TRUE(window_state->IsMinimized()); |
| 787 EXPECT_FALSE(maximize_button->maximizer()); | 802 EXPECT_FALSE(maximize_button->maximizer()); |
| 788 } | 803 } |
| 789 | 804 |
| 790 // Tests that dragging Left and pressing ESC does properly abort. | 805 // Tests that dragging Left and pressing ESC does properly abort. |
| 791 TEST_F(CustomFrameViewAshTest, MaximizeButtonDragLeftEscapeExits) { | 806 TEST_F(CustomFrameViewAshTest, MaximizeButtonDragLeftEscapeExits) { |
| 792 aura::Window* window = widget()->GetNativeWindow(); | 807 aura::Window* window = widget()->GetNativeWindow(); |
| 793 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); | 808 gfx::Rect initial_bounds = widget()->GetWindowBoundsInScreen(); |
| 794 ash::FrameMaximizeButton* maximize_button = | 809 ash::FrameMaximizeButton* maximize_button = |
| 795 CustomFrameViewAshTest::maximize_button(); | 810 CustomFrameViewAshTest::maximize_button(); |
| 796 | 811 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 810 | 825 |
| 811 // Check that there was no size change. | 826 // Check that there was no size change. |
| 812 EXPECT_EQ(widget()->GetWindowBoundsInScreen().size().ToString(), | 827 EXPECT_EQ(widget()->GetWindowBoundsInScreen().size().ToString(), |
| 813 initial_bounds.size().ToString()); | 828 initial_bounds.size().ToString()); |
| 814 // Check that there is no phantom window left open. | 829 // Check that there is no phantom window left open. |
| 815 EXPECT_FALSE(maximize_button->phantom_window_open()); | 830 EXPECT_FALSE(maximize_button->phantom_window_open()); |
| 816 } | 831 } |
| 817 | 832 |
| 818 } // namespace test | 833 } // namespace test |
| 819 } // namespace ash | 834 } // namespace ash |
| OLD | NEW |