| 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/download/download_service.h" | 7 #include "chrome/browser/download/download_service.h" |
| 8 #include "chrome/browser/download/download_service_factory.h" | 8 #include "chrome/browser/download/download_service_factory.h" |
| 9 #include "chrome/browser/net/url_request_mock_util.h" | 9 #include "chrome/browser/net/url_request_mock_util.h" |
| 10 #include "chrome/browser/prefs/browser_prefs.h" | 10 #include "chrome/browser/prefs/browser_prefs.h" |
| 11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 13 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 14 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 14 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| 15 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
| 16 #include "chrome/browser/ui/browser_finder.h" | 16 #include "chrome/browser/ui/browser_finder.h" |
| 17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
| 18 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
| 19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/browser/ui/find_bar/find_bar.h" | 20 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 21 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 21 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 22 #include "chrome/browser/ui/panels/base_panel_browser_test.h" | 22 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
| 23 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 23 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
| 24 #include "chrome/browser/ui/panels/native_panel.h" | 24 #include "chrome/browser/ui/panels/native_panel.h" |
| 25 #include "chrome/browser/ui/panels/panel.h" | 25 #include "chrome/browser/ui/panels/panel.h" |
| 26 #include "chrome/browser/ui/panels/panel_manager.h" | 26 #include "chrome/browser/ui/panels/panel_manager.h" |
| 27 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" | |
| 28 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 29 #include "chrome/browser/web_applications/web_app.h" | 28 #include "chrome/browser/web_applications/web_app.h" |
| 30 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 31 #include "chrome/common/extensions/extension_manifest_constants.h" | 30 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 32 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 33 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/test/base/ui_test_utils.h" | 33 #include "chrome/test/base/ui_test_utils.h" |
| 35 #include "content/public/browser/download_manager.h" | 34 #include "content/public/browser/download_manager.h" |
| 36 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 for (size_t i = 0; i < panels.size(); ++i) | 257 for (size_t i = 0; i < panels.size(); ++i) |
| 259 delete native_panels_testing[i]; | 258 delete native_panels_testing[i]; |
| 260 } | 259 } |
| 261 }; | 260 }; |
| 262 | 261 |
| 263 // Flaky (sometimes timeout): http://crbug.com/140971 | 262 // Flaky (sometimes timeout): http://crbug.com/140971 |
| 264 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_CheckDockedPanelProperties) { | 263 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_CheckDockedPanelProperties) { |
| 265 PanelManager* panel_manager = PanelManager::GetInstance(); | 264 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 266 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 265 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
| 267 | 266 |
| 268 // Don't let actual mouse movements affect this test as that may affect | |
| 269 // minimized vs title-only state. | |
| 270 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
| 271 panel_manager->SetMouseWatcherForTesting(mouse_watcher); | |
| 272 | |
| 273 // Create 3 docked panels that are in expanded, title-only or minimized states | 267 // Create 3 docked panels that are in expanded, title-only or minimized states |
| 274 // respectively. | 268 // respectively. |
| 275 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); | 269 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); |
| 276 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); | 270 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); |
| 277 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); | 271 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); |
| 278 panel2->SetExpansionState(Panel::TITLE_ONLY); | 272 panel2->SetExpansionState(Panel::TITLE_ONLY); |
| 279 WaitForExpansionStateChanged(panel2, Panel::TITLE_ONLY); | 273 WaitForExpansionStateChanged(panel2, Panel::TITLE_ONLY); |
| 280 panel3->SetExpansionState(Panel::MINIMIZED); | 274 panel3->SetExpansionState(Panel::MINIMIZED); |
| 281 WaitForExpansionStateChanged(panel3, Panel::MINIMIZED); | 275 WaitForExpansionStateChanged(panel3, Panel::MINIMIZED); |
| 282 scoped_ptr<NativePanelTesting> panel1_testing( | 276 scoped_ptr<NativePanelTesting> panel1_testing( |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 // Set bounds without animation. | 478 // Set bounds without animation. |
| 485 bounds = gfx::Rect(30, 40, 200, 220); | 479 bounds = gfx::Rect(30, 40, 200, 220); |
| 486 panel->SetPanelBoundsInstantly(bounds); | 480 panel->SetPanelBoundsInstantly(bounds); |
| 487 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); | 481 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); |
| 488 EXPECT_EQ(bounds, panel->GetBounds()); | 482 EXPECT_EQ(bounds, panel->GetBounds()); |
| 489 | 483 |
| 490 panel->Close(); | 484 panel->Close(); |
| 491 } | 485 } |
| 492 | 486 |
| 493 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { | 487 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { |
| 494 // Disable mouse watcher. We don't care about mouse movements in this test. | |
| 495 PanelManager* panel_manager = PanelManager::GetInstance(); | |
| 496 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
| 497 panel_manager->SetMouseWatcherForTesting(mouse_watcher); | |
| 498 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); | 488 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); |
| 499 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 489 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
| 500 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); | 490 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); |
| 501 | 491 |
| 502 panel->SetExpansionState(Panel::MINIMIZED); | 492 panel->SetExpansionState(Panel::MINIMIZED); |
| 503 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 493 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
| 504 gfx::Rect bounds = panel->GetBounds(); | 494 gfx::Rect bounds = panel->GetBounds(); |
| 505 gfx::Rect restored = panel->GetRestoredBounds(); | 495 gfx::Rect restored = panel->GetRestoredBounds(); |
| 506 EXPECT_EQ(bounds.x(), restored.x()); | 496 EXPECT_EQ(bounds.x(), restored.x()); |
| 507 EXPECT_GT(bounds.y(), restored.y()); | 497 EXPECT_GT(bounds.y(), restored.y()); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 bounds = gfx::Rect(40, 60, 300, 400); | 535 bounds = gfx::Rect(40, 60, 300, 400); |
| 546 panel->SetPanelBounds(bounds); | 536 panel->SetPanelBounds(bounds); |
| 547 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); | 537 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); |
| 548 panel->set_full_size(bounds.size()); | 538 panel->set_full_size(bounds.size()); |
| 549 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); | 539 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); |
| 550 | 540 |
| 551 panel->Close(); | 541 panel->Close(); |
| 552 } | 542 } |
| 553 | 543 |
| 554 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestore) { | 544 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestore) { |
| 555 // We'll simulate mouse movements for test. | |
| 556 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
| 557 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | |
| 558 | |
| 559 // Test with one panel. | 545 // Test with one panel. |
| 560 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 546 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 561 TestMinimizeRestore(); | 547 TestMinimizeRestore(); |
| 562 | 548 |
| 563 PanelManager::GetInstance()->CloseAll(); | 549 PanelManager::GetInstance()->CloseAll(); |
| 564 } | 550 } |
| 565 | 551 |
| 566 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreTwoPanels) { | 552 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreTwoPanels) { |
| 567 // We'll simulate mouse movements for test. | |
| 568 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
| 569 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | |
| 570 | |
| 571 // Test with two panels. | 553 // Test with two panels. |
| 572 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 554 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 573 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); | 555 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
| 574 TestMinimizeRestore(); | 556 TestMinimizeRestore(); |
| 575 | 557 |
| 576 PanelManager::GetInstance()->CloseAll(); | 558 PanelManager::GetInstance()->CloseAll(); |
| 577 } | 559 } |
| 578 | 560 |
| 579 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreThreePanels) { | 561 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreThreePanels) { |
| 580 // We'll simulate mouse movements for test. | |
| 581 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
| 582 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | |
| 583 | |
| 584 // Test with three panels. | 562 // Test with three panels. |
| 585 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 563 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
| 586 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); | 564 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
| 587 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); | 565 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); |
| 588 TestMinimizeRestore(); | 566 TestMinimizeRestore(); |
| 589 | 567 |
| 590 PanelManager::GetInstance()->CloseAll(); | 568 PanelManager::GetInstance()->CloseAll(); |
| 591 } | 569 } |
| 592 | 570 |
| 593 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreButtonClick) { | 571 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreButtonClick) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 EXPECT_TRUE(panel3->IsMinimized()); | 609 EXPECT_TRUE(panel3->IsMinimized()); |
| 632 | 610 |
| 633 // Restore all panels by clicking restore button on a minimized panel. | 611 // Restore all panels by clicking restore button on a minimized panel. |
| 634 panel3->OnRestoreButtonClicked(panel::APPLY_TO_ALL); | 612 panel3->OnRestoreButtonClicked(panel::APPLY_TO_ALL); |
| 635 EXPECT_FALSE(panel1->IsMinimized()); | 613 EXPECT_FALSE(panel1->IsMinimized()); |
| 636 EXPECT_FALSE(panel2->IsMinimized()); | 614 EXPECT_FALSE(panel2->IsMinimized()); |
| 637 EXPECT_FALSE(panel3->IsMinimized()); | 615 EXPECT_FALSE(panel3->IsMinimized()); |
| 638 } | 616 } |
| 639 | 617 |
| 640 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoreAllWithTitlebarClick) { | 618 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoreAllWithTitlebarClick) { |
| 641 // We'll simulate mouse movements for test. | |
| 642 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
| 643 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | |
| 644 | |
| 645 // Test with three panels. | 619 // Test with three panels. |
| 646 Panel* panel1 = CreatePanel("PanelTest1"); | 620 Panel* panel1 = CreatePanel("PanelTest1"); |
| 647 Panel* panel2 = CreatePanel("PanelTest2"); | 621 Panel* panel2 = CreatePanel("PanelTest2"); |
| 648 Panel* panel3 = CreatePanel("PanelTest3"); | 622 Panel* panel3 = CreatePanel("PanelTest3"); |
| 649 EXPECT_FALSE(panel1->IsMinimized()); | 623 EXPECT_FALSE(panel1->IsMinimized()); |
| 650 EXPECT_FALSE(panel2->IsMinimized()); | 624 EXPECT_FALSE(panel2->IsMinimized()); |
| 651 EXPECT_FALSE(panel3->IsMinimized()); | 625 EXPECT_FALSE(panel3->IsMinimized()); |
| 652 | 626 |
| 653 scoped_ptr<NativePanelTesting> test_panel1( | 627 scoped_ptr<NativePanelTesting> test_panel1( |
| 654 CreateNativePanelTesting(panel1)); | 628 CreateNativePanelTesting(panel1)); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 | 1023 |
| 1050 // Stop drawing attention. Titlebar should no longer be visible. | 1024 // Stop drawing attention. Titlebar should no longer be visible. |
| 1051 panel->FlashFrame(false); | 1025 panel->FlashFrame(false); |
| 1052 EXPECT_FALSE(panel->IsDrawingAttention()); | 1026 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 1053 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 1027 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
| 1054 | 1028 |
| 1055 panel->Close(); | 1029 panel->Close(); |
| 1056 } | 1030 } |
| 1057 | 1031 |
| 1058 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhileMinimized) { | 1032 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhileMinimized) { |
| 1059 // We'll simulate mouse movements for test. | |
| 1060 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
| 1061 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | |
| 1062 | |
| 1063 // Create 3 panels so we end up with an inactive panel that can | 1033 // Create 3 panels so we end up with an inactive panel that can |
| 1064 // be made to draw attention. | 1034 // be made to draw attention. |
| 1065 Panel* panel = CreatePanel("test panel1"); | 1035 Panel* panel = CreatePanel("test panel1"); |
| 1066 Panel* panel2 = CreatePanel("test panel2"); | 1036 Panel* panel2 = CreatePanel("test panel2"); |
| 1067 Panel* panel3 = CreatePanel("test panel3"); | 1037 Panel* panel3 = CreatePanel("test panel3"); |
| 1068 | 1038 |
| 1069 scoped_ptr<NativePanelTesting> native_panel_testing( | 1039 scoped_ptr<NativePanelTesting> native_panel_testing( |
| 1070 CreateNativePanelTesting(panel)); | 1040 CreateNativePanelTesting(panel)); |
| 1071 | 1041 |
| 1072 // Test that the attention is drawn and the title-bar is brought up when the | 1042 // Test that the attention is drawn and the title-bar is brought up when the |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1101 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1071 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
| 1102 | 1072 |
| 1103 panel->Close(); | 1073 panel->Close(); |
| 1104 panel2->Close(); | 1074 panel2->Close(); |
| 1105 panel3->Close(); | 1075 panel3->Close(); |
| 1106 } | 1076 } |
| 1107 | 1077 |
| 1108 // Verify that minimized state of a panel is correct after draw attention | 1078 // Verify that minimized state of a panel is correct after draw attention |
| 1109 // is stopped when there are other minimized panels. | 1079 // is stopped when there are other minimized panels. |
| 1110 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, StopDrawingAttentionWhileMinimized) { | 1080 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, StopDrawingAttentionWhileMinimized) { |
| 1111 // We'll simulate mouse movements for test. | |
| 1112 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
| 1113 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | |
| 1114 | |
| 1115 Panel* panel1 = CreatePanel("panel1"); | 1081 Panel* panel1 = CreatePanel("panel1"); |
| 1116 Panel* panel2 = CreatePanel("panel2"); | 1082 Panel* panel2 = CreatePanel("panel2"); |
| 1117 | 1083 |
| 1118 panel1->Minimize(); | 1084 panel1->Minimize(); |
| 1119 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 1085 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
| 1120 panel2->Minimize(); | 1086 panel2->Minimize(); |
| 1121 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state()); | 1087 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state()); |
| 1122 | 1088 |
| 1123 // Verify panel returns to minimized state when no longer drawing attention. | 1089 // Verify panel returns to minimized state when no longer drawing attention. |
| 1124 panel1->FlashFrame(true); | 1090 panel1->FlashFrame(true); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 EXPECT_GT(old_full_size.width(), panel->full_size().width()); | 1539 EXPECT_GT(old_full_size.width(), panel->full_size().width()); |
| 1574 EXPECT_GT(old_full_size.height(), panel->full_size().height()); | 1540 EXPECT_GT(old_full_size.height(), panel->full_size().height()); |
| 1575 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); | 1541 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); |
| 1576 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); | 1542 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); |
| 1577 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); | 1543 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); |
| 1578 | 1544 |
| 1579 panel->Close(); | 1545 panel->Close(); |
| 1580 } | 1546 } |
| 1581 | 1547 |
| 1582 #endif // OS_WIN || OS_MACOSX | 1548 #endif // OS_WIN || OS_MACOSX |
| OLD | NEW |