| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/message_loop.h" | |
| 6 #include "chrome/browser/ui/panels/old_base_panel_browser_test.h" | |
| 7 #include "chrome/browser/ui/panels/detached_panel_strip.h" | |
| 8 #include "chrome/browser/ui/panels/native_panel.h" | |
| 9 #include "chrome/browser/ui/panels/panel.h" | |
| 10 #include "chrome/browser/ui/panels/panel_manager.h" | |
| 11 | |
| 12 class OldDetachedPanelBrowserTest : public OldBasePanelBrowserTest { | |
| 13 }; | |
| 14 | |
| 15 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, | |
| 16 CheckDetachedPanelProperties) { | |
| 17 PanelManager* panel_manager = PanelManager::GetInstance(); | |
| 18 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | |
| 19 | |
| 20 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | |
| 21 scoped_ptr<NativePanelTesting> panel_testing( | |
| 22 CreateNativePanelTesting(panel)); | |
| 23 | |
| 24 EXPECT_EQ(1, panel_manager->num_panels()); | |
| 25 EXPECT_TRUE(detached_strip->HasPanel(panel)); | |
| 26 | |
| 27 EXPECT_FALSE(panel->always_on_top()); | |
| 28 | |
| 29 EXPECT_TRUE(panel_testing->IsButtonVisible(panel::CLOSE_BUTTON)); | |
| 30 EXPECT_FALSE(panel_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); | |
| 31 EXPECT_FALSE(panel_testing->IsButtonVisible(panel::RESTORE_BUTTON)); | |
| 32 | |
| 33 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | |
| 34 | |
| 35 Panel::AttentionMode expected_attention_mode = | |
| 36 static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | | |
| 37 Panel::USE_SYSTEM_ATTENTION); | |
| 38 EXPECT_EQ(expected_attention_mode, panel->attention_mode()); | |
| 39 | |
| 40 panel_manager->CloseAll(); | |
| 41 } | |
| 42 | |
| 43 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, | |
| 44 FLAKY_DrawAttentionOnActive) { | |
| 45 // Create a detached panel that is initially active. | |
| 46 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | |
| 47 scoped_ptr<NativePanelTesting> native_panel_testing( | |
| 48 CreateNativePanelTesting(panel)); | |
| 49 | |
| 50 // Test that the attention should not be drawn if the detached panel is in | |
| 51 // focus. | |
| 52 EXPECT_TRUE(panel->IsActive()); | |
| 53 EXPECT_FALSE(panel->IsDrawingAttention()); | |
| 54 panel->FlashFrame(true); | |
| 55 EXPECT_FALSE(panel->IsDrawingAttention()); | |
| 56 MessageLoop::current()->RunAllPending(); | |
| 57 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | |
| 58 | |
| 59 panel->Close(); | |
| 60 } | |
| 61 | |
| 62 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, | |
| 63 FLAKY_DrawAttentionOnInactive) { | |
| 64 // Create an inactive detached panel. | |
| 65 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | |
| 66 panel->Deactivate(); | |
| 67 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | |
| 68 | |
| 69 scoped_ptr<NativePanelTesting> native_panel_testing( | |
| 70 CreateNativePanelTesting(panel)); | |
| 71 | |
| 72 // Test that the attention is drawn when the detached panel is not in focus. | |
| 73 EXPECT_FALSE(panel->IsActive()); | |
| 74 EXPECT_FALSE(panel->IsDrawingAttention()); | |
| 75 panel->FlashFrame(true); | |
| 76 EXPECT_TRUE(panel->IsDrawingAttention()); | |
| 77 MessageLoop::current()->RunAllPending(); | |
| 78 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | |
| 79 | |
| 80 // Stop drawing attention. | |
| 81 panel->FlashFrame(false); | |
| 82 EXPECT_FALSE(panel->IsDrawingAttention()); | |
| 83 MessageLoop::current()->RunAllPending(); | |
| 84 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | |
| 85 | |
| 86 panel->Close(); | |
| 87 } | |
| 88 | |
| 89 // http://crbug.com/133464 | |
| 90 #if defined(OS_LINUX) | |
| 91 #define MAYBE_DrawAttentionResetOnActivate DISABLED_DrawAttentionResetOnActivate | |
| 92 #else | |
| 93 #define MAYBE_DrawAttentionResetOnActivate DrawAttentionResetOnActivate | |
| 94 #endif | |
| 95 | |
| 96 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, | |
| 97 MAYBE_DrawAttentionResetOnActivate) { | |
| 98 // Create 2 panels so we end up with an inactive panel that can | |
| 99 // be made to draw attention. | |
| 100 Panel* panel1 = CreatePanel("test panel1"); | |
| 101 Panel* panel2 = CreatePanel("test panel2"); | |
| 102 | |
| 103 scoped_ptr<NativePanelTesting> native_panel_testing( | |
| 104 CreateNativePanelTesting(panel1)); | |
| 105 | |
| 106 // Test that the attention is drawn when the detached panel is not in focus. | |
| 107 panel1->FlashFrame(true); | |
| 108 EXPECT_TRUE(panel1->IsDrawingAttention()); | |
| 109 MessageLoop::current()->RunAllPending(); | |
| 110 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | |
| 111 | |
| 112 // Test that the attention is cleared when panel gets focus. | |
| 113 panel1->Activate(); | |
| 114 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); | |
| 115 EXPECT_FALSE(panel1->IsDrawingAttention()); | |
| 116 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | |
| 117 | |
| 118 panel1->Close(); | |
| 119 panel2->Close(); | |
| 120 } | |
| 121 | |
| 122 #if defined(OS_LINUX) | |
| 123 // http://crbug.com/145740 | |
| 124 #define MAYBE_ClickTitlebar FLAKY_ClickTitlebar | |
| 125 #else | |
| 126 #define MAYBE_ClickTitlebar ClickTitlebar | |
| 127 #endif | |
| 128 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, MAYBE_ClickTitlebar) { | |
| 129 PanelManager* panel_manager = PanelManager::GetInstance(); | |
| 130 | |
| 131 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | |
| 132 EXPECT_TRUE(panel->IsActive()); | |
| 133 EXPECT_FALSE(panel->IsMinimized()); | |
| 134 | |
| 135 // Clicking on an active detached panel's titlebar has no effect, regardless | |
| 136 // of modifier. | |
| 137 scoped_ptr<NativePanelTesting> test_panel( | |
| 138 CreateNativePanelTesting(panel)); | |
| 139 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); | |
| 140 test_panel->ReleaseMouseButtonTitlebar(); | |
| 141 EXPECT_TRUE(panel->IsActive()); | |
| 142 EXPECT_FALSE(panel->IsMinimized()); | |
| 143 | |
| 144 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin(), | |
| 145 panel::APPLY_TO_ALL); | |
| 146 test_panel->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | |
| 147 EXPECT_TRUE(panel->IsActive()); | |
| 148 EXPECT_FALSE(panel->IsMinimized()); | |
| 149 | |
| 150 // Create a second panel to cause the first to become inactive. | |
| 151 CreateDetachedPanel("2", gfx::Rect(100, 200, 230, 345)); | |
| 152 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | |
| 153 | |
| 154 // Clicking on an inactive detached panel's titlebar activates it. | |
| 155 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); | |
| 156 test_panel->ReleaseMouseButtonTitlebar(); | |
| 157 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | |
| 158 EXPECT_FALSE(panel->IsMinimized()); | |
| 159 | |
| 160 panel_manager->CloseAll(); | |
| 161 } | |
| OLD | NEW |