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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/download/download_service.h" | 8 #include "chrome/browser/download/download_service.h" |
9 #include "chrome/browser/download/download_service_factory.h" | 9 #include "chrome/browser/download/download_service_factory.h" |
10 #include "chrome/browser/net/url_request_mock_util.h" | 10 #include "chrome/browser/net/url_request_mock_util.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 std::vector<gfx::Rect> test_begin_bounds = GetAllPanelBounds(); | 144 std::vector<gfx::Rect> test_begin_bounds = GetAllPanelBounds(); |
145 std::vector<gfx::Rect> expected_bounds = test_begin_bounds; | 145 std::vector<gfx::Rect> expected_bounds = test_begin_bounds; |
146 std::vector<Panel::ExpansionState> expected_expansion_states( | 146 std::vector<Panel::ExpansionState> expected_expansion_states( |
147 panels.size(), Panel::EXPANDED); | 147 panels.size(), Panel::EXPANDED); |
148 std::vector<NativePanelTesting*> native_panels_testing(panels.size()); | 148 std::vector<NativePanelTesting*> native_panels_testing(panels.size()); |
149 for (size_t i = 0; i < panels.size(); ++i) { | 149 for (size_t i = 0; i < panels.size(); ++i) { |
150 native_panels_testing[i] = | 150 native_panels_testing[i] = |
151 NativePanelTesting::Create(panels[i]->native_panel()); | 151 NativePanelTesting::Create(panels[i]->native_panel()); |
152 } | 152 } |
153 | 153 |
154 // Test minimize. | 154 // Verify titlebar click does not minimize. |
155 for (size_t index = 0; index < panels.size(); ++index) { | 155 for (size_t index = 0; index < panels.size(); ++index) { |
156 // Press left mouse button. Verify nothing changed. | 156 // Press left mouse button. Verify nothing changed. |
157 native_panels_testing[index]->PressLeftMouseButtonTitlebar( | 157 native_panels_testing[index]->PressLeftMouseButtonTitlebar( |
158 panels[index]->GetBounds().origin()); | 158 panels[index]->GetBounds().origin()); |
159 EXPECT_EQ(expected_bounds, GetAllPanelBounds()); | 159 EXPECT_EQ(expected_bounds, GetAllPanelBounds()); |
160 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates()); | 160 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates()); |
161 | 161 |
162 // Release mouse button. Verify minimized. | 162 // Release mouse button. Verify nothing changed. |
163 native_panels_testing[index]->ReleaseMouseButtonTitlebar(); | 163 native_panels_testing[index]->ReleaseMouseButtonTitlebar(); |
164 EXPECT_EQ(expected_bounds, GetAllPanelBounds()); | |
165 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates()); | |
166 } | |
167 | |
168 // Minimize all panels for next stage in test. | |
169 for (size_t index = 0; index < panels.size(); ++index) { | |
170 panels[index]->Minimize(); | |
164 expected_bounds[index].set_height(Panel::kMinimizedPanelHeight); | 171 expected_bounds[index].set_height(Panel::kMinimizedPanelHeight); |
165 expected_bounds[index].set_y( | 172 expected_bounds[index].set_y( |
166 test_begin_bounds[index].y() + | 173 test_begin_bounds[index].y() + |
167 test_begin_bounds[index].height() - Panel::kMinimizedPanelHeight); | 174 test_begin_bounds[index].height() - Panel::kMinimizedPanelHeight); |
168 expected_expansion_states[index] = Panel::MINIMIZED; | 175 expected_expansion_states[index] = Panel::MINIMIZED; |
169 EXPECT_EQ(expected_bounds, GetAllPanelBounds()); | 176 EXPECT_EQ(expected_bounds, GetAllPanelBounds()); |
170 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates()); | 177 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates()); |
171 } | 178 } |
172 | 179 |
173 // Setup bounds and expansion states for minimized and titlebar-only | 180 // Setup bounds and expansion states for minimized and titlebar-only |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 | 524 |
518 // Test with three panels. | 525 // Test with three panels. |
519 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 526 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
520 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); | 527 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
521 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); | 528 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); |
522 TestMinimizeRestore(); | 529 TestMinimizeRestore(); |
523 | 530 |
524 PanelManager::GetInstance()->CloseAll(); | 531 PanelManager::GetInstance()->CloseAll(); |
525 } | 532 } |
526 | 533 |
527 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ToggleMinimizeAll) { | 534 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoreAllWithTitlebarClick) { |
528 // We'll simulate mouse movements for test. | 535 // We'll simulate mouse movements for test. |
529 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 536 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
530 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 537 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
531 | 538 |
532 // Test with three panels. | 539 // Test with three panels. |
533 Panel* panel1 = CreatePanel("PanelTest1"); | 540 Panel* panel1 = CreatePanel("PanelTest1"); |
534 Panel* panel2 = CreatePanel("PanelTest2"); | 541 Panel* panel2 = CreatePanel("PanelTest2"); |
535 Panel* panel3 = CreatePanel("PanelTest3"); | 542 Panel* panel3 = CreatePanel("PanelTest3"); |
536 EXPECT_FALSE(panel1->IsMinimized()); | 543 EXPECT_FALSE(panel1->IsMinimized()); |
537 EXPECT_FALSE(panel2->IsMinimized()); | 544 EXPECT_FALSE(panel2->IsMinimized()); |
538 EXPECT_FALSE(panel3->IsMinimized()); | 545 EXPECT_FALSE(panel3->IsMinimized()); |
539 | 546 |
540 scoped_ptr<NativePanelTesting> test_panel1( | 547 scoped_ptr<NativePanelTesting> test_panel1( |
541 NativePanelTesting::Create(panel1->native_panel())); | 548 NativePanelTesting::Create(panel1->native_panel())); |
542 scoped_ptr<NativePanelTesting> test_panel2( | 549 scoped_ptr<NativePanelTesting> test_panel2( |
543 NativePanelTesting::Create(panel2->native_panel())); | 550 NativePanelTesting::Create(panel2->native_panel())); |
544 scoped_ptr<NativePanelTesting> test_panel3( | 551 scoped_ptr<NativePanelTesting> test_panel3( |
545 NativePanelTesting::Create(panel3->native_panel())); | 552 NativePanelTesting::Create(panel3->native_panel())); |
546 | 553 |
547 // Press and release mouse button on one panel's titlebar using a modifier | 554 // Press and release mouse button on one panel's titlebar using a modifier |
548 // to minimize all panels. Nothing changes until mouse is released. | 555 // to minimize all panels. Nothing changes. |
jianli
2012/04/25 18:19:31
Please update the comment for "minimize all panels
jennb
2012/04/25 20:34:05
Edited.
| |
549 test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), | 556 test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), |
550 panel::APPLY_TO_ALL); | 557 panel::APPLY_TO_ALL); |
558 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | |
551 EXPECT_FALSE(panel1->IsMinimized()); | 559 EXPECT_FALSE(panel1->IsMinimized()); |
552 EXPECT_FALSE(panel2->IsMinimized()); | 560 EXPECT_FALSE(panel2->IsMinimized()); |
553 EXPECT_FALSE(panel3->IsMinimized()); | 561 EXPECT_FALSE(panel3->IsMinimized()); |
554 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 562 |
563 // Minimize all panels. Then click on a panel with apply-all modifier. | |
jianli
2012/04/25 18:19:31
Better comment like: Clicking titlebar on minimize
jennb
2012/04/25 20:34:05
Edited.
| |
564 // Verify all panels restored. | |
565 panel1->Minimize(); | |
566 panel2->Minimize(); | |
567 panel3->Minimize(); | |
555 EXPECT_TRUE(panel1->IsMinimized()); | 568 EXPECT_TRUE(panel1->IsMinimized()); |
556 EXPECT_TRUE(panel2->IsMinimized()); | 569 EXPECT_TRUE(panel2->IsMinimized()); |
557 EXPECT_TRUE(panel3->IsMinimized()); | 570 EXPECT_TRUE(panel3->IsMinimized()); |
558 | 571 |
559 // Press and release on a panel titlebar to restore all panels. | |
560 // Nothing changes until mouse is released. | 572 // Nothing changes until mouse is released. |
561 test_panel1->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin(), | 573 test_panel1->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin(), |
562 panel::APPLY_TO_ALL); | 574 panel::APPLY_TO_ALL); |
563 EXPECT_TRUE(panel1->IsMinimized()); | 575 EXPECT_TRUE(panel1->IsMinimized()); |
564 EXPECT_TRUE(panel2->IsMinimized()); | 576 EXPECT_TRUE(panel2->IsMinimized()); |
565 EXPECT_TRUE(panel3->IsMinimized()); | 577 EXPECT_TRUE(panel3->IsMinimized()); |
566 test_panel1->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 578 test_panel1->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
567 EXPECT_FALSE(panel1->IsMinimized()); | 579 EXPECT_FALSE(panel1->IsMinimized()); |
568 EXPECT_FALSE(panel2->IsMinimized()); | 580 EXPECT_FALSE(panel2->IsMinimized()); |
569 EXPECT_FALSE(panel3->IsMinimized()); | 581 EXPECT_FALSE(panel3->IsMinimized()); |
570 | 582 |
571 // Minimize a single panel. Then minimize all panels to verify that apply-all | 583 // Minimize a single panel. Then click on non-minimized panel with apply-all |
572 // logic works even if not all panels have the same expansion state. | 584 // modifier. Verify nothing changes. |
573 panel1->Minimize(); | 585 panel1->Minimize(); |
574 EXPECT_TRUE(panel1->IsMinimized()); | 586 EXPECT_TRUE(panel1->IsMinimized()); |
575 EXPECT_FALSE(panel2->IsMinimized()); | 587 EXPECT_FALSE(panel2->IsMinimized()); |
576 EXPECT_FALSE(panel3->IsMinimized()); | 588 EXPECT_FALSE(panel3->IsMinimized()); |
589 | |
577 test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), | 590 test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), |
578 panel::APPLY_TO_ALL); | 591 panel::APPLY_TO_ALL); |
579 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 592 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
580 EXPECT_TRUE(panel1->IsMinimized()); | 593 EXPECT_TRUE(panel1->IsMinimized()); |
581 EXPECT_TRUE(panel2->IsMinimized()); | 594 EXPECT_FALSE(panel2->IsMinimized()); |
582 EXPECT_TRUE(panel3->IsMinimized()); | 595 EXPECT_FALSE(panel3->IsMinimized()); |
583 | 596 |
584 // Expand a single panel. Then restore all panels. | 597 // Minimize another panel. Then restore all panels. |
585 panel3->Restore(); | 598 panel2->Minimize(); |
586 EXPECT_TRUE(panel1->IsMinimized()); | 599 EXPECT_TRUE(panel1->IsMinimized()); |
587 EXPECT_TRUE(panel2->IsMinimized()); | 600 EXPECT_TRUE(panel2->IsMinimized()); |
588 EXPECT_FALSE(panel3->IsMinimized()); | 601 EXPECT_FALSE(panel3->IsMinimized()); |
602 | |
589 test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), | 603 test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), |
590 panel::APPLY_TO_ALL); | 604 panel::APPLY_TO_ALL); |
591 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 605 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
592 EXPECT_FALSE(panel1->IsMinimized()); | 606 EXPECT_FALSE(panel1->IsMinimized()); |
593 EXPECT_FALSE(panel2->IsMinimized()); | 607 EXPECT_FALSE(panel2->IsMinimized()); |
594 EXPECT_FALSE(panel3->IsMinimized()); | 608 EXPECT_FALSE(panel3->IsMinimized()); |
595 | 609 |
596 // Click on the single minimized panel. Verify all are restored. | 610 // Click on the single minimized panel. Verify all are restored. |
597 panel1->Minimize(); | 611 panel1->Minimize(); |
598 EXPECT_TRUE(panel1->IsMinimized()); | 612 EXPECT_TRUE(panel1->IsMinimized()); |
599 EXPECT_FALSE(panel2->IsMinimized()); | 613 EXPECT_FALSE(panel2->IsMinimized()); |
600 EXPECT_FALSE(panel3->IsMinimized()); | 614 EXPECT_FALSE(panel3->IsMinimized()); |
615 | |
601 test_panel1->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin(), | 616 test_panel1->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin(), |
602 panel::APPLY_TO_ALL); | 617 panel::APPLY_TO_ALL); |
603 test_panel1->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 618 test_panel1->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
604 EXPECT_FALSE(panel1->IsMinimized()); | 619 EXPECT_FALSE(panel1->IsMinimized()); |
605 EXPECT_FALSE(panel2->IsMinimized()); | 620 EXPECT_FALSE(panel2->IsMinimized()); |
606 EXPECT_FALSE(panel3->IsMinimized()); | 621 EXPECT_FALSE(panel3->IsMinimized()); |
607 | 622 |
608 // Click on the single expanded panel. Verify all are minimized. | 623 // Click on the single expanded panel. Verify nothing changes. |
609 panel1->Minimize(); | 624 panel1->Minimize(); |
610 panel3->Minimize(); | 625 panel3->Minimize(); |
611 EXPECT_TRUE(panel1->IsMinimized()); | 626 EXPECT_TRUE(panel1->IsMinimized()); |
612 EXPECT_FALSE(panel2->IsMinimized()); | 627 EXPECT_FALSE(panel2->IsMinimized()); |
613 EXPECT_TRUE(panel3->IsMinimized()); | 628 EXPECT_TRUE(panel3->IsMinimized()); |
629 | |
614 test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), | 630 test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), |
615 panel::APPLY_TO_ALL); | 631 panel::APPLY_TO_ALL); |
616 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 632 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
617 EXPECT_TRUE(panel1->IsMinimized()); | 633 EXPECT_TRUE(panel1->IsMinimized()); |
618 EXPECT_TRUE(panel2->IsMinimized()); | 634 EXPECT_FALSE(panel2->IsMinimized()); |
619 EXPECT_TRUE(panel3->IsMinimized()); | 635 EXPECT_TRUE(panel3->IsMinimized()); |
620 | 636 |
621 // Hover over a minimized panel and click on the titlebar while it is in | 637 // Hover over a minimized panel and click on the titlebar while it is in |
622 // title-only mode. Should restore all panels. | 638 // title-only mode. Should restore all panels. |
639 panel2->Minimize(); | |
640 EXPECT_TRUE(panel1->IsMinimized()); | |
641 EXPECT_TRUE(panel2->IsMinimized()); | |
642 EXPECT_TRUE(panel3->IsMinimized()); | |
643 | |
623 MoveMouseAndWaitForExpansionStateChange(panel2, panel2->GetBounds().origin()); | 644 MoveMouseAndWaitForExpansionStateChange(panel2, panel2->GetBounds().origin()); |
624 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); | 645 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
625 EXPECT_EQ(Panel::TITLE_ONLY, panel2->expansion_state()); | 646 EXPECT_EQ(Panel::TITLE_ONLY, panel2->expansion_state()); |
626 EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state()); | 647 EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state()); |
648 | |
627 test_panel3->PressLeftMouseButtonTitlebar(panel3->GetBounds().origin(), | 649 test_panel3->PressLeftMouseButtonTitlebar(panel3->GetBounds().origin(), |
628 panel::APPLY_TO_ALL); | 650 panel::APPLY_TO_ALL); |
629 test_panel3->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 651 test_panel3->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
630 EXPECT_FALSE(panel1->IsMinimized()); | 652 EXPECT_FALSE(panel1->IsMinimized()); |
631 EXPECT_FALSE(panel2->IsMinimized()); | 653 EXPECT_FALSE(panel2->IsMinimized()); |
632 EXPECT_FALSE(panel3->IsMinimized()); | 654 EXPECT_FALSE(panel3->IsMinimized()); |
633 | 655 |
634 // Draw attention to a panel. Verify minimize all applies without | 656 // Draw attention to a minimized panel. Verify restore all applies without |
635 // affecting draw attention state. | 657 // affecting draw attention. |
636 panel1->FlashFrame(true); | 658 panel1->Minimize(); |
637 EXPECT_TRUE(panel1->IsDrawingAttention()); | 659 panel2->Minimize(); |
638 test_panel3->PressLeftMouseButtonTitlebar(panel3->GetBounds().origin(), | 660 panel3->Minimize(); |
639 panel::APPLY_TO_ALL); | |
640 test_panel3->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | |
641 EXPECT_TRUE(panel1->IsMinimized()); | 661 EXPECT_TRUE(panel1->IsMinimized()); |
642 EXPECT_TRUE(panel2->IsMinimized()); | 662 EXPECT_TRUE(panel2->IsMinimized()); |
643 EXPECT_TRUE(panel3->IsMinimized()); | 663 EXPECT_TRUE(panel3->IsMinimized()); |
664 | |
665 panel1->FlashFrame(true); | |
644 EXPECT_TRUE(panel1->IsDrawingAttention()); | 666 EXPECT_TRUE(panel1->IsDrawingAttention()); |
645 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); | 667 |
668 test_panel2->PressLeftMouseButtonTitlebar(panel3->GetBounds().origin(), | |
669 panel::APPLY_TO_ALL); | |
670 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | |
671 EXPECT_FALSE(panel1->IsMinimized()); | |
672 EXPECT_FALSE(panel2->IsMinimized()); | |
673 EXPECT_FALSE(panel3->IsMinimized()); | |
674 EXPECT_TRUE(panel1->IsDrawingAttention()); | |
646 | 675 |
647 // Restore all panels by clicking on the minimized panel that is drawing | 676 // Restore all panels by clicking on the minimized panel that is drawing |
648 // attention. Verify restore all applies without affecting draw attention | 677 // attention. Verify restore all applies and clears draw attention. |
649 // state. | 678 panel1->Minimize(); |
679 panel2->Minimize(); | |
680 panel3->Minimize(); | |
681 EXPECT_TRUE(panel1->IsMinimized()); | |
682 EXPECT_TRUE(panel2->IsMinimized()); | |
683 EXPECT_TRUE(panel3->IsMinimized()); | |
684 | |
650 test_panel1->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin(), | 685 test_panel1->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin(), |
651 panel::APPLY_TO_ALL); | 686 panel::APPLY_TO_ALL); |
652 test_panel1->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 687 test_panel1->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
653 EXPECT_FALSE(panel1->IsMinimized()); | 688 EXPECT_FALSE(panel1->IsMinimized()); |
654 EXPECT_FALSE(panel2->IsMinimized()); | 689 EXPECT_FALSE(panel2->IsMinimized()); |
655 EXPECT_FALSE(panel3->IsMinimized()); | 690 EXPECT_FALSE(panel3->IsMinimized()); |
656 EXPECT_TRUE(panel1->IsDrawingAttention()); | 691 EXPECT_FALSE(panel1->IsDrawingAttention()); |
657 | 692 |
658 PanelManager::GetInstance()->CloseAll(); | 693 PanelManager::GetInstance()->CloseAll(); |
659 } | 694 } |
660 | 695 |
661 #if defined(OS_MACOSX) | 696 #if defined(OS_MACOSX) |
662 // This test doesn't pass on Snow Leopard (10.6), although it works just | 697 // This test doesn't pass on Snow Leopard (10.6), although it works just |
663 // fine on Lion (10.7). The problem is not having a real run loop around | 698 // fine on Lion (10.7). The problem is not having a real run loop around |
664 // the window close is at fault, given how window controllers in Chrome | 699 // the window close is at fault, given how window controllers in Chrome |
665 // autorelease themselves on a -performSelector:withObject:afterDelay: | 700 // autorelease themselves on a -performSelector:withObject:afterDelay: |
666 #define MAYBE_ActivatePanelOrTabbedWindow DISABLED_ActivatePanelOrTabbedWindow | 701 #define MAYBE_ActivatePanelOrTabbedWindow DISABLED_ActivatePanelOrTabbedWindow |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
945 | 980 |
946 panel->Close(); | 981 panel->Close(); |
947 } | 982 } |
948 | 983 |
949 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) { | 984 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) { |
950 CreatePanelParams params("Initially active", gfx::Rect(), SHOW_AS_ACTIVE); | 985 CreatePanelParams params("Initially active", gfx::Rect(), SHOW_AS_ACTIVE); |
951 Panel* panel = CreatePanelWithParams(params); | 986 Panel* panel = CreatePanelWithParams(params); |
952 scoped_ptr<NativePanelTesting> native_panel_testing( | 987 scoped_ptr<NativePanelTesting> native_panel_testing( |
953 NativePanelTesting::Create(panel->native_panel())); | 988 NativePanelTesting::Create(panel->native_panel())); |
954 | 989 |
955 // Activate the panel. | 990 // Deactivate the panel. |
956 panel->Deactivate(); | 991 panel->Deactivate(); |
957 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 992 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
958 | 993 |
959 panel->FlashFrame(true); | 994 panel->FlashFrame(true); |
960 EXPECT_TRUE(panel->IsDrawingAttention()); | 995 EXPECT_TRUE(panel->IsDrawingAttention()); |
961 MessageLoop::current()->RunAllPending(); | 996 MessageLoop::current()->RunAllPending(); |
962 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 997 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
963 | 998 |
964 // Test that the attention is cleared when panel gets focus. | 999 // Test that the attention is cleared when panel gets focus. |
965 panel->Activate(); | 1000 panel->Activate(); |
966 MessageLoop::current()->RunAllPending(); | 1001 MessageLoop::current()->RunAllPending(); |
967 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 1002 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
968 EXPECT_FALSE(panel->IsDrawingAttention()); | 1003 EXPECT_FALSE(panel->IsDrawingAttention()); |
969 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1004 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
970 | 1005 |
971 panel->Close(); | 1006 panel->Close(); |
972 } | 1007 } |
973 | 1008 |
974 // TODO(dimich): try/enable on other platforms. | 1009 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, |
975 #if defined(OS_MACOSX) | 1010 DrawAttentionMinimizedNotResetOnActivate) { |
976 #define MAYBE_DrawAttentionResetOnClick DrawAttentionResetOnClick | 1011 // Create 2 panels so we end up with an inactive panel that can |
977 #else | 1012 // be made to draw attention. |
978 #define MAYBE_DrawAttentionResetOnClick DISABLED_DrawAttentionResetOnClick | 1013 Panel* panel1 = CreatePanel("test panel1"); |
979 #endif | 1014 Panel* panel2 = CreatePanel("test panel2"); |
980 | 1015 |
981 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_DrawAttentionResetOnClick) { | 1016 panel1->Minimize(); |
1017 EXPECT_TRUE(panel1->IsMinimized()); | |
1018 panel1->FlashFrame(true); | |
1019 EXPECT_TRUE(panel1->IsDrawingAttention()); | |
1020 | |
1021 // Simulate panel being activated while minimized. Cannot call | |
1022 // Activate() as that expands the panel. | |
1023 panel1->OnActiveStateChanged(true); | |
1024 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. | |
1025 | |
1026 // Unminimize panel to show that attention would have been cleared | |
1027 // if panel had not been minimized. | |
1028 panel1->Restore(); | |
1029 EXPECT_FALSE(panel1->IsMinimized()); | |
1030 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. | |
1031 | |
1032 panel1->OnActiveStateChanged(true); | |
1033 EXPECT_FALSE(panel1->IsDrawingAttention()); // Attention cleared. | |
1034 | |
1035 panel1->Close(); | |
1036 panel2->Close(); | |
1037 } | |
1038 | |
1039 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnClick) { | |
982 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); | 1040 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); |
983 Panel* panel = CreatePanelWithParams(params); | 1041 Panel* panel = CreatePanelWithParams(params); |
984 scoped_ptr<NativePanelTesting> native_panel_testing( | 1042 scoped_ptr<NativePanelTesting> native_panel_testing( |
985 NativePanelTesting::Create(panel->native_panel())); | 1043 NativePanelTesting::Create(panel->native_panel())); |
986 | 1044 |
987 panel->FlashFrame(true); | 1045 panel->FlashFrame(true); |
988 EXPECT_TRUE(panel->IsDrawingAttention()); | 1046 EXPECT_TRUE(panel->IsDrawingAttention()); |
989 MessageLoop::current()->RunAllPending(); | 1047 MessageLoop::current()->RunAllPending(); |
990 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 1048 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
991 | 1049 |
992 // Test that the attention is cleared when panel gets focus. | 1050 // Test that the attention is cleared when panel gets focus. |
993 native_panel_testing->PressLeftMouseButtonTitlebar( | 1051 native_panel_testing->PressLeftMouseButtonTitlebar( |
994 panel->GetBounds().origin()); | 1052 panel->GetBounds().origin()); |
995 native_panel_testing->ReleaseMouseButtonTitlebar(); | 1053 native_panel_testing->ReleaseMouseButtonTitlebar(); |
996 | 1054 |
997 MessageLoop::current()->RunAllPending(); | 1055 MessageLoop::current()->RunAllPending(); |
998 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 1056 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
999 EXPECT_FALSE(panel->IsDrawingAttention()); | 1057 EXPECT_FALSE(panel->IsDrawingAttention()); |
1000 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1058 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
1001 | 1059 |
1002 panel->Close(); | 1060 panel->Close(); |
1003 } | 1061 } |
1004 | 1062 |
1005 // There was a bug when it was not possible to minimize the panel by clicking | |
1006 // on the titlebar right after it was restored and activated. This test verifies | |
1007 // it's possible. | |
1008 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1063 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, |
1009 MinimizeImmediatelyAfterRestore) { | 1064 MinimizeImmediatelyAfterRestore) { |
1010 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_ACTIVE); | 1065 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_ACTIVE); |
1011 Panel* panel = CreatePanelWithParams(params); | 1066 Panel* panel = CreatePanelWithParams(params); |
1012 scoped_ptr<NativePanelTesting> native_panel_testing( | 1067 scoped_ptr<NativePanelTesting> native_panel_testing( |
1013 NativePanelTesting::Create(panel->native_panel())); | 1068 NativePanelTesting::Create(panel->native_panel())); |
1014 | 1069 |
1015 panel->SetExpansionState(Panel::MINIMIZED); // this should deactivate. | 1070 panel->Minimize(); // this should deactivate. |
1016 MessageLoop::current()->RunAllPending(); | 1071 MessageLoop::current()->RunAllPending(); |
1017 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 1072 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
1018 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 1073 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
1019 | 1074 |
1020 panel->Activate(); | 1075 panel->Activate(); |
1021 MessageLoop::current()->RunAllPending(); | 1076 MessageLoop::current()->RunAllPending(); |
1022 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 1077 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
1023 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 1078 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
1024 | 1079 |
1025 // Test that click on the titlebar right after expansion minimizes the Panel. | 1080 // Verify that minimizing a panel right after expansion works. |
1026 native_panel_testing->PressLeftMouseButtonTitlebar( | 1081 panel->Minimize(); |
1027 panel->GetBounds().origin()); | |
1028 native_panel_testing->ReleaseMouseButtonTitlebar(); | |
1029 MessageLoop::current()->RunAllPending(); | 1082 MessageLoop::current()->RunAllPending(); |
1030 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 1083 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
1031 panel->Close(); | 1084 panel->Close(); |
1032 } | 1085 } |
1033 | 1086 |
1034 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FocusLostOnMinimize) { | 1087 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FocusLostOnMinimize) { |
1035 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); | 1088 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); |
1036 Panel* panel = CreatePanelWithParams(params); | 1089 Panel* panel = CreatePanelWithParams(params); |
1037 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 1090 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
1038 | 1091 |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1669 // position when tall panel brings up its titlebar. | 1722 // position when tall panel brings up its titlebar. |
1670 CloseWindowAndWait(panel1->browser()); | 1723 CloseWindowAndWait(panel1->browser()); |
1671 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, | 1724 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, |
1672 GetBalloonBottomPosition(balloon)); | 1725 GetBalloonBottomPosition(balloon)); |
1673 | 1726 |
1674 // Closing the remaining tall panel should move the notification balloon back | 1727 // Closing the remaining tall panel should move the notification balloon back |
1675 // to its original position. | 1728 // to its original position. |
1676 CloseWindowAndWait(panel2->browser()); | 1729 CloseWindowAndWait(panel2->browser()); |
1677 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); | 1730 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); |
1678 } | 1731 } |
OLD | NEW |