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/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" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnActive) { | 48 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionOnActive) { |
49 // Create a detached panel that is initially active. | 49 // Create a detached panel that is initially active. |
50 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 50 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
51 scoped_ptr<NativePanelTesting> native_panel_testing( | 51 scoped_ptr<NativePanelTesting> native_panel_testing( |
52 CreateNativePanelTesting(panel)); | 52 CreateNativePanelTesting(panel)); |
53 | 53 |
54 // Test that the attention should not be drawn if the detached panel is in | 54 // Test that the attention should not be drawn if the detached panel is in |
55 // focus. | 55 // focus. |
56 EXPECT_TRUE(panel->IsActive()); | 56 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); // doublecheck active state |
57 EXPECT_FALSE(panel->IsDrawingAttention()); | 57 EXPECT_FALSE(panel->IsDrawingAttention()); |
58 panel->FlashFrame(true); | 58 panel->FlashFrame(true); |
59 EXPECT_FALSE(panel->IsDrawingAttention()); | 59 EXPECT_FALSE(panel->IsDrawingAttention()); |
60 MessageLoop::current()->RunAllPending(); | 60 MessageLoop::current()->RunAllPending(); |
61 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 61 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
62 | 62 |
63 panel->Close(); | 63 panel->Close(); |
64 } | 64 } |
65 | 65 |
66 #if defined(OS_LINUX) | |
67 // http://crbug.com/145740 | |
68 #define MAYBE_DrawAttentionOnInactive FLAKY_DrawAttentionOnInactive | |
69 #else | |
70 #define MAYBE_DrawAttentionOnInactive DrawAttentionOnInactive | |
71 #endif | |
72 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, | 66 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, |
73 MAYBE_DrawAttentionOnInactive) { | 67 DrawAttentionOnInactive) { |
74 // Create an inactive detached panel. | 68 // Create two panels so that first panel becomes inactive. |
75 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 69 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
76 panel->Deactivate(); | 70 CreateDetachedPanel("2", gfx::Rect(100, 100, 250, 200)); |
77 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 71 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
78 | 72 |
79 scoped_ptr<NativePanelTesting> native_panel_testing( | 73 scoped_ptr<NativePanelTesting> native_panel_testing( |
80 CreateNativePanelTesting(panel)); | 74 CreateNativePanelTesting(panel)); |
81 | 75 |
82 // Test that the attention is drawn when the detached panel is not in focus. | 76 // Test that the attention is drawn when the detached panel is not in focus. |
83 EXPECT_FALSE(panel->IsActive()); | 77 EXPECT_FALSE(panel->IsActive()); |
84 EXPECT_FALSE(panel->IsDrawingAttention()); | 78 EXPECT_FALSE(panel->IsDrawingAttention()); |
85 panel->FlashFrame(true); | 79 panel->FlashFrame(true); |
86 EXPECT_TRUE(panel->IsDrawingAttention()); | 80 EXPECT_TRUE(panel->IsDrawingAttention()); |
87 MessageLoop::current()->RunAllPending(); | 81 MessageLoop::current()->RunAllPending(); |
88 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 82 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
89 | 83 |
90 // Stop drawing attention. | 84 // Stop drawing attention. |
91 panel->FlashFrame(false); | 85 panel->FlashFrame(false); |
92 EXPECT_FALSE(panel->IsDrawingAttention()); | 86 EXPECT_FALSE(panel->IsDrawingAttention()); |
93 MessageLoop::current()->RunAllPending(); | 87 MessageLoop::current()->RunAllPending(); |
94 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 88 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
95 | 89 |
96 panel->Close(); | 90 PanelManager::GetInstance()->CloseAll(); |
97 } | 91 } |
98 | 92 |
99 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionResetOnActivate) { | 93 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DrawAttentionResetOnActivate) { |
100 // Create 2 panels so we end up with an inactive panel that can | 94 // Create 2 panels so we end up with an inactive panel that can |
101 // be made to draw attention. | 95 // be made to draw attention. |
102 Panel* panel1 = CreatePanel("test panel1"); | 96 Panel* panel1 = CreateDetachedPanel("test panel1", |
103 Panel* panel2 = CreatePanel("test panel2"); | 97 gfx::Rect(300, 200, 250, 200)); |
| 98 Panel* panel2 = CreateDetachedPanel("test panel2", |
| 99 gfx::Rect(100, 100, 250, 200)); |
| 100 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE); |
104 | 101 |
105 scoped_ptr<NativePanelTesting> native_panel_testing( | 102 scoped_ptr<NativePanelTesting> native_panel_testing( |
106 CreateNativePanelTesting(panel1)); | 103 CreateNativePanelTesting(panel1)); |
107 | 104 |
108 // Test that the attention is drawn when the detached panel is not in focus. | 105 // Test that the attention is drawn when the detached panel is not in focus. |
109 panel1->FlashFrame(true); | 106 panel1->FlashFrame(true); |
110 EXPECT_TRUE(panel1->IsDrawingAttention()); | 107 EXPECT_TRUE(panel1->IsDrawingAttention()); |
111 MessageLoop::current()->RunAllPending(); | 108 MessageLoop::current()->RunAllPending(); |
112 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 109 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
113 | 110 |
114 // Test that the attention is cleared when panel gets focus. | 111 // Test that the attention is cleared when panel gets focus. |
115 panel1->Activate(); | 112 panel1->Activate(); |
116 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); | 113 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); |
117 EXPECT_FALSE(panel1->IsDrawingAttention()); | 114 EXPECT_FALSE(panel1->IsDrawingAttention()); |
118 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 115 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
119 | 116 |
120 panel1->Close(); | 117 panel1->Close(); |
121 panel2->Close(); | 118 panel2->Close(); |
122 } | 119 } |
123 | 120 |
124 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, ClickTitlebar) { | 121 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, ClickTitlebar) { |
125 PanelManager* panel_manager = PanelManager::GetInstance(); | 122 PanelManager* panel_manager = PanelManager::GetInstance(); |
126 | 123 |
127 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); | 124 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200)); |
128 EXPECT_TRUE(panel->IsActive()); | |
129 EXPECT_FALSE(panel->IsMinimized()); | 125 EXPECT_FALSE(panel->IsMinimized()); |
130 | 126 |
131 // 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 |
132 // of modifier. | 128 // of modifier. |
| 129 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); // doublecheck active state |
133 scoped_ptr<NativePanelTesting> test_panel( | 130 scoped_ptr<NativePanelTesting> test_panel( |
134 CreateNativePanelTesting(panel)); | 131 CreateNativePanelTesting(panel)); |
135 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); | 132 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); |
136 test_panel->ReleaseMouseButtonTitlebar(); | 133 test_panel->ReleaseMouseButtonTitlebar(); |
137 EXPECT_TRUE(panel->IsActive()); | 134 EXPECT_TRUE(panel->IsActive()); |
138 EXPECT_FALSE(panel->IsMinimized()); | 135 EXPECT_FALSE(panel->IsMinimized()); |
139 | 136 |
140 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin(), | 137 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin(), |
141 panel::APPLY_TO_ALL); | 138 panel::APPLY_TO_ALL); |
142 test_panel->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 139 test_panel->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
143 EXPECT_TRUE(panel->IsActive()); | 140 EXPECT_TRUE(panel->IsActive()); |
144 EXPECT_FALSE(panel->IsMinimized()); | 141 EXPECT_FALSE(panel->IsMinimized()); |
145 | 142 |
146 // Create a second panel to cause the first to become inactive. | 143 // Create a second panel to cause the first to become inactive. |
147 CreateDetachedPanel("2", gfx::Rect(100, 200, 230, 345)); | 144 CreateDetachedPanel("2", gfx::Rect(100, 200, 230, 345)); |
148 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 145 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
149 | 146 |
150 // Clicking on an inactive detached panel's titlebar activates it. | 147 // Clicking on an inactive detached panel's titlebar activates it. |
151 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); | 148 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin()); |
152 test_panel->ReleaseMouseButtonTitlebar(); | 149 test_panel->ReleaseMouseButtonTitlebar(); |
153 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 150 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
154 EXPECT_FALSE(panel->IsMinimized()); | 151 EXPECT_FALSE(panel->IsMinimized()); |
155 | 152 |
156 panel_manager->CloseAll(); | 153 panel_manager->CloseAll(); |
157 } | 154 } |
OLD | NEW |