| OLD | NEW |
| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/i18n/time_formatting.h" | 6 #include "base/i18n/time_formatting.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.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 EXPECT_EQ(PanelBrowserFrameView::PAINT_AS_INACTIVE, | 193 EXPECT_EQ(PanelBrowserFrameView::PAINT_AS_INACTIVE, |
| 194 frame_view2->paint_state_); | 194 frame_view2->paint_state_); |
| 195 | 195 |
| 196 browser_view1->panel()->Close(); | 196 browser_view1->panel()->Close(); |
| 197 browser_view2->panel()->Close(); | 197 browser_view2->panel()->Close(); |
| 198 } | 198 } |
| 199 | 199 |
| 200 // We put all the testing logic in this class instead of the test so that | 200 // We put all the testing logic in this class instead of the test so that |
| 201 // we do not need to declare each new test as a friend of PanelBrowserView | 201 // we do not need to declare each new test as a friend of PanelBrowserView |
| 202 // for the purpose of accessing its private members. | 202 // for the purpose of accessing its private members. |
| 203 void TestMinimizeAndRestore() { | 203 void TestMinimizeAndRestore(int auto_hide_bottom_bar_height) { |
| 204 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 205 |
| 206 // Specify the work area for testing purpose. |
| 207 const int kTestWorkAreaWidth = 800; |
| 208 const int kTestWorkAreaHeight = 600; |
| 209 panel_manager->SetWorkArea( |
| 210 gfx::Rect(0, 0, kTestWorkAreaWidth, kTestWorkAreaHeight), |
| 211 auto_hide_bottom_bar_height); |
| 212 panel_manager->should_check_auto_hide_bottom_bar_on_titlebar_change_ = |
| 213 false; |
| 214 int expected_bottom_on_unminimized = |
| 215 kTestWorkAreaHeight - auto_hide_bottom_bar_height; |
| 216 int expected_bottom_on_minimized = kTestWorkAreaHeight; |
| 217 |
| 218 // Create and test one panel first. |
| 204 PanelBrowserView* browser_view1 = CreatePanelBrowserView("PanelTest1", | 219 PanelBrowserView* browser_view1 = CreatePanelBrowserView("PanelTest1", |
| 205 SHOW_AS_ACTIVE); | 220 SHOW_AS_ACTIVE); |
| 206 Panel* panel1 = browser_view1->panel_.get(); | 221 Panel* panel1 = browser_view1->panel_.get(); |
| 207 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView(); | 222 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView(); |
| 208 | 223 |
| 209 // Test minimizing/restoring an individual panel. | 224 // Test minimizing/restoring an individual panel. |
| 210 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); | 225 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); |
| 211 int initial_height = panel1->GetBounds().height(); | 226 int initial_height = panel1->GetBounds().height(); |
| 212 int titlebar_height = | 227 int titlebar_height = |
| 213 browser_view1->GetFrameView()->NonClientTopBorderHeight(); | 228 browser_view1->GetFrameView()->NonClientTopBorderHeight(); |
| 214 | 229 |
| 215 panel1->SetExpansionState(Panel::MINIMIZED); | 230 panel1->SetExpansionState(Panel::MINIMIZED); |
| 216 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 231 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
| 217 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); | 232 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); |
| 218 EXPECT_GT(panel1->GetBounds().height(), 0); | 233 EXPECT_GT(panel1->GetBounds().height(), 0); |
| 234 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); |
| 219 EXPECT_TRUE(IsMouseWatcherStarted()); | 235 EXPECT_TRUE(IsMouseWatcherStarted()); |
| 220 EXPECT_FALSE(panel1->IsActive()); | 236 EXPECT_FALSE(panel1->IsActive()); |
| 221 WaitTillBoundsAnimationFinished(browser_view1); | 237 WaitTillBoundsAnimationFinished(browser_view1); |
| 222 // TODO(jianli): Enable the following checks after the patch to support | 238 // TODO(jianli): Enable the following checks after the patch to support |
| 223 // minimizing window to 3-pixel line is landed. | 239 // minimizing window to 3-pixel line is landed. |
| 224 //EXPECT_FALSE(frame_view1->close_button_->IsVisible()); | 240 //EXPECT_FALSE(frame_view1->close_button_->IsVisible()); |
| 225 //EXPECT_FALSE(frame_view1->title_icon_->IsVisible()); | 241 //EXPECT_FALSE(frame_view1->title_icon_->IsVisible()); |
| 226 //EXPECT_FALSE(frame_view1->title_label_->IsVisible()); | 242 //EXPECT_FALSE(frame_view1->title_label_->IsVisible()); |
| 227 | 243 |
| 228 panel1->SetExpansionState(Panel::TITLE_ONLY); | 244 panel1->SetExpansionState(Panel::TITLE_ONLY); |
| 229 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); | 245 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
| 230 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); | 246 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); |
| 247 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); |
| 231 WaitTillBoundsAnimationFinished(browser_view1); | 248 WaitTillBoundsAnimationFinished(browser_view1); |
| 232 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); | 249 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); |
| 233 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); | 250 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); |
| 234 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); | 251 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); |
| 235 | 252 |
| 236 panel1->SetExpansionState(Panel::EXPANDED); | 253 panel1->SetExpansionState(Panel::EXPANDED); |
| 237 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); | 254 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); |
| 238 EXPECT_EQ(initial_height, panel1->GetBounds().height()); | 255 EXPECT_EQ(initial_height, panel1->GetBounds().height()); |
| 256 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); |
| 239 WaitTillBoundsAnimationFinished(browser_view1); | 257 WaitTillBoundsAnimationFinished(browser_view1); |
| 240 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); | 258 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); |
| 241 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); | 259 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); |
| 242 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); | 260 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); |
| 243 | 261 |
| 244 panel1->SetExpansionState(Panel::TITLE_ONLY); | 262 panel1->SetExpansionState(Panel::TITLE_ONLY); |
| 245 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); | 263 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
| 246 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); | 264 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); |
| 265 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); |
| 247 | 266 |
| 248 panel1->SetExpansionState(Panel::MINIMIZED); | 267 panel1->SetExpansionState(Panel::MINIMIZED); |
| 249 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 268 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
| 250 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); | 269 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); |
| 251 EXPECT_GT(panel1->GetBounds().height(), 0); | 270 EXPECT_GT(panel1->GetBounds().height(), 0); |
| 271 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); |
| 252 | 272 |
| 253 // Create 2 more panels for more testing. | 273 // Create 2 more panels for more testing. |
| 254 PanelBrowserView* browser_view2 = CreatePanelBrowserView("PanelTest2", | 274 PanelBrowserView* browser_view2 = CreatePanelBrowserView("PanelTest2", |
| 255 SHOW_AS_ACTIVE); | 275 SHOW_AS_ACTIVE); |
| 256 Panel* panel2 = browser_view2->panel_.get(); | 276 Panel* panel2 = browser_view2->panel_.get(); |
| 257 | 277 |
| 258 PanelBrowserView* browser_view3 = CreatePanelBrowserView("PanelTest3", | 278 PanelBrowserView* browser_view3 = CreatePanelBrowserView("PanelTest3", |
| 259 SHOW_AS_ACTIVE); | 279 SHOW_AS_ACTIVE); |
| 260 Panel* panel3 = browser_view3->panel_.get(); | 280 Panel* panel3 = browser_view3->panel_.get(); |
| 261 | 281 |
| 262 // Test bringing up or down the title-bar of all minimized panels. | 282 // Test bringing up or down the title-bar of all minimized panels. |
| 263 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); | 283 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); |
| 264 panel3->SetExpansionState(Panel::MINIMIZED); | 284 panel3->SetExpansionState(Panel::MINIMIZED); |
| 265 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); | 285 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); |
| 266 | 286 |
| 267 PanelManager* panel_manager = PanelManager::GetInstance(); | 287 panel_manager->BringUpTitleBar(); |
| 268 | |
| 269 panel_manager->BringUpOrDownTitleBarForAllMinimizedPanels(true); | |
| 270 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); | 288 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
| 271 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); | 289 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); |
| 272 EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state()); | 290 EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state()); |
| 273 | 291 |
| 274 panel_manager->BringUpOrDownTitleBarForAllMinimizedPanels(false); | 292 panel_manager->BringDownTitleBar(); |
| 275 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 293 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
| 276 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); | 294 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); |
| 277 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); | 295 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); |
| 278 | 296 |
| 279 // Test if it is OK to bring up title-bar given the mouse position. | 297 // Test if it is OK to bring up title-bar given the mouse position. |
| 280 EXPECT_TRUE(panel_manager->ShouldBringUpTitleBarForAllMinimizedPanels( | 298 EXPECT_TRUE(panel_manager->ShouldBringUpTitleBarForAllMinimizedPanels( |
| 281 panel1->GetBounds().x(), panel1->GetBounds().y())); | 299 panel1->GetBounds().x(), panel1->GetBounds().y())); |
| 282 EXPECT_FALSE(panel_manager->ShouldBringUpTitleBarForAllMinimizedPanels( | 300 EXPECT_FALSE(panel_manager->ShouldBringUpTitleBarForAllMinimizedPanels( |
| 283 panel2->GetBounds().x(), panel2->GetBounds().y())); | 301 panel2->GetBounds().x(), panel2->GetBounds().y())); |
| 284 EXPECT_TRUE(panel_manager->ShouldBringUpTitleBarForAllMinimizedPanels( | 302 EXPECT_TRUE(panel_manager->ShouldBringUpTitleBarForAllMinimizedPanels( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 MessageLoop::current()->RunAllPending(); | 353 MessageLoop::current()->RunAllPending(); |
| 336 EXPECT_EQ(attention_color, frame_view->title_label_->GetColor()); | 354 EXPECT_EQ(attention_color, frame_view->title_label_->GetColor()); |
| 337 | 355 |
| 338 // Test that we cannot bring up other minimized panel if the mouse is over | 356 // Test that we cannot bring up other minimized panel if the mouse is over |
| 339 // the panel that draws attension. | 357 // the panel that draws attension. |
| 340 EXPECT_FALSE(PanelManager::GetInstance()-> | 358 EXPECT_FALSE(PanelManager::GetInstance()-> |
| 341 ShouldBringUpTitleBarForAllMinimizedPanels( | 359 ShouldBringUpTitleBarForAllMinimizedPanels( |
| 342 panel->GetBounds().x(), panel->GetBounds().y())); | 360 panel->GetBounds().x(), panel->GetBounds().y())); |
| 343 | 361 |
| 344 // Test that we cannot bring down the panel that is drawing the attention. | 362 // Test that we cannot bring down the panel that is drawing the attention. |
| 345 PanelManager::GetInstance()->BringUpOrDownTitleBarForAllMinimizedPanels( | 363 PanelManager::GetInstance()->BringDownTitleBar(); |
| 346 false); | |
| 347 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | 364 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
| 348 | 365 |
| 349 // Test that the attention is cleared. | 366 // Test that the attention is cleared. |
| 350 browser_view->StopDrawingAttention(); | 367 browser_view->StopDrawingAttention(); |
| 351 EXPECT_FALSE(browser_view->IsDrawingAttention()); | 368 EXPECT_FALSE(browser_view->IsDrawingAttention()); |
| 352 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 369 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
| 353 MessageLoop::current()->RunAllPending(); | 370 MessageLoop::current()->RunAllPending(); |
| 354 EXPECT_NE(attention_color, frame_view->title_label_->GetColor()); | 371 EXPECT_NE(attention_color, frame_view->title_label_->GetColor()); |
| 355 | 372 |
| 356 panel->Close(); | 373 panel->Close(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 497 |
| 481 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreateSettingsMenu) { | 498 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreateSettingsMenu) { |
| 482 TestCreateSettingsMenuForExtension( | 499 TestCreateSettingsMenuForExtension( |
| 483 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, | 500 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, |
| 484 "", ""); | 501 "", ""); |
| 485 TestCreateSettingsMenuForExtension( | 502 TestCreateSettingsMenuForExtension( |
| 486 FILE_PATH_LITERAL("extension2"), Extension::INVALID, | 503 FILE_PATH_LITERAL("extension2"), Extension::INVALID, |
| 487 "http://home", "options.html"); | 504 "http://home", "options.html"); |
| 488 } | 505 } |
| 489 | 506 |
| 490 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, MinimizeAndRestore) { | 507 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, |
| 491 TestMinimizeAndRestore(); | 508 MinimizeAndRestoreOnNormalTaskBar) { |
| 509 // Test that the taskbar is always visible. |
| 510 TestMinimizeAndRestore(0); |
| 511 } |
| 512 |
| 513 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, |
| 514 MinimizeAndRestoreOnAutoHideTaskBar) { |
| 515 // Test that the taskbar is in auto-hide mode. |
| 516 TestMinimizeAndRestore(40); |
| 492 } | 517 } |
| 493 | 518 |
| 494 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DrawAttention) { | 519 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DrawAttention) { |
| 495 TestDrawAttention(); | 520 TestDrawAttention(); |
| 496 } | 521 } |
| 497 #endif | 522 #endif |
| OLD | NEW |