| 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "chrome/browser/ui/panels/base_panel_browser_test.h" | 6 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
| 7 #include "chrome/browser/ui/panels/detached_panel_collection.h" | 7 #include "chrome/browser/ui/panels/detached_panel_collection.h" |
| 8 #include "chrome/browser/ui/panels/native_panel.h" | 8 #include "chrome/browser/ui/panels/native_panel.h" |
| 9 #include "chrome/browser/ui/panels/panel.h" | 9 #include "chrome/browser/ui/panels/panel.h" |
| 10 #include "chrome/browser/ui/panels/panel_manager.h" | 10 #include "chrome/browser/ui/panels/panel_manager.h" |
| 11 | 11 |
| 12 class DetachedPanelBrowserTest : public BasePanelBrowserTest { | 12 class DetachedPanelBrowserTest : public BasePanelBrowserTest { |
| 13 }; | 13 }; |
| 14 | 14 |
| 15 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, CheckDetachedPanelProperties) { | 15 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, CheckDetachedPanelProperties) { |
| 16 PanelManager* panel_manager = PanelManager::GetInstance(); | 16 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 17 DetachedPanelCollection* detached_collection = | 17 DetachedPanelCollection* detached_collection = |
| 18 panel_manager->detached_collection(); | 18 panel_manager->detached_collection(); |
| 19 | 19 |
| 20 // Create an initially detached panel (as opposed to other tests which create | 20 // Create an initially detached panel (as opposed to other tests which create |
| 21 // a docked panel, then detaches it). | 21 // a docked panel, then detaches it). |
| 22 gfx::Rect bounds(300, 200, 250, 200); | 22 gfx::Rect bounds(300, 200, 250, 200); |
| 23 CreatePanelParams params("1", bounds, SHOW_AS_ACTIVE); | 23 CreatePanelParams params("1", bounds, SHOW_AS_ACTIVE); |
| 24 params.create_mode = PanelManager::CREATE_AS_DETACHED; | 24 params.create_mode = PanelManager::CREATE_AS_DETACHED; |
| 25 Panel* panel = CreatePanelWithParams(params); | 25 Panel* panel = CreatePanelWithParams(params); |
| 26 scoped_ptr<NativePanelTesting> panel_testing( | 26 std::unique_ptr<NativePanelTesting> panel_testing( |
| 27 CreateNativePanelTesting(panel)); | 27 CreateNativePanelTesting(panel)); |
| 28 | 28 |
| 29 EXPECT_EQ(1, panel_manager->num_panels()); | 29 EXPECT_EQ(1, panel_manager->num_panels()); |
| 30 EXPECT_TRUE(detached_collection->HasPanel(panel)); | 30 EXPECT_TRUE(detached_collection->HasPanel(panel)); |
| 31 | 31 |
| 32 EXPECT_EQ(bounds.x(), panel->GetBounds().x()); | 32 EXPECT_EQ(bounds.x(), panel->GetBounds().x()); |
| 33 // Ignore checking y position since the detached panel will be placed near | 33 // Ignore checking y position since the detached panel will be placed near |
| 34 // the top if the stacking mode is enabled. | 34 // the top if the stacking mode is enabled. |
| 35 if (!PanelManager::IsPanelStackingEnabled()) | 35 if (!PanelManager::IsPanelStackingEnabled()) |
| 36 EXPECT_EQ(bounds.y(), panel->GetBounds().y()); | 36 EXPECT_EQ(bounds.y(), panel->GetBounds().y()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 57 static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | | 57 static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | |
| 58 Panel::USE_SYSTEM_ATTENTION); | 58 Panel::USE_SYSTEM_ATTENTION); |
| 59 EXPECT_EQ(expected_attention_mode, panel->attention_mode()); | 59 EXPECT_EQ(expected_attention_mode, panel->attention_mode()); |
| 60 | 60 |
| 61 panel_manager->CloseAll(); | 61 panel_manager->CloseAll(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnActive) { | 64 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnActive) { |
| 65 // Create a detached panel that is initially active. | 65 // Create a detached panel that is initially active. |
| 66 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 66 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
| 67 scoped_ptr<NativePanelTesting> native_panel_testing( | 67 std::unique_ptr<NativePanelTesting> native_panel_testing( |
| 68 CreateNativePanelTesting(panel)); | 68 CreateNativePanelTesting(panel)); |
| 69 | 69 |
| 70 // Test that the attention should not be drawn if the detached panel is in | 70 // Test that the attention should not be drawn if the detached panel is in |
| 71 // focus. | 71 // focus. |
| 72 EXPECT_FALSE(panel->IsDrawingAttention()); | 72 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 73 panel->FlashFrame(true); | 73 panel->FlashFrame(true); |
| 74 EXPECT_FALSE(panel->IsDrawingAttention()); | 74 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 75 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 75 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
| 76 | 76 |
| 77 panel->Close(); | 77 panel->Close(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnInactive) { | 80 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnInactive) { |
| 81 // Create an inactive detached panel. | 81 // Create an inactive detached panel. |
| 82 Panel* panel = | 82 Panel* panel = |
| 83 CreateInactiveDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 83 CreateInactiveDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
| 84 scoped_ptr<NativePanelTesting> native_panel_testing( | 84 std::unique_ptr<NativePanelTesting> native_panel_testing( |
| 85 CreateNativePanelTesting(panel)); | 85 CreateNativePanelTesting(panel)); |
| 86 | 86 |
| 87 // Test that the attention is drawn when the detached panel is not in focus. | 87 // Test that the attention is drawn when the detached panel is not in focus. |
| 88 EXPECT_FALSE(panel->IsActive()); | 88 EXPECT_FALSE(panel->IsActive()); |
| 89 EXPECT_FALSE(panel->IsDrawingAttention()); | 89 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 90 panel->FlashFrame(true); | 90 panel->FlashFrame(true); |
| 91 EXPECT_TRUE(panel->IsDrawingAttention()); | 91 EXPECT_TRUE(panel->IsDrawingAttention()); |
| 92 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 92 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
| 93 | 93 |
| 94 // Stop drawing attention. | 94 // Stop drawing attention. |
| 95 panel->FlashFrame(false); | 95 panel->FlashFrame(false); |
| 96 EXPECT_FALSE(panel->IsDrawingAttention()); | 96 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 97 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 97 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
| 98 | 98 |
| 99 PanelManager::GetInstance()->CloseAll(); | 99 PanelManager::GetInstance()->CloseAll(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionResetOnActivate) { | 102 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionResetOnActivate) { |
| 103 // Create an inactive detached panel. | 103 // Create an inactive detached panel. |
| 104 Panel* panel = | 104 Panel* panel = |
| 105 CreateInactiveDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 105 CreateInactiveDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
| 106 scoped_ptr<NativePanelTesting> native_panel_testing( | 106 std::unique_ptr<NativePanelTesting> native_panel_testing( |
| 107 CreateNativePanelTesting(panel)); | 107 CreateNativePanelTesting(panel)); |
| 108 | 108 |
| 109 // Test that the attention is drawn when the detached panel is not in focus. | 109 // Test that the attention is drawn when the detached panel is not in focus. |
| 110 panel->FlashFrame(true); | 110 panel->FlashFrame(true); |
| 111 EXPECT_TRUE(panel->IsDrawingAttention()); | 111 EXPECT_TRUE(panel->IsDrawingAttention()); |
| 112 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 112 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
| 113 | 113 |
| 114 // Test that the attention is cleared when panel gets focus. | 114 // Test that the attention is cleared when panel gets focus. |
| 115 panel->Activate(); | 115 panel->Activate(); |
| 116 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 116 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
| 117 EXPECT_FALSE(panel->IsDrawingAttention()); | 117 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 118 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 118 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
| 119 | 119 |
| 120 PanelManager::GetInstance()->CloseAll(); | 120 PanelManager::GetInstance()->CloseAll(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, ClickTitlebar) { | 123 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, ClickTitlebar) { |
| 124 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 124 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
| 125 EXPECT_FALSE(panel->IsMinimized()); | 125 EXPECT_FALSE(panel->IsMinimized()); |
| 126 | 126 |
| 127 // Clicking on an active detached panel's titlebar has no effect, regardless | 127 // Clicking on an active detached panel's titlebar has no effect, regardless |
| 128 // of modifier. | 128 // of modifier. |
| 129 scoped_ptr<NativePanelTesting> test_panel( | 129 std::unique_ptr<NativePanelTesting> test_panel( |
| 130 CreateNativePanelTesting(panel)); | 130 CreateNativePanelTesting(panel)); |
| 131 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); | 131 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); |
| 132 test_panel->ReleaseMouseButtonTitlebar(); | 132 test_panel->ReleaseMouseButtonTitlebar(); |
| 133 EXPECT_TRUE(panel->IsActive()); | 133 EXPECT_TRUE(panel->IsActive()); |
| 134 EXPECT_FALSE(panel->IsMinimized()); | 134 EXPECT_FALSE(panel->IsMinimized()); |
| 135 | 135 |
| 136 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin(), | 136 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin(), |
| 137 panel::APPLY_TO_ALL); | 137 panel::APPLY_TO_ALL); |
| 138 test_panel->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 138 test_panel->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
| 139 EXPECT_TRUE(panel->IsActive()); | 139 EXPECT_TRUE(panel->IsActive()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 panel_manager->CloseAll(); | 210 panel_manager->CloseAll(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, | 213 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, |
| 214 KeepShowingDetachedPanelCreatedBeforeFullScreenMode) { | 214 KeepShowingDetachedPanelCreatedBeforeFullScreenMode) { |
| 215 // Create a detached panel. | 215 // Create a detached panel. |
| 216 CreatePanelParams params("1", gfx::Rect(300, 200, 250, 200), SHOW_AS_ACTIVE); | 216 CreatePanelParams params("1", gfx::Rect(300, 200, 250, 200), SHOW_AS_ACTIVE); |
| 217 params.create_mode = PanelManager::CREATE_AS_DETACHED; | 217 params.create_mode = PanelManager::CREATE_AS_DETACHED; |
| 218 Panel* panel = CreatePanelWithParams(params); | 218 Panel* panel = CreatePanelWithParams(params); |
| 219 scoped_ptr<NativePanelTesting> panel_testing(CreateNativePanelTesting(panel)); | 219 std::unique_ptr<NativePanelTesting> panel_testing( |
| 220 CreateNativePanelTesting(panel)); |
| 220 | 221 |
| 221 // Panel should be visible at first. | 222 // Panel should be visible at first. |
| 222 EXPECT_TRUE(panel_testing->IsWindowVisible()); | 223 EXPECT_TRUE(panel_testing->IsWindowVisible()); |
| 223 | 224 |
| 224 // Panel's visibility should not be affected when entering full-screen mode. | 225 // Panel's visibility should not be affected when entering full-screen mode. |
| 225 mock_display_settings_provider()->EnableFullScreenMode(true); | 226 mock_display_settings_provider()->EnableFullScreenMode(true); |
| 226 EXPECT_TRUE(panel_testing->IsWindowVisible()); | 227 EXPECT_TRUE(panel_testing->IsWindowVisible()); |
| 227 | 228 |
| 228 // Panel's visibility should not be affected when leaving full-screen mode. | 229 // Panel's visibility should not be affected when leaving full-screen mode. |
| 229 mock_display_settings_provider()->EnableFullScreenMode(false); | 230 mock_display_settings_provider()->EnableFullScreenMode(false); |
| 230 EXPECT_TRUE(panel_testing->IsWindowVisible()); | 231 EXPECT_TRUE(panel_testing->IsWindowVisible()); |
| 231 | 232 |
| 232 PanelManager::GetInstance()->CloseAll(); | 233 PanelManager::GetInstance()->CloseAll(); |
| 233 } | 234 } |
| 234 | 235 |
| 235 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, | 236 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, |
| 236 HideDetachedPanelCreatedOnFullScreenMode) { | 237 HideDetachedPanelCreatedOnFullScreenMode) { |
| 237 // Enable full-screen mode first. | 238 // Enable full-screen mode first. |
| 238 mock_display_settings_provider()->EnableFullScreenMode(true); | 239 mock_display_settings_provider()->EnableFullScreenMode(true); |
| 239 | 240 |
| 240 // Create a detached panel without waiting it to be shown since it is not | 241 // Create a detached panel without waiting it to be shown since it is not |
| 241 // supposed to be shown on full-screen mode. | 242 // supposed to be shown on full-screen mode. |
| 242 CreatePanelParams params("1", gfx::Rect(300, 200, 250, 200), SHOW_AS_ACTIVE); | 243 CreatePanelParams params("1", gfx::Rect(300, 200, 250, 200), SHOW_AS_ACTIVE); |
| 243 params.create_mode = PanelManager::CREATE_AS_DETACHED; | 244 params.create_mode = PanelManager::CREATE_AS_DETACHED; |
| 244 params.wait_for_fully_created = false; | 245 params.wait_for_fully_created = false; |
| 245 Panel* panel = CreatePanelWithParams(params); | 246 Panel* panel = CreatePanelWithParams(params); |
| 246 scoped_ptr<NativePanelTesting> panel_testing(CreateNativePanelTesting(panel)); | 247 std::unique_ptr<NativePanelTesting> panel_testing( |
| 248 CreateNativePanelTesting(panel)); |
| 247 | 249 |
| 248 // Panel should not be shown on full-screen mode. | 250 // Panel should not be shown on full-screen mode. |
| 249 EXPECT_FALSE(panel_testing->IsWindowVisible()); | 251 EXPECT_FALSE(panel_testing->IsWindowVisible()); |
| 250 | 252 |
| 251 // Panel should become visible when leaving full-screen mode. | 253 // Panel should become visible when leaving full-screen mode. |
| 252 mock_display_settings_provider()->EnableFullScreenMode(false); | 254 mock_display_settings_provider()->EnableFullScreenMode(false); |
| 253 EXPECT_TRUE(panel_testing->IsWindowVisible()); | 255 EXPECT_TRUE(panel_testing->IsWindowVisible()); |
| 254 | 256 |
| 255 PanelManager::GetInstance()->CloseAll(); | 257 PanelManager::GetInstance()->CloseAll(); |
| 256 } | 258 } |
| OLD | NEW |