OLD | NEW |
(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/i18n/time_formatting.h" |
| 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
| 11 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
| 12 #include "chrome/browser/ui/panels/panel.h" |
| 13 #include "chrome/browser/ui/panels/panel_bounds_animation.h" |
| 14 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
| 15 #include "chrome/browser/ui/panels/panel_browser_view.h" |
| 16 #include "chrome/browser/ui/panels/panel_manager.h" |
| 17 #include "chrome/browser/web_applications/web_app.h" |
| 18 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/test/base/ui_test_utils.h" |
| 22 #include "grit/generated_resources.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "ui/base/animation/linear_animation.h" |
| 25 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/views/controls/button/image_button.h" |
| 27 #include "ui/views/controls/button/menu_button.h" |
| 28 #include "ui/views/controls/image_view.h" |
| 29 #include "ui/views/controls/label.h" |
| 30 #include "ui/views/controls/link.h" |
| 31 #include "ui/views/controls/textfield/textfield.h" |
| 32 |
| 33 class PanelBrowserViewTest : public BasePanelBrowserTest { |
| 34 public: |
| 35 PanelBrowserViewTest() : BasePanelBrowserTest() { } |
| 36 |
| 37 protected: |
| 38 PanelBrowserView* GetBrowserView(Panel* panel) const { |
| 39 return static_cast<PanelBrowserView*>(panel->native_panel()); |
| 40 } |
| 41 |
| 42 gfx::Rect GetViewBounds(Panel* panel) const { |
| 43 return GetBrowserView(panel)->GetBounds(); |
| 44 } |
| 45 |
| 46 void SetViewBounds(Panel* panel, const gfx::Rect& rect) const { |
| 47 return GetBrowserView(panel)->SetPanelBounds(rect); |
| 48 } |
| 49 |
| 50 gfx::NativeWindow GetNativeWindow(Panel* panel) const { |
| 51 return GetBrowserView(panel)->GetNativeWindow(); |
| 52 } |
| 53 |
| 54 PanelBoundsAnimation* GetBoundsAnimator(Panel* panel) const { |
| 55 return GetBrowserView(panel)->bounds_animator_.get(); |
| 56 } |
| 57 |
| 58 int GetTitlebarHeight(Panel* panel) const { |
| 59 PanelBrowserFrameView* frame_view = GetBrowserView(panel)->GetFrameView(); |
| 60 return frame_view->NonClientTopBorderHeight() - |
| 61 frame_view->NonClientBorderThickness(); |
| 62 } |
| 63 |
| 64 PanelBrowserFrameView::PaintState GetTitlebarPaintState(Panel* panel) const { |
| 65 return GetBrowserView(panel)->GetFrameView()->paint_state_; |
| 66 } |
| 67 |
| 68 bool IsTitlebarPaintedAsActive(Panel* panel) const { |
| 69 return GetTitlebarPaintState(panel) == |
| 70 PanelBrowserFrameView::PAINT_AS_ACTIVE; |
| 71 } |
| 72 |
| 73 bool IsTitlebarPaintedAsInactive(Panel* panel) const { |
| 74 return GetTitlebarPaintState(panel) == |
| 75 PanelBrowserFrameView::PAINT_AS_INACTIVE; |
| 76 } |
| 77 |
| 78 bool IsTitlebarPaintedForAttention(Panel* panel) const { |
| 79 return GetTitlebarPaintState(panel) == |
| 80 PanelBrowserFrameView::PAINT_FOR_ATTENTION; |
| 81 } |
| 82 |
| 83 int GetControlCount(Panel* panel) const { |
| 84 return GetBrowserView(panel)->GetFrameView()->child_count(); |
| 85 } |
| 86 |
| 87 TabIconView* GetTitleIcon(Panel* panel) const { |
| 88 return GetBrowserView(panel)->GetFrameView()->title_icon_; |
| 89 } |
| 90 |
| 91 views::Label* GetTitleText(Panel* panel) const { |
| 92 return GetBrowserView(panel)->GetFrameView()->title_label_; |
| 93 } |
| 94 |
| 95 views::Button* GetCloseButton(Panel* panel) const { |
| 96 return GetBrowserView(panel)->GetFrameView()->close_button_; |
| 97 } |
| 98 |
| 99 views::Button* GetMinimizeButton(Panel* panel) const { |
| 100 return GetBrowserView(panel)->GetFrameView()->minimize_button_; |
| 101 } |
| 102 |
| 103 views::Button* GetRestoreButton(Panel* panel) const { |
| 104 return GetBrowserView(panel)->GetFrameView()->restore_button_; |
| 105 } |
| 106 |
| 107 bool ContainsControl(Panel* panel, views::View* control) const { |
| 108 return GetBrowserView(panel)->GetFrameView()->Contains(control); |
| 109 } |
| 110 |
| 111 void WaitTillBoundsAnimationFinished(Panel* panel) { |
| 112 // The timer for the animation will only kick in as async task. |
| 113 while (GetBoundsAnimator(panel)->is_animating()) { |
| 114 MessageLoopForUI::current()->PostTask(FROM_HERE, |
| 115 MessageLoop::QuitClosure()); |
| 116 MessageLoopForUI::current()->RunAllPending(); |
| 117 } |
| 118 } |
| 119 |
| 120 void ClosePanelAndWaitForNotification(Panel* panel) { |
| 121 ui_test_utils::WindowedNotificationObserver signal( |
| 122 chrome::NOTIFICATION_PANEL_CLOSED, |
| 123 content::Source<Panel>(panel)); |
| 124 panel->Close(); |
| 125 signal.Wait(); |
| 126 } |
| 127 |
| 128 // We put all the testing logic in this class instead of the test so that |
| 129 // we do not need to declare each new test as a friend of PanelBrowserView |
| 130 // for the purpose of accessing its private members. |
| 131 void TestMinimizeAndRestore(bool enable_auto_hiding) { |
| 132 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 133 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
| 134 int expected_bottom_on_expanded = docked_strip->display_area().bottom(); |
| 135 int expected_bottom_on_title_only = expected_bottom_on_expanded; |
| 136 int expected_bottom_on_minimized = expected_bottom_on_expanded; |
| 137 |
| 138 // Turn on auto-hiding if requested. |
| 139 static const int bottom_thickness = 40; |
| 140 mock_display_settings_provider()->EnableAutoHidingDesktopBar( |
| 141 DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_BOTTOM, |
| 142 enable_auto_hiding, |
| 143 bottom_thickness); |
| 144 if (enable_auto_hiding) |
| 145 expected_bottom_on_title_only -= bottom_thickness; |
| 146 |
| 147 // Create and test one panel first. |
| 148 Panel* panel1 = CreatePanel("PanelTest1"); |
| 149 PanelBrowserView* browser_view1 = GetBrowserView(panel1); |
| 150 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView(); |
| 151 |
| 152 // Test minimizing/restoring an individual panel. |
| 153 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); |
| 154 int initial_height = panel1->GetBounds().height(); |
| 155 |
| 156 panel1->SetExpansionState(Panel::MINIMIZED); |
| 157 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
| 158 |
| 159 int titlebar_height = frame_view1->NonClientTopBorderHeight(); |
| 160 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); |
| 161 EXPECT_GT(panel1->GetBounds().height(), 0); |
| 162 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); |
| 163 WaitTillBoundsAnimationFinished(panel1); |
| 164 EXPECT_FALSE(panel1->IsActive()); |
| 165 |
| 166 panel1->SetExpansionState(Panel::TITLE_ONLY); |
| 167 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
| 168 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); |
| 169 EXPECT_EQ(expected_bottom_on_title_only, panel1->GetBounds().bottom()); |
| 170 WaitTillBoundsAnimationFinished(panel1); |
| 171 EXPECT_TRUE(frame_view1->close_button_->visible()); |
| 172 EXPECT_TRUE(frame_view1->title_icon_->visible()); |
| 173 EXPECT_TRUE(frame_view1->title_label_->visible()); |
| 174 |
| 175 panel1->SetExpansionState(Panel::EXPANDED); |
| 176 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); |
| 177 EXPECT_EQ(initial_height, panel1->GetBounds().height()); |
| 178 EXPECT_EQ(expected_bottom_on_expanded, panel1->GetBounds().bottom()); |
| 179 WaitTillBoundsAnimationFinished(panel1); |
| 180 EXPECT_TRUE(frame_view1->close_button_->visible()); |
| 181 EXPECT_TRUE(frame_view1->title_icon_->visible()); |
| 182 EXPECT_TRUE(frame_view1->title_label_->visible()); |
| 183 |
| 184 panel1->SetExpansionState(Panel::MINIMIZED); |
| 185 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
| 186 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); |
| 187 EXPECT_GT(panel1->GetBounds().height(), 0); |
| 188 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); |
| 189 |
| 190 panel1->SetExpansionState(Panel::TITLE_ONLY); |
| 191 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
| 192 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); |
| 193 EXPECT_EQ(expected_bottom_on_title_only, panel1->GetBounds().bottom()); |
| 194 |
| 195 // Create 2 more panels for more testing. |
| 196 Panel* panel2 = CreatePanel("PanelTest2"); |
| 197 Panel* panel3 = CreatePanel("PanelTest3"); |
| 198 |
| 199 // Test bringing up or down the title-bar of all minimized panels. |
| 200 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); |
| 201 panel3->SetExpansionState(Panel::MINIMIZED); |
| 202 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); |
| 203 |
| 204 mock_display_settings_provider()->SetDesktopBarVisibility( |
| 205 DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_BOTTOM, |
| 206 DisplaySettingsProvider::DESKTOP_BAR_VISIBLE); |
| 207 panel_manager->BringUpOrDownTitlebars(true); |
| 208 MessageLoopForUI::current()->RunAllPending(); |
| 209 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
| 210 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); |
| 211 EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state()); |
| 212 |
| 213 mock_display_settings_provider()->SetDesktopBarVisibility( |
| 214 DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_BOTTOM, |
| 215 DisplaySettingsProvider::DESKTOP_BAR_HIDDEN); |
| 216 panel_manager->BringUpOrDownTitlebars(false); |
| 217 MessageLoopForUI::current()->RunAllPending(); |
| 218 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
| 219 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); |
| 220 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); |
| 221 |
| 222 // Test if it is OK to bring up title-bar given the mouse position. |
| 223 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( |
| 224 panel1->GetBounds().x(), panel1->GetBounds().y())); |
| 225 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( |
| 226 panel2->GetBounds().x(), panel2->GetBounds().y())); |
| 227 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( |
| 228 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() - 1)); |
| 229 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( |
| 230 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() + 10)); |
| 231 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( |
| 232 0, 0)); |
| 233 |
| 234 // Test that the panel in title-only state should not be minimized |
| 235 // regardless of the current mouse position when the panel is being dragged. |
| 236 panel1->SetExpansionState(Panel::TITLE_ONLY); |
| 237 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( |
| 238 0, 0)); |
| 239 browser_view1->OnTitlebarMousePressed(panel1->GetBounds().origin()); |
| 240 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
| 241 browser_view1->OnTitlebarMouseDragged( |
| 242 panel1->GetBounds().origin().Subtract(gfx::Point(5, 5))); |
| 243 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
| 244 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( |
| 245 0, 0)); |
| 246 browser_view1->OnTitlebarMouseReleased(panel::NO_MODIFIER); |
| 247 |
| 248 ClosePanelAndWaitForNotification(panel1); |
| 249 ClosePanelAndWaitForNotification(panel2); |
| 250 ClosePanelAndWaitForNotification(panel3); |
| 251 } |
| 252 |
| 253 void TestChangeAutoHideTaskBarThickness() { |
| 254 PanelManager* manager = PanelManager::GetInstance(); |
| 255 DockedPanelStrip* docked_strip = manager->docked_strip(); |
| 256 int initial_starting_right_position = docked_strip->StartingRightPosition(); |
| 257 |
| 258 int bottom_bar_thickness = 20; |
| 259 int right_bar_thickness = 30; |
| 260 mock_display_settings_provider()->EnableAutoHidingDesktopBar( |
| 261 DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_BOTTOM, |
| 262 true, |
| 263 bottom_bar_thickness); |
| 264 mock_display_settings_provider()->EnableAutoHidingDesktopBar( |
| 265 DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_RIGHT, |
| 266 true, |
| 267 right_bar_thickness); |
| 268 EXPECT_EQ( |
| 269 initial_starting_right_position - docked_strip->StartingRightPosition(), |
| 270 right_bar_thickness); |
| 271 |
| 272 Panel* panel = CreatePanel("PanelTest"); |
| 273 panel->SetExpansionState(Panel::TITLE_ONLY); |
| 274 WaitTillBoundsAnimationFinished(panel); |
| 275 |
| 276 EXPECT_EQ(docked_strip->display_area().bottom() - bottom_bar_thickness, |
| 277 panel->GetBounds().bottom()); |
| 278 EXPECT_EQ(docked_strip->StartingRightPosition(), |
| 279 panel->GetBounds().right()); |
| 280 |
| 281 initial_starting_right_position = docked_strip->StartingRightPosition(); |
| 282 int bottom_bar_thickness_delta = 10; |
| 283 bottom_bar_thickness += bottom_bar_thickness_delta; |
| 284 int right_bar_thickness_delta = 15; |
| 285 right_bar_thickness += right_bar_thickness_delta; |
| 286 mock_display_settings_provider()->SetDesktopBarThickness( |
| 287 DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_BOTTOM, |
| 288 bottom_bar_thickness); |
| 289 mock_display_settings_provider()->SetDesktopBarThickness( |
| 290 DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_RIGHT, |
| 291 right_bar_thickness); |
| 292 MessageLoopForUI::current()->RunAllPending(); |
| 293 EXPECT_EQ( |
| 294 initial_starting_right_position - docked_strip->StartingRightPosition(), |
| 295 right_bar_thickness_delta); |
| 296 EXPECT_EQ(docked_strip->display_area().bottom() - bottom_bar_thickness, |
| 297 panel->GetBounds().bottom()); |
| 298 EXPECT_EQ(docked_strip->StartingRightPosition(), |
| 299 panel->GetBounds().right()); |
| 300 |
| 301 initial_starting_right_position = docked_strip->StartingRightPosition(); |
| 302 bottom_bar_thickness_delta = 20; |
| 303 bottom_bar_thickness -= bottom_bar_thickness_delta; |
| 304 right_bar_thickness_delta = 10; |
| 305 right_bar_thickness -= right_bar_thickness_delta; |
| 306 mock_display_settings_provider()->SetDesktopBarThickness( |
| 307 DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_BOTTOM, |
| 308 bottom_bar_thickness); |
| 309 mock_display_settings_provider()->SetDesktopBarThickness( |
| 310 DisplaySettingsProvider::DESKTOP_BAR_ALIGNED_RIGHT, |
| 311 right_bar_thickness); |
| 312 MessageLoopForUI::current()->RunAllPending(); |
| 313 EXPECT_EQ( |
| 314 docked_strip->StartingRightPosition() - initial_starting_right_position, |
| 315 right_bar_thickness_delta); |
| 316 EXPECT_EQ(docked_strip->display_area().bottom() - bottom_bar_thickness, |
| 317 panel->GetBounds().bottom()); |
| 318 EXPECT_EQ(docked_strip->StartingRightPosition(), |
| 319 panel->GetBounds().right()); |
| 320 |
| 321 panel->Close(); |
| 322 } |
| 323 }; |
| 324 |
| 325 // Panel is not supported for Linux view yet. |
| 326 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) |
| 327 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanelBasic) { |
| 328 CreatePanelParams params( |
| 329 "PanelTest", gfx::Rect(0, 0, 200, 150), SHOW_AS_ACTIVE); |
| 330 Panel* panel = CreatePanelWithParams(params); |
| 331 |
| 332 // Validate basic window properties. |
| 333 #if defined(OS_WIN) && !defined(USE_AURA) |
| 334 HWND native_window = GetNativeWindow(panel); |
| 335 |
| 336 RECT window_rect; |
| 337 EXPECT_TRUE(::GetWindowRect(native_window, &window_rect)); |
| 338 EXPECT_EQ(200, window_rect.right - window_rect.left); |
| 339 EXPECT_EQ(150, window_rect.bottom - window_rect.top); |
| 340 |
| 341 EXPECT_TRUE(::IsWindowVisible(native_window)); |
| 342 #endif |
| 343 |
| 344 panel->Close(); |
| 345 } |
| 346 |
| 347 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanelActive) { |
| 348 CreatePanelParams params("PanelTest", gfx::Rect(), SHOW_AS_ACTIVE); |
| 349 Panel* panel = CreatePanelWithParams(params); |
| 350 |
| 351 // Validate it is active. |
| 352 EXPECT_TRUE(panel->IsActive()); |
| 353 EXPECT_TRUE(IsTitlebarPaintedAsActive(panel)); |
| 354 |
| 355 // Validate window styles. We want to ensure that the window is created |
| 356 // with expected styles regardless of its active state. |
| 357 #if defined(OS_WIN) && !defined(USE_AURA) |
| 358 HWND native_window = GetNativeWindow(panel); |
| 359 |
| 360 LONG styles = ::GetWindowLong(native_window, GWL_STYLE); |
| 361 EXPECT_EQ(0, styles & WS_MAXIMIZEBOX); |
| 362 EXPECT_EQ(0, styles & WS_MINIMIZEBOX); |
| 363 |
| 364 LONG ext_styles = ::GetWindowLong(native_window, GWL_EXSTYLE); |
| 365 EXPECT_EQ(WS_EX_TOPMOST, ext_styles & WS_EX_TOPMOST); |
| 366 #endif |
| 367 |
| 368 panel->Close(); |
| 369 } |
| 370 |
| 371 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanelInactive) { |
| 372 CreatePanelParams params("PanelTest", gfx::Rect(), SHOW_AS_INACTIVE); |
| 373 Panel* panel = CreatePanelWithParams(params); |
| 374 |
| 375 // Validate it is inactive. |
| 376 EXPECT_FALSE(panel->IsActive()); |
| 377 EXPECT_FALSE(IsTitlebarPaintedAsActive(panel)); |
| 378 |
| 379 // Validate window styles. We want to ensure that the window is created |
| 380 // with expected styles regardless of its active state. |
| 381 #if defined(OS_WIN) && !defined(USE_AURA) |
| 382 HWND native_window = GetNativeWindow(panel); |
| 383 |
| 384 LONG styles = ::GetWindowLong(native_window, GWL_STYLE); |
| 385 EXPECT_EQ(0, styles & WS_MAXIMIZEBOX); |
| 386 EXPECT_EQ(0, styles & WS_MINIMIZEBOX); |
| 387 |
| 388 LONG ext_styles = ::GetWindowLong(native_window, GWL_EXSTYLE); |
| 389 EXPECT_EQ(WS_EX_TOPMOST, ext_styles & WS_EX_TOPMOST); |
| 390 #endif |
| 391 |
| 392 panel->Close(); |
| 393 } |
| 394 |
| 395 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, PanelLayout) { |
| 396 // Create a fixed-size panel to avoid possible collapsing of the title |
| 397 // if the enforced min sizes are too small. |
| 398 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 200, 50)); |
| 399 |
| 400 views::View* title_icon = GetTitleIcon(panel); |
| 401 views::View* title_text = GetTitleText(panel); |
| 402 views::View* close_button = GetCloseButton(panel); |
| 403 views::View* minimize_button = GetMinimizeButton(panel); |
| 404 views::View* restore_button = GetRestoreButton(panel); |
| 405 |
| 406 // We should have icon, text, minimize, restore and close buttons. Only one of |
| 407 // minimize and restore buttons are visible. |
| 408 EXPECT_EQ(5, GetControlCount(panel)); |
| 409 EXPECT_TRUE(ContainsControl(panel, title_icon)); |
| 410 EXPECT_TRUE(ContainsControl(panel, title_text)); |
| 411 EXPECT_TRUE(ContainsControl(panel, close_button)); |
| 412 EXPECT_TRUE(ContainsControl(panel, minimize_button)); |
| 413 EXPECT_TRUE(ContainsControl(panel, restore_button)); |
| 414 |
| 415 // These controls should be visible. |
| 416 EXPECT_TRUE(title_icon->visible()); |
| 417 EXPECT_TRUE(title_text->visible()); |
| 418 EXPECT_TRUE(close_button->visible()); |
| 419 EXPECT_TRUE(minimize_button->visible()); |
| 420 EXPECT_FALSE(restore_button->visible()); |
| 421 |
| 422 // Validate their layouts. |
| 423 int titlebar_height = GetTitlebarHeight(panel); |
| 424 EXPECT_GT(title_icon->width(), 0); |
| 425 EXPECT_GT(title_icon->height(), 0); |
| 426 EXPECT_LT(title_icon->height(), titlebar_height); |
| 427 EXPECT_GT(title_text->width(), 0); |
| 428 EXPECT_GT(title_text->height(), 0); |
| 429 EXPECT_LT(title_text->height(), titlebar_height); |
| 430 EXPECT_GT(minimize_button->width(), 0); |
| 431 EXPECT_GT(minimize_button->height(), 0); |
| 432 EXPECT_LT(minimize_button->height(), titlebar_height); |
| 433 EXPECT_GT(close_button->width(), 0); |
| 434 EXPECT_GT(close_button->height(), 0); |
| 435 EXPECT_LT(close_button->height(), titlebar_height); |
| 436 EXPECT_LT(title_icon->x() + title_icon->width(), title_text->x()); |
| 437 EXPECT_LT(title_text->x() + title_text->width(), minimize_button->x()); |
| 438 EXPECT_LT(minimize_button->x() + minimize_button->width(), close_button->x()); |
| 439 } |
| 440 |
| 441 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, SetBoundsAnimation) { |
| 442 Panel* panel = CreatePanel("PanelTest"); |
| 443 PanelBrowserView* browser_view = GetBrowserView(panel); |
| 444 |
| 445 // The bounds animation should not be triggered when the panel is up for the |
| 446 // first time. |
| 447 EXPECT_FALSE(GetBoundsAnimator(panel)); |
| 448 |
| 449 // Validate that animation should be triggered when bounds are changed. |
| 450 gfx::Rect target_bounds(GetViewBounds(panel)); |
| 451 target_bounds.Offset(20, -30); |
| 452 target_bounds.set_width(target_bounds.width() + 100); |
| 453 target_bounds.set_height(target_bounds.height() + 50); |
| 454 SetViewBounds(panel, target_bounds); |
| 455 ASSERT_TRUE(GetBoundsAnimator(panel)); |
| 456 EXPECT_TRUE(GetBoundsAnimator(panel)->is_animating()); |
| 457 EXPECT_NE(GetViewBounds(panel), target_bounds); |
| 458 WaitTillBoundsAnimationFinished(panel); |
| 459 EXPECT_EQ(GetViewBounds(panel), target_bounds); |
| 460 |
| 461 // Validates that no animation should be triggered for the panel currently |
| 462 // being dragged. |
| 463 browser_view->OnTitlebarMousePressed(gfx::Point( |
| 464 target_bounds.x(), target_bounds.y())); |
| 465 browser_view->OnTitlebarMouseDragged(gfx::Point( |
| 466 target_bounds.x() + 5, target_bounds.y() + 5)); |
| 467 EXPECT_FALSE(GetBoundsAnimator(panel)->is_animating()); |
| 468 browser_view->OnTitlebarMouseCaptureLost(); |
| 469 |
| 470 panel->Close(); |
| 471 } |
| 472 |
| 473 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, |
| 474 MinimizeAndRestoreOnNormalTaskBar) { |
| 475 TestMinimizeAndRestore(false); |
| 476 } |
| 477 |
| 478 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, |
| 479 MinimizeAndRestoreOnAutoHideTaskBar) { |
| 480 TestMinimizeAndRestore(true); |
| 481 } |
| 482 |
| 483 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, |
| 484 ChangeAutoHideTaskBarThickness) { |
| 485 TestChangeAutoHideTaskBarThickness(); |
| 486 } |
| 487 #endif |
OLD | NEW |