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

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

Issue 8827011: Panel strip refactor cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/i18n/time_formatting.h" 5 #include "base/i18n/time_formatting.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser_window.h" 9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/panels/base_panel_browser_test.h" 10 #include "chrome/browser/ui/panels/base_panel_browser_test.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 if (enable_auto_hiding) 188 if (enable_auto_hiding)
189 expected_bottom_on_title_only -= bottom_thickness; 189 expected_bottom_on_title_only -= bottom_thickness;
190 190
191 // Create and test one panel first. 191 // Create and test one panel first.
192 Panel* panel1 = CreatePanel("PanelTest1"); 192 Panel* panel1 = CreatePanel("PanelTest1");
193 PanelBrowserView* browser_view1 = GetBrowserView(panel1); 193 PanelBrowserView* browser_view1 = GetBrowserView(panel1);
194 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView(); 194 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView();
195 195
196 // Test minimizing/restoring an individual panel. 196 // Test minimizing/restoring an individual panel.
197 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); 197 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
198 EXPECT_EQ(0, panel_manager->minimized_panel_count());
199 int initial_height = panel1->GetBounds().height(); 198 int initial_height = panel1->GetBounds().height();
200 int titlebar_height = frame_view1->NonClientTopBorderHeight(); 199 int titlebar_height = frame_view1->NonClientTopBorderHeight();
201 200
202 panel1->SetExpansionState(Panel::MINIMIZED); 201 panel1->SetExpansionState(Panel::MINIMIZED);
203 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); 202 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state());
204 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); 203 EXPECT_LT(panel1->GetBounds().height(), titlebar_height);
205 EXPECT_GT(panel1->GetBounds().height(), 0); 204 EXPECT_GT(panel1->GetBounds().height(), 0);
206 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); 205 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom());
207 EXPECT_EQ(1, panel_manager->minimized_panel_count());
208 WaitTillBoundsAnimationFinished(panel1); 206 WaitTillBoundsAnimationFinished(panel1);
209 EXPECT_FALSE(panel1->IsActive()); 207 EXPECT_FALSE(panel1->IsActive());
210 208
211 panel1->SetExpansionState(Panel::TITLE_ONLY); 209 panel1->SetExpansionState(Panel::TITLE_ONLY);
212 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); 210 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
213 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); 211 EXPECT_EQ(titlebar_height, panel1->GetBounds().height());
214 EXPECT_EQ(expected_bottom_on_title_only, panel1->GetBounds().bottom()); 212 EXPECT_EQ(expected_bottom_on_title_only, panel1->GetBounds().bottom());
215 EXPECT_EQ(1, panel_manager->minimized_panel_count());
216 WaitTillBoundsAnimationFinished(panel1); 213 WaitTillBoundsAnimationFinished(panel1);
217 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); 214 EXPECT_TRUE(frame_view1->close_button_->IsVisible());
218 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); 215 EXPECT_TRUE(frame_view1->title_icon_->IsVisible());
219 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); 216 EXPECT_TRUE(frame_view1->title_label_->IsVisible());
220 217
221 panel1->SetExpansionState(Panel::EXPANDED); 218 panel1->SetExpansionState(Panel::EXPANDED);
222 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); 219 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
223 EXPECT_EQ(initial_height, panel1->GetBounds().height()); 220 EXPECT_EQ(initial_height, panel1->GetBounds().height());
224 EXPECT_EQ(expected_bottom_on_expanded, panel1->GetBounds().bottom()); 221 EXPECT_EQ(expected_bottom_on_expanded, panel1->GetBounds().bottom());
225 EXPECT_EQ(0, panel_manager->minimized_panel_count());
226 WaitTillBoundsAnimationFinished(panel1); 222 WaitTillBoundsAnimationFinished(panel1);
227 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); 223 EXPECT_TRUE(frame_view1->close_button_->IsVisible());
228 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); 224 EXPECT_TRUE(frame_view1->title_icon_->IsVisible());
229 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); 225 EXPECT_TRUE(frame_view1->title_label_->IsVisible());
230 226
231 panel1->SetExpansionState(Panel::MINIMIZED); 227 panel1->SetExpansionState(Panel::MINIMIZED);
232 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); 228 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state());
233 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); 229 EXPECT_LT(panel1->GetBounds().height(), titlebar_height);
234 EXPECT_GT(panel1->GetBounds().height(), 0); 230 EXPECT_GT(panel1->GetBounds().height(), 0);
235 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); 231 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom());
236 EXPECT_EQ(1, panel_manager->minimized_panel_count());
237 232
238 panel1->SetExpansionState(Panel::TITLE_ONLY); 233 panel1->SetExpansionState(Panel::TITLE_ONLY);
239 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); 234 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
240 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); 235 EXPECT_EQ(titlebar_height, panel1->GetBounds().height());
241 EXPECT_EQ(expected_bottom_on_title_only, panel1->GetBounds().bottom()); 236 EXPECT_EQ(expected_bottom_on_title_only, panel1->GetBounds().bottom());
242 EXPECT_EQ(1, panel_manager->minimized_panel_count());
243 237
244 // Create 2 more panels for more testing. 238 // Create 2 more panels for more testing.
245 Panel* panel2 = CreatePanel("PanelTest2"); 239 Panel* panel2 = CreatePanel("PanelTest2");
246 Panel* panel3 = CreatePanel("PanelTest3"); 240 Panel* panel3 = CreatePanel("PanelTest3");
247 241
248 // Test bringing up or down the title-bar of all minimized panels. 242 // Test bringing up or down the title-bar of all minimized panels.
249 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); 243 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
250 panel3->SetExpansionState(Panel::MINIMIZED); 244 panel3->SetExpansionState(Panel::MINIMIZED);
251 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); 245 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state());
252 EXPECT_EQ(2, panel_manager->minimized_panel_count());
253 246
254 mock_auto_hiding_desktop_bar()->SetVisibility( 247 mock_auto_hiding_desktop_bar()->SetVisibility(
255 AutoHidingDesktopBar::ALIGN_BOTTOM, AutoHidingDesktopBar::VISIBLE); 248 AutoHidingDesktopBar::ALIGN_BOTTOM, AutoHidingDesktopBar::VISIBLE);
256 panel_manager->BringUpOrDownTitlebars(true); 249 panel_manager->BringUpOrDownTitlebars(true);
257 MessageLoopForUI::current()->RunAllPending(); 250 MessageLoopForUI::current()->RunAllPending();
258 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); 251 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
259 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); 252 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
260 EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state()); 253 EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state());
261 EXPECT_EQ(2, panel_manager->minimized_panel_count());
262 254
263 mock_auto_hiding_desktop_bar()->SetVisibility( 255 mock_auto_hiding_desktop_bar()->SetVisibility(
264 AutoHidingDesktopBar::ALIGN_BOTTOM, AutoHidingDesktopBar::HIDDEN); 256 AutoHidingDesktopBar::ALIGN_BOTTOM, AutoHidingDesktopBar::HIDDEN);
265 panel_manager->BringUpOrDownTitlebars(false); 257 panel_manager->BringUpOrDownTitlebars(false);
266 MessageLoopForUI::current()->RunAllPending(); 258 MessageLoopForUI::current()->RunAllPending();
267 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); 259 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state());
268 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); 260 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
269 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); 261 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state());
270 EXPECT_EQ(2, panel_manager->minimized_panel_count());
271 262
272 // Test if it is OK to bring up title-bar given the mouse position. 263 // Test if it is OK to bring up title-bar given the mouse position.
273 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( 264 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars(
274 panel1->GetBounds().x(), panel1->GetBounds().y())); 265 panel1->GetBounds().x(), panel1->GetBounds().y()));
275 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( 266 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars(
276 panel2->GetBounds().x(), panel2->GetBounds().y())); 267 panel2->GetBounds().x(), panel2->GetBounds().y()));
277 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( 268 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars(
278 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() - 1)); 269 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() - 1));
279 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( 270 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars(
280 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() + 10)); 271 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() + 10));
281 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( 272 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars(
282 0, 0)); 273 0, 0));
283 274
284 // Test that the panel in title-only state should not be minimized 275 // Test that the panel in title-only state should not be minimized
285 // regardless of the current mouse position when the panel is being dragged. 276 // regardless of the current mouse position when the panel is being dragged.
286 panel1->SetExpansionState(Panel::TITLE_ONLY); 277 panel1->SetExpansionState(Panel::TITLE_ONLY);
287 EXPECT_EQ(2, panel_manager->minimized_panel_count());
288 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( 278 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars(
289 0, 0)); 279 0, 0));
290 browser_view1->OnTitlebarMousePressed(panel1->GetBounds().origin()); 280 browser_view1->OnTitlebarMousePressed(panel1->GetBounds().origin());
291 browser_view1->OnTitlebarMouseDragged( 281 browser_view1->OnTitlebarMouseDragged(
292 panel1->GetBounds().origin().Subtract(gfx::Point(5, 5))); 282 panel1->GetBounds().origin().Subtract(gfx::Point(5, 5)));
293 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( 283 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars(
294 0, 0)); 284 0, 0));
295 browser_view1->OnTitlebarMouseReleased(); 285 browser_view1->OnTitlebarMouseReleased();
296 286
297 ClosePanelAndWaitForNotification(panel1); 287 ClosePanelAndWaitForNotification(panel1);
298 ClosePanelAndWaitForNotification(panel2); 288 ClosePanelAndWaitForNotification(panel2);
299 ClosePanelAndWaitForNotification(panel3); 289 ClosePanelAndWaitForNotification(panel3);
300 EXPECT_EQ(0, panel_manager->minimized_panel_count());
301 } 290 }
302 291
303 void TestDrawAttention() { 292 void TestDrawAttention() {
304 Panel* panel = CreatePanel("PanelTest"); 293 Panel* panel = CreatePanel("PanelTest");
305 PanelBrowserView* browser_view = GetBrowserView(panel); 294 PanelBrowserView* browser_view = GetBrowserView(panel);
306 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); 295 PanelBrowserFrameView* frame_view = browser_view->GetFrameView();
307 frame_view->title_label_->SetAutoColorReadabilityEnabled(false); 296 frame_view->title_label_->SetAutoColorReadabilityEnabled(false);
308 SkColor attention_color = frame_view->GetTitleColor( 297 SkColor attention_color = frame_view->GetTitleColor(
309 PanelBrowserFrameView::PAINT_FOR_ATTENTION); 298 PanelBrowserFrameView::PAINT_FOR_ATTENTION);
310 299
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 // http://crbug.com/102734 602 // http://crbug.com/102734
614 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DISABLED_DrawAttention) { 603 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DISABLED_DrawAttention) {
615 TestDrawAttention(); 604 TestDrawAttention();
616 } 605 }
617 606
618 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, 607 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest,
619 ChangeAutoHideTaskBarThickness) { 608 ChangeAutoHideTaskBarThickness) {
620 TestChangeAutoHideTaskBarThickness(); 609 TestChangeAutoHideTaskBarThickness();
621 } 610 }
622 #endif 611 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_view.cc ('k') | chrome/browser/ui/panels/panel_browser_window_cocoa.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698