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.h" | 5 #include "base/message_loop.h" |
6 #include "chrome/browser/ui/panels/base_panel_browser_test.h" | 6 #include "chrome/browser/ui/panels/old_base_panel_browser_test.h" |
7 #include "chrome/browser/ui/panels/detached_panel_strip.h" | 7 #include "chrome/browser/ui/panels/detached_panel_strip.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 OldDetachedPanelBrowserTest : public OldBasePanelBrowserTest { |
13 }; | 13 }; |
14 | 14 |
15 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, CheckDetachedPanelProperties) { | 15 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, |
| 16 CheckDetachedPanelProperties) { |
16 PanelManager* panel_manager = PanelManager::GetInstance(); | 17 PanelManager* panel_manager = PanelManager::GetInstance(); |
17 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); | 18 DetachedPanelStrip* detached_strip = panel_manager->detached_strip(); |
18 | 19 |
19 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 20 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
20 scoped_ptr<NativePanelTesting> panel_testing( | 21 scoped_ptr<NativePanelTesting> panel_testing( |
21 NativePanelTesting::Create(panel->native_panel())); | 22 NativePanelTesting::Create(panel->native_panel())); |
22 | 23 |
23 EXPECT_EQ(1, panel_manager->num_panels()); | 24 EXPECT_EQ(1, panel_manager->num_panels()); |
24 EXPECT_TRUE(detached_strip->HasPanel(panel)); | 25 EXPECT_TRUE(detached_strip->HasPanel(panel)); |
25 | 26 |
26 EXPECT_FALSE(panel->always_on_top()); | 27 EXPECT_FALSE(panel->always_on_top()); |
27 | 28 |
28 EXPECT_TRUE(panel_testing->IsButtonVisible(panel::CLOSE_BUTTON)); | 29 EXPECT_TRUE(panel_testing->IsButtonVisible(panel::CLOSE_BUTTON)); |
29 EXPECT_FALSE(panel_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); | 30 EXPECT_FALSE(panel_testing->IsButtonVisible(panel::MINIMIZE_BUTTON)); |
30 EXPECT_FALSE(panel_testing->IsButtonVisible(panel::RESTORE_BUTTON)); | 31 EXPECT_FALSE(panel_testing->IsButtonVisible(panel::RESTORE_BUTTON)); |
31 | 32 |
32 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); | 33 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse()); |
33 | 34 |
34 Panel::AttentionMode expected_attention_mode = | 35 Panel::AttentionMode expected_attention_mode = |
35 static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | | 36 static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | |
36 Panel::USE_SYSTEM_ATTENTION); | 37 Panel::USE_SYSTEM_ATTENTION); |
37 EXPECT_EQ(expected_attention_mode, panel->attention_mode()); | 38 EXPECT_EQ(expected_attention_mode, panel->attention_mode()); |
38 | 39 |
39 panel_manager->CloseAll(); | 40 panel_manager->CloseAll(); |
40 } | 41 } |
41 | 42 |
42 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnActive) { | 43 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, DrawAttentionOnActive) { |
43 // Create a detached panel that is initially active. | 44 // Create a detached panel that is initially active. |
44 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 45 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
45 scoped_ptr<NativePanelTesting> native_panel_testing( | 46 scoped_ptr<NativePanelTesting> native_panel_testing( |
46 NativePanelTesting::Create(panel->native_panel())); | 47 NativePanelTesting::Create(panel->native_panel())); |
47 | 48 |
48 // Test that the attention should not be drawn if the detached panel is in | 49 // Test that the attention should not be drawn if the detached panel is in |
49 // focus. | 50 // focus. |
50 EXPECT_TRUE(panel->IsActive()); | 51 EXPECT_TRUE(panel->IsActive()); |
51 EXPECT_FALSE(panel->IsDrawingAttention()); | 52 EXPECT_FALSE(panel->IsDrawingAttention()); |
52 panel->FlashFrame(true); | 53 panel->FlashFrame(true); |
53 EXPECT_FALSE(panel->IsDrawingAttention()); | 54 EXPECT_FALSE(panel->IsDrawingAttention()); |
54 MessageLoop::current()->RunAllPending(); | 55 MessageLoop::current()->RunAllPending(); |
55 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 56 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
56 | 57 |
57 panel->Close(); | 58 panel->Close(); |
58 } | 59 } |
59 | 60 |
60 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnInactive) { | 61 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, DrawAttentionOnInactive) { |
61 // Create an inactive detached panel. | 62 // Create an inactive detached panel. |
62 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 63 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
63 panel->Deactivate(); | 64 panel->Deactivate(); |
64 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 65 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
65 | 66 |
66 scoped_ptr<NativePanelTesting> native_panel_testing( | 67 scoped_ptr<NativePanelTesting> native_panel_testing( |
67 NativePanelTesting::Create(panel->native_panel())); | 68 NativePanelTesting::Create(panel->native_panel())); |
68 | 69 |
69 // Test that the attention is drawn when the detached panel is not in focus. | 70 // Test that the attention is drawn when the detached panel is not in focus. |
70 EXPECT_FALSE(panel->IsActive()); | 71 EXPECT_FALSE(panel->IsActive()); |
71 EXPECT_FALSE(panel->IsDrawingAttention()); | 72 EXPECT_FALSE(panel->IsDrawingAttention()); |
72 panel->FlashFrame(true); | 73 panel->FlashFrame(true); |
73 EXPECT_TRUE(panel->IsDrawingAttention()); | 74 EXPECT_TRUE(panel->IsDrawingAttention()); |
74 MessageLoop::current()->RunAllPending(); | 75 MessageLoop::current()->RunAllPending(); |
75 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 76 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
76 | 77 |
77 // Stop drawing attention. | 78 // Stop drawing attention. |
78 panel->FlashFrame(false); | 79 panel->FlashFrame(false); |
79 EXPECT_FALSE(panel->IsDrawingAttention()); | 80 EXPECT_FALSE(panel->IsDrawingAttention()); |
80 MessageLoop::current()->RunAllPending(); | 81 MessageLoop::current()->RunAllPending(); |
81 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 82 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
82 | 83 |
83 panel->Close(); | 84 panel->Close(); |
84 } | 85 } |
85 | 86 |
86 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionResetOnActivate) { | 87 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, |
| 88 DrawAttentionResetOnActivate) { |
87 // Create 2 panels so we end up with an inactive panel that can | 89 // Create 2 panels so we end up with an inactive panel that can |
88 // be made to draw attention. | 90 // be made to draw attention. |
89 Panel* panel1 = CreatePanel("test panel1"); | 91 Panel* panel1 = CreatePanel("test panel1"); |
90 Panel* panel2 = CreatePanel("test panel2"); | 92 Panel* panel2 = CreatePanel("test panel2"); |
91 | 93 |
92 scoped_ptr<NativePanelTesting> native_panel_testing( | 94 scoped_ptr<NativePanelTesting> native_panel_testing( |
93 NativePanelTesting::Create(panel1->native_panel())); | 95 NativePanelTesting::Create(panel1->native_panel())); |
94 | 96 |
95 // Test that the attention is drawn when the detached panel is not in focus. | 97 // Test that the attention is drawn when the detached panel is not in focus. |
96 panel1->FlashFrame(true); | 98 panel1->FlashFrame(true); |
97 EXPECT_TRUE(panel1->IsDrawingAttention()); | 99 EXPECT_TRUE(panel1->IsDrawingAttention()); |
98 MessageLoop::current()->RunAllPending(); | 100 MessageLoop::current()->RunAllPending(); |
99 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 101 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
100 | 102 |
101 // Test that the attention is cleared when panel gets focus. | 103 // Test that the attention is cleared when panel gets focus. |
102 panel1->Activate(); | 104 panel1->Activate(); |
103 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); | 105 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); |
104 EXPECT_FALSE(panel1->IsDrawingAttention()); | 106 EXPECT_FALSE(panel1->IsDrawingAttention()); |
105 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 107 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
106 | 108 |
107 panel1->Close(); | 109 panel1->Close(); |
108 panel2->Close(); | 110 panel2->Close(); |
109 } | 111 } |
110 | 112 |
111 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, ClickTitlebar) { | 113 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, ClickTitlebar) { |
112 PanelManager* panel_manager = PanelManager::GetInstance(); | 114 PanelManager* panel_manager = PanelManager::GetInstance(); |
113 | 115 |
114 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 116 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
115 EXPECT_TRUE(panel->IsActive()); | 117 EXPECT_TRUE(panel->IsActive()); |
116 EXPECT_FALSE(panel->IsMinimized()); | 118 EXPECT_FALSE(panel->IsMinimized()); |
117 | 119 |
118 // Clicking on an active detached panel's titlebar has no effect, regardless | 120 // Clicking on an active detached panel's titlebar has no effect, regardless |
119 // of modifier. | 121 // of modifier. |
120 scoped_ptr<NativePanelTesting> test_panel( | 122 scoped_ptr<NativePanelTesting> test_panel( |
121 NativePanelTesting::Create(panel->native_panel())); | 123 NativePanelTesting::Create(panel->native_panel())); |
(...skipping 13 matching lines...) Expand all Loading... |
135 EXPECT_FALSE(panel->IsActive()); | 137 EXPECT_FALSE(panel->IsActive()); |
136 | 138 |
137 // Clicking on an inactive detached panel's titlebar activates it. | 139 // Clicking on an inactive detached panel's titlebar activates it. |
138 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); | 140 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); |
139 test_panel->ReleaseMouseButtonTitlebar(); | 141 test_panel->ReleaseMouseButtonTitlebar(); |
140 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 142 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
141 EXPECT_FALSE(panel->IsMinimized()); | 143 EXPECT_FALSE(panel->IsMinimized()); |
142 | 144 |
143 panel_manager->CloseAll(); | 145 panel_manager->CloseAll(); |
144 } | 146 } |
OLD | NEW |