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

Side by Side Diff: ash/wm/caption_buttons/frame_maximize_button_unittest.cc

Issue 169713003: Remove WindowState::IsNormalShowState() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/caption_buttons/alternate_frame_size_button_unittest.cc ('k') | ash/wm/default_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/caption_buttons/frame_maximize_button.h" 5 #include "ash/wm/caption_buttons/frame_maximize_button.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"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 // Tests that click+dragging on the resize-button tiles or minimizes the window. 220 // Tests that click+dragging on the resize-button tiles or minimizes the window.
221 TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) { 221 TEST_F(FrameMaximizeButtonTest, MAYBE_ResizeButtonDrag) {
222 aura::Window* window = widget()->GetNativeWindow(); 222 aura::Window* window = widget()->GetNativeWindow();
223 views::View* view = maximize_button(); 223 views::View* view = maximize_button();
224 gfx::Point center = view->GetBoundsInScreen().CenterPoint(); 224 gfx::Point center = view->GetBoundsInScreen().CenterPoint();
225 225
226 aura::test::EventGenerator generator(window->GetRootWindow(), center); 226 aura::test::EventGenerator generator(window->GetRootWindow(), center);
227 227
228 wm::WindowState* window_state = wm::GetWindowState(window); 228 wm::WindowState* window_state = wm::GetWindowState(window);
229 EXPECT_TRUE(window_state->IsNormalShowState()); 229 EXPECT_TRUE(window_state->IsNormalShowType());
230 230
231 // Snap right. 231 // Snap right.
232 { 232 {
233 generator.PressLeftButton(); 233 generator.PressLeftButton();
234 generator.MoveMouseBy(10, 0); 234 generator.MoveMouseBy(10, 0);
235 generator.ReleaseLeftButton(); 235 generator.ReleaseLeftButton();
236 RunAllPendingInMessageLoop(); 236 RunAllPendingInMessageLoop();
237 237
238 EXPECT_FALSE(window_state->IsMaximized()); 238 EXPECT_FALSE(window_state->IsMaximized());
239 EXPECT_FALSE(window_state->IsMinimized()); 239 EXPECT_FALSE(window_state->IsMinimized());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 base::TimeDelta::FromMilliseconds(100), 320 base::TimeDelta::FromMilliseconds(100),
321 3); 321 3);
322 RunAllPendingInMessageLoop(); 322 RunAllPendingInMessageLoop();
323 323
324 EXPECT_TRUE(window_state->IsMinimized()); 324 EXPECT_TRUE(window_state->IsMinimized());
325 } 325 }
326 326
327 // Test with gesture events. 327 // Test with gesture events.
328 } 328 }
329 329
330 #if defined(OS_WIN)
331 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962
332 #define MAYBE_TouchDragResizeCloseToCornerDiffersFromMouse \
333 DISABLED_TouchDragResizeCloseToCornerDiffersFromMouse
334 #else
335 #define MAYBE_TouchDragResizeCloseToCornerDiffersFromMouse \
336 TouchDragResizeCloseToCornerDiffersFromMouse
337 #endif
338
339 // Test that closing the (browser) window with an opened balloon does not 330 // Test that closing the (browser) window with an opened balloon does not
340 // crash the system. In other words: Make sure that shutting down the frame 331 // crash the system. In other words: Make sure that shutting down the frame
341 // destroys the opened balloon in an orderly fashion. 332 // destroys the opened balloon in an orderly fashion.
342 TEST_F(FrameMaximizeButtonTest, MaximizeButtonExternalShutDown) { 333 TEST_F(FrameMaximizeButtonTest, MaximizeButtonExternalShutDown) {
343 aura::Window* window = widget()->GetNativeWindow(); 334 aura::Window* window = widget()->GetNativeWindow();
344 ash::FrameMaximizeButton* maximize_button = 335 ash::FrameMaximizeButton* maximize_button =
345 FrameMaximizeButtonTest::maximize_button(); 336 FrameMaximizeButtonTest::maximize_button();
346 maximize_button->set_bubble_appearance_delay_ms(0); 337 maximize_button->set_bubble_appearance_delay_ms(0);
347 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); 338 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
348 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); 339 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
349 340
350 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); 341 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
351 EXPECT_FALSE(maximize_button->maximizer()); 342 EXPECT_FALSE(maximize_button->maximizer());
352 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); 343 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowType());
353 344
354 // Move the mouse cursor over the button to bring up the maximizer bubble. 345 // Move the mouse cursor over the button to bring up the maximizer bubble.
355 generator.MoveMouseTo(button_pos); 346 generator.MoveMouseTo(button_pos);
356 EXPECT_TRUE(maximize_button->maximizer()); 347 EXPECT_TRUE(maximize_button->maximizer());
357 348
358 // Even though the widget is closing the bubble menu should not crash upon 349 // Even though the widget is closing the bubble menu should not crash upon
359 // its delayed destruction. 350 // its delayed destruction.
360 CloseWidget(); 351 CloseWidget();
361 } 352 }
362 353
363 // Test that maximizing the browser after hovering in does not crash the system 354 // Test that maximizing the browser after hovering in does not crash the system
364 // when the observer gets removed in the bubble destruction process. 355 // when the observer gets removed in the bubble destruction process.
365 TEST_F(FrameMaximizeButtonTest, MaximizeOnHoverThenClick) { 356 TEST_F(FrameMaximizeButtonTest, MaximizeOnHoverThenClick) {
366 aura::Window* window = widget()->GetNativeWindow(); 357 aura::Window* window = widget()->GetNativeWindow();
367 ash::FrameMaximizeButton* maximize_button = 358 ash::FrameMaximizeButton* maximize_button =
368 FrameMaximizeButtonTest::maximize_button(); 359 FrameMaximizeButtonTest::maximize_button();
369 maximize_button->set_bubble_appearance_delay_ms(0); 360 maximize_button->set_bubble_appearance_delay_ms(0);
370 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); 361 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
371 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); 362 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
372 363
373 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); 364 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
374 EXPECT_FALSE(maximize_button->maximizer()); 365 EXPECT_FALSE(maximize_button->maximizer());
375 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); 366 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowType());
376 367
377 // Move the mouse cursor over the button to bring up the maximizer bubble. 368 // Move the mouse cursor over the button to bring up the maximizer bubble.
378 generator.MoveMouseTo(button_pos); 369 generator.MoveMouseTo(button_pos);
379 EXPECT_TRUE(maximize_button->maximizer()); 370 EXPECT_TRUE(maximize_button->maximizer());
380 generator.ClickLeftButton(); 371 generator.ClickLeftButton();
381 EXPECT_TRUE(wm::GetWindowState(window)->IsMaximized()); 372 EXPECT_TRUE(wm::GetWindowState(window)->IsMaximized());
382 } 373 }
383 374
384 // Test that hovering over a button in the balloon dialog will show the phantom 375 // Test that hovering over a button in the balloon dialog will show the phantom
385 // window. Moving then away from the button will hide it again. Then check that 376 // window. Moving then away from the button will hide it again. Then check that
386 // pressing and dragging the button itself off the button will also release the 377 // pressing and dragging the button itself off the button will also release the
387 // phantom window. 378 // phantom window.
388 TEST_F(FrameMaximizeButtonTest, MaximizeLeftButtonDragOut) { 379 TEST_F(FrameMaximizeButtonTest, MaximizeLeftButtonDragOut) {
389 aura::Window* window = widget()->GetNativeWindow(); 380 aura::Window* window = widget()->GetNativeWindow();
390 ash::FrameMaximizeButton* maximize_button = 381 ash::FrameMaximizeButton* maximize_button =
391 FrameMaximizeButtonTest::maximize_button(); 382 FrameMaximizeButtonTest::maximize_button();
392 maximize_button->set_bubble_appearance_delay_ms(0); 383 maximize_button->set_bubble_appearance_delay_ms(0);
393 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); 384 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
394 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); 385 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
395 386
396 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); 387 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
397 EXPECT_FALSE(maximize_button->maximizer()); 388 EXPECT_FALSE(maximize_button->maximizer());
398 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); 389 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowType());
399 EXPECT_FALSE(maximize_button->phantom_window_open()); 390 EXPECT_FALSE(maximize_button->phantom_window_open());
400 391
401 // Move the mouse cursor over the button to bring up the maximizer bubble. 392 // Move the mouse cursor over the button to bring up the maximizer bubble.
402 generator.MoveMouseTo(button_pos); 393 generator.MoveMouseTo(button_pos);
403 EXPECT_TRUE(maximize_button->maximizer()); 394 EXPECT_TRUE(maximize_button->maximizer());
404 395
405 // Move the mouse over the left maximize button. 396 // Move the mouse over the left maximize button.
406 gfx::Point left_max_pos = maximize_button->maximizer()-> 397 gfx::Point left_max_pos = maximize_button->maximizer()->
407 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); 398 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint();
408 399
(...skipping 25 matching lines...) Expand all
434 aura::Window* window = widget()->GetNativeWindow(); 425 aura::Window* window = widget()->GetNativeWindow();
435 426
436 ash::FrameMaximizeButton* maximize_button = 427 ash::FrameMaximizeButton* maximize_button =
437 FrameMaximizeButtonTest::maximize_button(); 428 FrameMaximizeButtonTest::maximize_button();
438 maximize_button->set_bubble_appearance_delay_ms(0); 429 maximize_button->set_bubble_appearance_delay_ms(0);
439 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); 430 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
440 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); 431 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
441 432
442 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); 433 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
443 EXPECT_FALSE(maximize_button->maximizer()); 434 EXPECT_FALSE(maximize_button->maximizer());
444 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); 435 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowType());
445 EXPECT_FALSE(maximize_button->phantom_window_open()); 436 EXPECT_FALSE(maximize_button->phantom_window_open());
446 437
447 // Move the mouse cursor over the button to bring up the maximizer bubble. 438 // Move the mouse cursor over the button to bring up the maximizer bubble.
448 generator.MoveMouseTo(button_pos); 439 generator.MoveMouseTo(button_pos);
449 EXPECT_TRUE(maximize_button->maximizer()); 440 EXPECT_TRUE(maximize_button->maximizer());
450 441
451 // Move the mouse over the left maximize button. 442 // Move the mouse over the left maximize button.
452 gfx::Point left_max_pos = maximize_button->maximizer()-> 443 gfx::Point left_max_pos = maximize_button->maximizer()->
453 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); 444 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint();
454 generator.MoveMouseTo(left_max_pos); 445 generator.MoveMouseTo(left_max_pos);
(...skipping 16 matching lines...) Expand all
471 TEST_F(FrameMaximizeButtonTest, MaximizeKeepFocus) { 462 TEST_F(FrameMaximizeButtonTest, MaximizeKeepFocus) {
472 aura::Window* window = widget()->GetNativeWindow(); 463 aura::Window* window = widget()->GetNativeWindow();
473 ash::FrameMaximizeButton* maximize_button = 464 ash::FrameMaximizeButton* maximize_button =
474 FrameMaximizeButtonTest::maximize_button(); 465 FrameMaximizeButtonTest::maximize_button();
475 maximize_button->set_bubble_appearance_delay_ms(0); 466 maximize_button->set_bubble_appearance_delay_ms(0);
476 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); 467 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
477 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); 468 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
478 469
479 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); 470 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
480 EXPECT_FALSE(maximize_button->maximizer()); 471 EXPECT_FALSE(maximize_button->maximizer());
481 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); 472 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowType());
482 473
483 aura::Window* active = 474 aura::Window* active =
484 aura::client::GetFocusClient(window)->GetFocusedWindow(); 475 aura::client::GetFocusClient(window)->GetFocusedWindow();
485 476
486 // Move the mouse cursor over the button to bring up the maximizer bubble. 477 // Move the mouse cursor over the button to bring up the maximizer bubble.
487 generator.MoveMouseTo(button_pos); 478 generator.MoveMouseTo(button_pos);
488 EXPECT_TRUE(maximize_button->maximizer()); 479 EXPECT_TRUE(maximize_button->maximizer());
489 480
490 // Check that the focused window is still the same. 481 // Check that the focused window is still the same.
491 EXPECT_EQ(active, aura::client::GetFocusClient(window)->GetFocusedWindow()); 482 EXPECT_EQ(active, aura::client::GetFocusClient(window)->GetFocusedWindow());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 aura::Window* window = widget()->GetNativeWindow(); 519 aura::Window* window = widget()->GetNativeWindow();
529 ash::FrameMaximizeButton* maximize_button = 520 ash::FrameMaximizeButton* maximize_button =
530 FrameMaximizeButtonTest::maximize_button(); 521 FrameMaximizeButtonTest::maximize_button();
531 maximize_button->set_bubble_appearance_delay_ms(0); 522 maximize_button->set_bubble_appearance_delay_ms(0);
532 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); 523 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
533 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); 524 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
534 525
535 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); 526 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
536 EXPECT_FALSE(maximize_button->maximizer()); 527 EXPECT_FALSE(maximize_button->maximizer());
537 wm::WindowState* window_state = wm::GetWindowState(window); 528 wm::WindowState* window_state = wm::GetWindowState(window);
538 EXPECT_TRUE(window_state->IsNormalShowState()); 529 EXPECT_TRUE(window_state->IsNormalShowType());
539 EXPECT_FALSE(window_state->IsMaximized()); 530 EXPECT_FALSE(window_state->IsMaximized());
540 531
541 // Move the mouse cursor over the button. 532 // Move the mouse cursor over the button.
542 generator.MoveMouseTo(button_pos); 533 generator.MoveMouseTo(button_pos);
543 EXPECT_TRUE(maximize_button->maximizer()); 534 EXPECT_TRUE(maximize_button->maximizer());
544 EXPECT_FALSE(maximize_button->phantom_window_open()); 535 EXPECT_FALSE(maximize_button->phantom_window_open());
545 536
546 // After pressing the left button the button should get triggered. 537 // After pressing the left button the button should get triggered.
547 generator.PressLeftButton(); 538 generator.PressLeftButton();
548 RunAllPendingInMessageLoop(); 539 RunAllPendingInMessageLoop();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 777
787 // Test that hovering over a button in the maximizer bubble and switching 778 // Test that hovering over a button in the maximizer bubble and switching
788 // activation without moving the mouse properly aborts. 779 // activation without moving the mouse properly aborts.
789 TEST_F(FrameMaximizeButtonTest, LossOfActivationWhileMaximizeBubbleOpenAborts) { 780 TEST_F(FrameMaximizeButtonTest, LossOfActivationWhileMaximizeBubbleOpenAborts) {
790 aura::Window* window = widget()->GetNativeWindow(); 781 aura::Window* window = widget()->GetNativeWindow();
791 ash::FrameMaximizeButton* maximize_button = 782 ash::FrameMaximizeButton* maximize_button =
792 FrameMaximizeButtonTest::maximize_button(); 783 FrameMaximizeButtonTest::maximize_button();
793 maximize_button->set_bubble_appearance_delay_ms(0); 784 maximize_button->set_bubble_appearance_delay_ms(0);
794 785
795 gfx::Rect initial_bounds = window->GetBoundsInScreen(); 786 gfx::Rect initial_bounds = window->GetBoundsInScreen();
796 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); 787 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowType());
797 EXPECT_TRUE(widget()->IsActive()); 788 EXPECT_TRUE(widget()->IsActive());
798 789
799 // Move the mouse over the maximize button in order to bring up the maximizer 790 // Move the mouse over the maximize button in order to bring up the maximizer
800 // bubble. 791 // bubble.
801 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); 792 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint();
802 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100); 793 gfx::Point off_pos(button_pos.x() + 100, button_pos.y() + 100);
803 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos); 794 aura::test::EventGenerator generator(window->GetRootWindow(), off_pos);
804 generator.MoveMouseTo(button_pos); 795 generator.MoveMouseTo(button_pos);
805 EXPECT_TRUE(maximize_button->maximizer()); 796 EXPECT_TRUE(maximize_button->maximizer());
806 797
807 // Hover the mouse over the left maximize button in the maximizer bubble to 798 // Hover the mouse over the left maximize button in the maximizer bubble to
808 // show the phantom window. 799 // show the phantom window.
809 gfx::Point left_max_pos = maximize_button->maximizer()-> 800 gfx::Point left_max_pos = maximize_button->maximizer()->
810 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint(); 801 GetButtonForUnitTest(SNAP_LEFT)->GetBoundsInScreen().CenterPoint();
811 generator.MoveMouseTo(left_max_pos); 802 generator.MoveMouseTo(left_max_pos);
812 EXPECT_TRUE(maximize_button->phantom_window_open()); 803 EXPECT_TRUE(maximize_button->phantom_window_open());
813 804
814 // Change activation by creating a new window. This could be done via an 805 // Change activation by creating a new window. This could be done via an
815 // accelerator. The root window takes ownership of |just_created|. 806 // accelerator. The root window takes ownership of |just_created|.
816 views::Widget* just_created = views::Widget::CreateWindowWithContextAndBounds( 807 views::Widget* just_created = views::Widget::CreateWindowWithContextAndBounds(
817 NULL, widget()->GetNativeWindow(), gfx::Rect(100, 100)); 808 NULL, widget()->GetNativeWindow(), gfx::Rect(100, 100));
818 just_created->Show(); 809 just_created->Show();
819 just_created->Activate(); 810 just_created->Activate();
820 EXPECT_FALSE(widget()->IsActive()); 811 EXPECT_FALSE(widget()->IsActive());
821 812
822 // Test that we have properly reset the state of the now inactive window. 813 // Test that we have properly reset the state of the now inactive window.
823 EXPECT_FALSE(maximize_button->maximizer()); 814 EXPECT_FALSE(maximize_button->maximizer());
824 EXPECT_FALSE(maximize_button->phantom_window_open()); 815 EXPECT_FALSE(maximize_button->phantom_window_open());
825 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); 816 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowType());
826 EXPECT_EQ(initial_bounds.ToString(), window->GetBoundsInScreen().ToString()); 817 EXPECT_EQ(initial_bounds.ToString(), window->GetBoundsInScreen().ToString());
827 } 818 }
828 819
829 } // namespace test 820 } // namespace test
830 } // namespace ash 821 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/caption_buttons/alternate_frame_size_button_unittest.cc ('k') | ash/wm/default_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698