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

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

Issue 12764018: Improve panel related tests to make them more reliable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 7 years, 9 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
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/docked_panel_collection.h" 7 #include "chrome/browser/ui/panels/docked_panel_collection.h"
8 #include "chrome/browser/ui/panels/panel.h" 8 #include "chrome/browser/ui/panels/panel.h"
9 #include "chrome/browser/ui/panels/panel_manager.h" 9 #include "chrome/browser/ui/panels/panel_manager.h"
10 #include "chrome/browser/ui/panels/test_panel_collection_squeeze_observer.h"
11 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
12 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
13 #include "content/public/test/test_utils.h" 12 #include "content/public/test/test_utils.h"
14 13
15 class DockedPanelBrowserTest : public BasePanelBrowserTest { 14 class DockedPanelBrowserTest : public BasePanelBrowserTest {
16 public: 15 public:
17 virtual void SetUpOnMainThread() OVERRIDE { 16 virtual void SetUpOnMainThread() OVERRIDE {
18 BasePanelBrowserTest::SetUpOnMainThread(); 17 BasePanelBrowserTest::SetUpOnMainThread();
19 18
20 // All the tests here assume using mocked 800x600 display area for the 19 // All the tests here assume using mocked 800x600 display area for the
(...skipping 25 matching lines...) Expand all
46 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); 45 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
47 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); 46 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width());
48 EXPECT_EQ(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); 47 EXPECT_EQ(panel3->GetBounds().width(), panel3->GetRestoredBounds().width());
49 48
50 // Create more panels so they start getting squeezed. 49 // Create more panels so they start getting squeezed.
51 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); 50 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100));
52 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); 51 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100));
53 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); 52 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100));
54 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); 53 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100));
55 54
56 // Wait for active states to settle.
57 PanelCollectionSqueezeObserver panel7_settled(docked_collection, panel7);
58 panel7_settled.Wait();
59
60 // The active panel should be at full width. 55 // The active panel should be at full width.
61 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); 56 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width());
62 EXPECT_GT(panel7->GetBounds().x(), docked_collection->work_area().x()); 57 EXPECT_GT(panel7->GetBounds().x(), docked_collection->work_area().x());
63 58
64 // The rest of them should be at reduced width. 59 // The rest of them should be at reduced width.
65 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); 60 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
66 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); 61 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width());
67 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); 62 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width());
68 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); 63 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width());
69 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width()); 64 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width());
70 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); 65 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
71 66
72 // Activate a different panel. 67 // Activate a different panel.
73 panel2->Activate(); 68 panel2->Activate();
74 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); 69 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE);
75 70
76 // Wait for active states to settle.
77 PanelCollectionSqueezeObserver panel2_settled(docked_collection, panel2);
78 panel2_settled.Wait();
79
80 // The active panel should be at full width. 71 // The active panel should be at full width.
81 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); 72 EXPECT_EQ(panel2->GetBounds().width(), panel2->GetRestoredBounds().width());
82 73
83 // The rest of them should be at reduced width. 74 // The rest of them should be at reduced width.
84 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); 75 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
85 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); 76 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width());
86 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); 77 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width());
87 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width()); 78 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width());
88 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); 79 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
89 EXPECT_LT(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); 80 EXPECT_LT(panel7->GetBounds().width(), panel7->GetRestoredBounds().width());
90 81
91 panel_manager->CloseAll(); 82 panel_manager->CloseAll();
92 } 83 }
93 84
94 // http://crbug.com/143247 85 // http://crbug.com/143247
95 #if !defined(OS_WIN) 86 #if !defined(OS_WIN)
96 #define MAYBE_SqueezeAndThenSomeMore DISABLED_SqueezeAndThenSomeMore 87 #define MAYBE_SqueezeAndThenSomeMore DISABLED_SqueezeAndThenSomeMore
97 #else 88 #else
98 #define MAYBE_SqueezeAndThenSomeMore SqueezeAndThenSomeMore 89 #define MAYBE_SqueezeAndThenSomeMore SqueezeAndThenSomeMore
99 #endif 90 #endif
100 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, MAYBE_SqueezeAndThenSomeMore) { 91 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, MAYBE_SqueezeAndThenSomeMore) {
101 PanelManager* panel_manager = PanelManager::GetInstance(); 92 PanelManager* panel_manager = PanelManager::GetInstance();
102 DockedPanelCollection* docked_collection = panel_manager->docked_collection();
103 93
104 // Create enough docked panels to get into squeezing. 94 // Create enough docked panels to get into squeezing.
105 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); 95 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100));
106 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); 96 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100));
107 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); 97 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100));
108 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); 98 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100));
109 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); 99 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100));
110 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); 100 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100));
111 101
112 // Wait for active states to settle. 102 // The active panel should be at full width.
113 PanelCollectionSqueezeObserver panel6_settled(docked_collection, panel6); 103 EXPECT_EQ(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
114 panel6_settled.Wait();
115 104
116 // Record current widths of some panels. 105 // Record current widths of some panels.
117 int panel_1_width_less_squeezed = panel1->GetBounds().width(); 106 int panel_1_width_less_squeezed = panel1->GetBounds().width();
118 int panel_2_width_less_squeezed = panel2->GetBounds().width(); 107 int panel_2_width_less_squeezed = panel2->GetBounds().width();
119 int panel_3_width_less_squeezed = panel3->GetBounds().width(); 108 int panel_3_width_less_squeezed = panel3->GetBounds().width();
120 int panel_4_width_less_squeezed = panel4->GetBounds().width(); 109 int panel_4_width_less_squeezed = panel4->GetBounds().width();
121 int panel_5_width_less_squeezed = panel5->GetBounds().width(); 110 int panel_5_width_less_squeezed = panel5->GetBounds().width();
122 111
123 // These widths should be reduced. 112 // These widths should be reduced.
124 EXPECT_LT(panel_1_width_less_squeezed, panel1->GetRestoredBounds().width()); 113 EXPECT_LT(panel_1_width_less_squeezed, panel1->GetRestoredBounds().width());
125 EXPECT_LT(panel_2_width_less_squeezed, panel2->GetRestoredBounds().width()); 114 EXPECT_LT(panel_2_width_less_squeezed, panel2->GetRestoredBounds().width());
126 EXPECT_LT(panel_3_width_less_squeezed, panel3->GetRestoredBounds().width()); 115 EXPECT_LT(panel_3_width_less_squeezed, panel3->GetRestoredBounds().width());
127 EXPECT_LT(panel_4_width_less_squeezed, panel4->GetRestoredBounds().width()); 116 EXPECT_LT(panel_4_width_less_squeezed, panel4->GetRestoredBounds().width());
128 EXPECT_LT(panel_5_width_less_squeezed, panel5->GetRestoredBounds().width()); 117 EXPECT_LT(panel_5_width_less_squeezed, panel5->GetRestoredBounds().width());
129 118
130 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); 119 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100));
131 120
132 // Wait for active states to settle.
133 PanelCollectionSqueezeObserver panel7_settled(docked_collection, panel7);
134 panel7_settled.Wait();
135
136 // The active panel should be at full width. 121 // The active panel should be at full width.
137 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); 122 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width());
138 123
139 // The panels should shrink in width. 124 // The panels should shrink in width.
140 EXPECT_LT(panel1->GetBounds().width(), panel_1_width_less_squeezed); 125 EXPECT_LT(panel1->GetBounds().width(), panel_1_width_less_squeezed);
141 EXPECT_LT(panel2->GetBounds().width(), panel_2_width_less_squeezed); 126 EXPECT_LT(panel2->GetBounds().width(), panel_2_width_less_squeezed);
142 EXPECT_LT(panel3->GetBounds().width(), panel_3_width_less_squeezed); 127 EXPECT_LT(panel3->GetBounds().width(), panel_3_width_less_squeezed);
143 EXPECT_LT(panel4->GetBounds().width(), panel_4_width_less_squeezed); 128 EXPECT_LT(panel4->GetBounds().width(), panel_4_width_less_squeezed);
144 EXPECT_LT(panel5->GetBounds().width(), panel_5_width_less_squeezed); 129 EXPECT_LT(panel5->GetBounds().width(), panel_5_width_less_squeezed);
130 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
145 131
146 panel_manager->CloseAll(); 132 panel_manager->CloseAll();
147 } 133 }
148 134
149 // http://crbug.com/143247 135 // http://crbug.com/143247
150 #if !defined(OS_WIN) 136 #if !defined(OS_WIN)
151 #define MAYBE_MinimizeSqueezedActive DISABLED_MinimizeSqueezedActive 137 #define MAYBE_MinimizeSqueezedActive DISABLED_MinimizeSqueezedActive
152 #else 138 #else
153 #define MAYBE_MinimizeSqueezedActive MinimizeSqueezedActive 139 #define MAYBE_MinimizeSqueezedActive MinimizeSqueezedActive
154 #endif 140 #endif
155 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, MAYBE_MinimizeSqueezedActive) { 141 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, MAYBE_MinimizeSqueezedActive) {
156 PanelManager* panel_manager = PanelManager::GetInstance(); 142 PanelManager* panel_manager = PanelManager::GetInstance();
157 DockedPanelCollection* docked_collection = panel_manager->docked_collection();
158 143
159 // Create enough docked panels to get into squeezing. 144 // Create enough docked panels to get into squeezing.
160 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); 145 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100));
161 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); 146 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100));
162 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); 147 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100));
163 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); 148 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100));
164 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); 149 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100));
165 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); 150 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100));
166 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); 151 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100));
167 152
168 // Wait for active states to settle.
169 PanelCollectionSqueezeObserver panel7_settled(docked_collection, panel7);
170 panel7_settled.Wait();
171
172 // The active panel should be at full width. 153 // The active panel should be at full width.
173 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width()); 154 EXPECT_EQ(panel7->GetBounds().width(), panel7->GetRestoredBounds().width());
174 155
175 // The rest of them should be at reduced width. 156 // The rest of them should be at reduced width.
176 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); 157 EXPECT_LT(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
177 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width()); 158 EXPECT_LT(panel2->GetBounds().width(), panel2->GetRestoredBounds().width());
178 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width()); 159 EXPECT_LT(panel3->GetBounds().width(), panel3->GetRestoredBounds().width());
179 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); 160 EXPECT_LT(panel4->GetBounds().width(), panel4->GetRestoredBounds().width());
180 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width()); 161 EXPECT_LT(panel5->GetBounds().width(), panel5->GetRestoredBounds().width());
181 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); 162 EXPECT_LT(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
(...skipping 24 matching lines...) Expand all
206 } 187 }
207 188
208 // http://crbug.com/143247 189 // http://crbug.com/143247
209 #if !defined(OS_WIN) 190 #if !defined(OS_WIN)
210 #define MAYBE_CloseSqueezedPanels DISABLED_CloseSqueezedPanels 191 #define MAYBE_CloseSqueezedPanels DISABLED_CloseSqueezedPanels
211 #else 192 #else
212 #define MAYBE_CloseSqueezedPanels CloseSqueezedPanels 193 #define MAYBE_CloseSqueezedPanels CloseSqueezedPanels
213 #endif 194 #endif
214 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, MAYBE_CloseSqueezedPanels) { 195 IN_PROC_BROWSER_TEST_F(DockedPanelBrowserTest, MAYBE_CloseSqueezedPanels) {
215 PanelManager* panel_manager = PanelManager::GetInstance(); 196 PanelManager* panel_manager = PanelManager::GetInstance();
216 DockedPanelCollection* docked_collection = panel_manager->docked_collection();
217 197
218 // Create enough docked panels to get into squeezing. 198 // Create enough docked panels to get into squeezing.
219 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100)); 199 Panel* panel1 = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 100));
220 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100)); 200 Panel* panel2 = CreateDockedPanel("2", gfx::Rect(0, 0, 200, 100));
221 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100)); 201 Panel* panel3 = CreateDockedPanel("3", gfx::Rect(0, 0, 200, 100));
222 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100)); 202 Panel* panel4 = CreateDockedPanel("4", gfx::Rect(0, 0, 200, 100));
223 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100)); 203 Panel* panel5 = CreateDockedPanel("5", gfx::Rect(0, 0, 200, 100));
224 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100)); 204 Panel* panel6 = CreateDockedPanel("6", gfx::Rect(0, 0, 200, 100));
225 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100)); 205 Panel* panel7 = CreateDockedPanel("7", gfx::Rect(0, 0, 200, 100));
226 206
227 // Wait for active states to settle.
228 PanelCollectionSqueezeObserver panel7_settled(docked_collection, panel7);
229 panel7_settled.Wait();
230
231 // Record current widths of some panels. 207 // Record current widths of some panels.
232 int panel_1_orig_width = panel1->GetBounds().width(); 208 int panel_1_orig_width = panel1->GetBounds().width();
233 int panel_2_orig_width = panel2->GetBounds().width(); 209 int panel_2_orig_width = panel2->GetBounds().width();
234 int panel_3_orig_width = panel3->GetBounds().width(); 210 int panel_3_orig_width = panel3->GetBounds().width();
235 int panel_4_orig_width = panel4->GetBounds().width(); 211 int panel_4_orig_width = panel4->GetBounds().width();
236 int panel_5_orig_width = panel5->GetBounds().width(); 212 int panel_5_orig_width = panel5->GetBounds().width();
237 int panel_6_orig_width = panel6->GetBounds().width(); 213 int panel_6_orig_width = panel6->GetBounds().width();
238 int panel_7_orig_width = panel7->GetBounds().width(); 214 int panel_7_orig_width = panel7->GetBounds().width();
239 215
240 // The active panel should be at full width. 216 // The active panel should be at full width.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 CloseWindowAndWait(panel7); 252 CloseWindowAndWait(panel7);
277 signal2.Wait(); 253 signal2.Wait();
278 254
279 // We should not have squeezing any more; all panels should be at full width. 255 // We should not have squeezing any more; all panels should be at full width.
280 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width()); 256 EXPECT_EQ(panel1->GetBounds().width(), panel1->GetRestoredBounds().width());
281 EXPECT_EQ(panel4->GetBounds().width(), panel4->GetRestoredBounds().width()); 257 EXPECT_EQ(panel4->GetBounds().width(), panel4->GetRestoredBounds().width());
282 EXPECT_EQ(panel6->GetBounds().width(), panel6->GetRestoredBounds().width()); 258 EXPECT_EQ(panel6->GetBounds().width(), panel6->GetRestoredBounds().width());
283 259
284 panel_manager->CloseAll(); 260 panel_manager->CloseAll();
285 } 261 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/base_panel_browser_test.cc ('k') | chrome/browser/ui/panels/docked_panel_collection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698