Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(751)

Side by Side Diff: chrome/browser/ui/panels/old_docked_panel_browsertest.cc

Issue 10908153: [Panel refactor] Deprecate old panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux_chromeos test failure Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/docked_panel_strip.h"
8 #include "chrome/browser/ui/panels/panel.h"
9 #include "chrome/browser/ui/panels/panel_manager.h"
10 #include "chrome/common/chrome_notification_types.h"
11 #include "content/public/browser/notification_service.h"
12 #include "content/public/test/test_utils.h"
13
14 class OldDockedPanelBrowserTest : public OldBasePanelBrowserTest {
15 public:
16 virtual void SetUpOnMainThread() OVERRIDE {
17 OldBasePanelBrowserTest::SetUpOnMainThread();
18
19 // All the tests here assume using mocked 800x600 screen area for the
20 // primary monitor. Do the check now.
21 gfx::Rect primary_screen_area = PanelManager::GetInstance()->
22 display_settings_provider()->GetPrimaryScreenArea();
23 DCHECK(primary_screen_area.width() == 800);
24 DCHECK(primary_screen_area.height() == 600);
25 }
26 };
27
28 // TODO(jennb): timing out on Windows after r10702045 (crbug 135510)
29 #if defined(OS_WIN)
30 #define MAYBE_SqueezePanelsInDock DISABLED_SqueezePanelsInDock
31 #else
32 #define MAYBE_SqueezePanelsInDock SqueezePanelsInDock
33 #endif
34 IN_PROC_BROWSER_TEST_F(OldDockedPanelBrowserTest, MAYBE_SqueezePanelsInDock) {
35 PanelManager* panel_manager = PanelManager::GetInstance();
36 DockedPanelStrip* docked_strip = panel_manager->docked_strip();
37
38 // Create some docked panels.
39 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100));
40 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100));
41 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100));
42 ASSERT_EQ(3, docked_strip->num_panels());
43
44 // Check that nothing has been squeezed so far.
45 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
46 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width());
47 EXPECT_EQ(panel3->GetBounds().width(), panel3->GetRestoredBounds().width());
48
49 // Create more panels so they start getting squeezed.
50 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100));
51 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100));
52 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100));
53 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100));
54
55 // Wait for active states to settle.
56 WaitForPanelActiveState(panel7, SHOW_AS_ACTIVE);
57
58 // Wait for the scheduled layout to run.
59 MessageLoopForUI::current()->RunAllPending();
60
61 // The active panel should be at full width.
62 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width());
63 EXPECT_GT(panel7->GetBounds().x(), docked_strip->display_area().x());
64
65 // The rest of them should be at reduced width.
66 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
67 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width());
68 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width());
69 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width());
70 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width());
71 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
72
73 // Activate a different panel.
74 panel2->Activate();
75
76 // Wait for active states to settle.
77 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE);
78
79 // Wait for the scheduled layout to run.
80 MessageLoopForUI::current()->RunAllPending();
81
82 // The active panel should be at full width.
83 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width());
84
85 // The rest of them should be at reduced width.
86 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
87 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width());
88 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width());
89 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width());
90 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
91 EXPECT_LT(panel7->GetBounds().width(), panel7->GetRestoredBounds().width());
92
93 panel_manager->CloseAll();
94 }
95
96 IN_PROC_BROWSER_TEST_F(OldDockedPanelBrowserTest, SqueezeAndThenSomeMore) {
97 PanelManager* panel_manager = PanelManager::GetInstance();
98
99 // Create enough docked panels to get into squeezing.
100 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100));
101 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100));
102 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100));
103 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100));
104 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100));
105 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100));
106
107 // Wait for active states to settle.
108 WaitForPanelActiveState(panel6, SHOW_AS_ACTIVE);
109
110 // Wait for the scheduled layout to run.
111 MessageLoopForUI::current()->RunAllPending();
112
113 // Record current widths of some panels.
114 int panel_1_width_less_squeezed = panel1->GetBounds().width();
115 int panel_2_width_less_squeezed = panel2->GetBounds().width();
116 int panel_3_width_less_squeezed = panel3->GetBounds().width();
117 int panel_4_width_less_squeezed = panel4->GetBounds().width();
118 int panel_5_width_less_squeezed = panel5->GetBounds().width();
119
120 // These widths should be reduced.
121 EXPECT_LT(panel_1_width_less_squeezed, panel1->GetRestoredBounds().width());
122 EXPECT_LT(panel_2_width_less_squeezed, panel2->GetRestoredBounds().width());
123 EXPECT_LT(panel_3_width_less_squeezed, panel3->GetRestoredBounds().width());
124 EXPECT_LT(panel_4_width_less_squeezed, panel4->GetRestoredBounds().width());
125 EXPECT_LT(panel_5_width_less_squeezed, panel5->GetRestoredBounds().width());
126
127 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100));
128
129 // Wait for active states to settle.
130 WaitForPanelActiveState(panel7, SHOW_AS_ACTIVE);
131
132 // Wait for the scheduled layout to run.
133 MessageLoopForUI::current()->RunAllPending();
134
135 // The active panel should be at full width.
136 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width());
137
138 // The panels should shrink in width.
139 EXPECT_LT(panel1->GetBounds().width(), panel_1_width_less_squeezed);
140 EXPECT_LT(panel2->GetBounds().width(), panel_2_width_less_squeezed);
141 EXPECT_LT(panel3->GetBounds().width(), panel_3_width_less_squeezed);
142 EXPECT_LT(panel4->GetBounds().width(), panel_4_width_less_squeezed);
143 EXPECT_LT(panel5->GetBounds().width(), panel_5_width_less_squeezed);
144
145 panel_manager->CloseAll();
146 }
147
148 // http://crbug.com/133463
149 #if defined(OS_LINUX)
150 #define MAYBE_MinimizeSqueezedActive DISABLED_MinimizeSqueezedActive
151 #else
152 #define MAYBE_MinimizeSqueezedActive MinimizeSqueezedActive
153 #endif
154
155 IN_PROC_BROWSER_TEST_F(OldDockedPanelBrowserTest, MAYBE_MinimizeSqueezedActive) {
156 PanelManager* panel_manager = PanelManager::GetInstance();
157
158 // Create enough docked panels to get into squeezing.
159 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100));
160 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100));
161 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100));
162 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100));
163 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100));
164 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100));
165 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100));
166
167 // Wait for active states to settle.
168 WaitForPanelActiveState(panel7, SHOW_AS_ACTIVE);
169
170 // Wait for the scheduled layout to run.
171 MessageLoopForUI::current()->RunAllPending();
172
173 // The active panel should be at full width.
174 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width());
175
176 // The rest of them should be at reduced width.
177 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
178 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width());
179 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width());
180 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width());
181 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width());
182 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
183
184 // Record the width of an inactive panel and minimize it.
185 int width_of_panel3_squeezed = panel3->GetBounds().width();
186 panel3->Minimize();
187
188 // Wait for any possible events.
189 MessageLoopForUI::current()->RunAllPending();
190
191 // Check that this panel is still at the same width.
192 EXPECT_EQ(width_of_panel3_squeezed, panel3->GetBounds().width());
193
194 // Minimize the active panel. It should become inactive and shrink in width.
195 content::WindowedNotificationObserver signal(
196 chrome::NOTIFICATION_PANEL_STRIP_UPDATED,
197 content::NotificationService::AllSources());
198 panel7->Minimize();
199
200 // Wait for active states to settle.
201 WaitForPanelActiveState(panel7, SHOW_AS_INACTIVE);
202
203 // Wait for the scheduled layout to run.
204 signal.Wait();
205
206 // The minimized panel should now be at reduced width.
207 EXPECT_LT(panel7->GetBounds().width(), panel7->GetRestoredBounds().width());
208
209 panel_manager->CloseAll();
210 }
211
212 IN_PROC_BROWSER_TEST_F(OldDockedPanelBrowserTest, CloseSqueezedPanels) {
213 PanelManager* panel_manager = PanelManager::GetInstance();
214
215 // Create enough docked panels to get into squeezing.
216 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100));
217 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100));
218 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100));
219 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100));
220 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100));
221 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100));
222 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100));
223
224 // Wait for active states to settle.
225 WaitForPanelActiveState(panel7, SHOW_AS_ACTIVE);
226
227 // Wait for the scheduled layout to run.
228 MessageLoopForUI::current()->RunAllPending();
229
230 // Record current widths of some panels.
231 int panel_1_orig_width = panel1->GetBounds().width();
232 int panel_2_orig_width = panel2->GetBounds().width();
233 int panel_3_orig_width = panel3->GetBounds().width();
234 int panel_4_orig_width = panel4->GetBounds().width();
235 int panel_5_orig_width = panel5->GetBounds().width();
236 int panel_6_orig_width = panel6->GetBounds().width();
237 int panel_7_orig_width = panel7->GetBounds().width();
238
239 // The active panel should be at full width.
240 EXPECT_EQ(panel_7_orig_width, panel7->GetRestoredBounds().width());
241
242 // The rest of them should be at reduced width.
243 EXPECT_LT(panel_1_orig_width, panel1->GetRestoredBounds().width());
244 EXPECT_LT(panel_2_orig_width, panel2->GetRestoredBounds().width());
245 EXPECT_LT(panel_3_orig_width, panel3->GetRestoredBounds().width());
246 EXPECT_LT(panel_4_orig_width, panel4->GetRestoredBounds().width());
247 EXPECT_LT(panel_5_orig_width, panel5->GetRestoredBounds().width());
248 EXPECT_LT(panel_6_orig_width, panel6->GetRestoredBounds().width());
249
250 // Close one panel.
251 panel2->Close();
252
253 // Wait for all processing to finish.
254 MessageLoopForUI::current()->RunAllPending();
255
256 // The widths of the remaining panels should have increased.
257 EXPECT_GT(panel1->GetBounds().width(), panel_1_orig_width);
258 EXPECT_GT(panel3->GetBounds().width(), panel_3_orig_width);
259 EXPECT_GT(panel4->GetBounds().width(), panel_4_orig_width);
260 EXPECT_GT(panel5->GetBounds().width(), panel_5_orig_width);
261 EXPECT_GT(panel6->GetBounds().width(), panel_6_orig_width);
262
263 // The active panel should have stayed at full width.
264 EXPECT_EQ(panel7->GetBounds().width(), panel_7_orig_width);
265
266 // Close several panels.
267 panel3->Close();
268 panel5->Close();
269 panel7->Close();
270
271 // Wait for all processing to finish.
272 MessageLoopForUI::current()->RunAllPending();
273
274 // We should not have squeezing any more; all panels should be at full width.
275 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
276 EXPECT_EQ(panel4->GetBounds().width(), panel4->GetRestoredBounds().width());
277 EXPECT_EQ(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
278
279 panel_manager->CloseAll();
280 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/old_detached_panel_browsertest.cc ('k') | chrome/browser/ui/panels/old_panel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698