| 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/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" |
| 11 #include "chrome/browser/ui/panels/panel.h" | 11 #include "chrome/browser/ui/panels/panel.h" |
| 12 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 12 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
| 13 #include "chrome/browser/ui/panels/panel_browser_view.h" | 13 #include "chrome/browser/ui/panels/panel_browser_view.h" |
| 14 #include "chrome/browser/ui/panels/panel_manager.h" | 14 #include "chrome/browser/ui/panels/panel_manager.h" |
| 15 #include "chrome/browser/ui/panels/panel_mouse_watcher_win.h" | 15 #include "chrome/browser/ui/panels/panel_mouse_watcher_win.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 16 #include "chrome/browser/web_applications/web_app.h" | 17 #include "chrome/browser/web_applications/web_app.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" |
| 19 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 22 #include "net/base/net_util.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/base/animation/slide_animation.h" | 25 #include "ui/base/animation/slide_animation.h" |
| 23 #include "views/controls/button/image_button.h" | 26 #include "views/controls/button/image_button.h" |
| 24 #include "views/controls/button/menu_button.h" | 27 #include "views/controls/button/menu_button.h" |
| 25 #include "views/controls/image_view.h" | 28 #include "views/controls/image_view.h" |
| 26 #include "views/controls/label.h" | 29 #include "views/controls/label.h" |
| 27 #include "views/controls/link.h" | 30 #include "views/controls/link.h" |
| 28 #include "views/controls/textfield/textfield.h" | 31 #include "views/controls/textfield/textfield.h" |
| 29 | 32 |
| 33 const FilePath::CharType* kUpdateSizeTestFile = |
| 34 FILE_PATH_LITERAL("update-preferred-size.html"); |
| 35 |
| 30 class PanelBrowserViewTest : public BasePanelBrowserTest { | 36 class PanelBrowserViewTest : public BasePanelBrowserTest { |
| 31 public: | 37 public: |
| 32 PanelBrowserViewTest() : BasePanelBrowserTest() { } | 38 PanelBrowserViewTest() : BasePanelBrowserTest() { } |
| 33 | 39 |
| 34 protected: | 40 protected: |
| 35 struct MenuItem { | 41 struct MenuItem { |
| 36 int id; | 42 int id; |
| 37 bool enabled; | 43 bool enabled; |
| 38 }; | 44 }; |
| 39 | 45 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 mock_auto_hiding_desktop_bar()->SetThickness( | 385 mock_auto_hiding_desktop_bar()->SetThickness( |
| 380 AutoHidingDesktopBar::ALIGN_RIGHT, right_bar_thickness); | 386 AutoHidingDesktopBar::ALIGN_RIGHT, right_bar_thickness); |
| 381 MessageLoop::current()->RunAllPending(); | 387 MessageLoop::current()->RunAllPending(); |
| 382 EXPECT_EQ(testing_work_area().height() - bottom_bar_thickness, | 388 EXPECT_EQ(testing_work_area().height() - bottom_bar_thickness, |
| 383 panel->GetBounds().bottom()); | 389 panel->GetBounds().bottom()); |
| 384 EXPECT_EQ(testing_work_area().right() - right_bar_thickness, | 390 EXPECT_EQ(testing_work_area().right() - right_bar_thickness, |
| 385 panel->GetBounds().right()); | 391 panel->GetBounds().right()); |
| 386 | 392 |
| 387 panel->Close(); | 393 panel->Close(); |
| 388 } | 394 } |
| 395 |
| 396 void TestUpdatePreferredSize() { |
| 397 PanelManager::GetInstance()->enable_auto_sizing(true); |
| 398 |
| 399 // Create a test panel with tab contents loaded. |
| 400 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 100, 100), |
| 401 SHOW_AS_ACTIVE); |
| 402 params.url = GURL(chrome::kAboutBlankURL); |
| 403 Panel* panel = CreatePanelWithParams(params); |
| 404 |
| 405 // Load the test page. |
| 406 ui_test_utils::NavigateToURL(panel->browser(), |
| 407 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 408 FilePath(kUpdateSizeTestFile))); |
| 409 gfx::Rect initial_bounds = panel->GetBounds(); |
| 410 EXPECT_EQ(100, initial_bounds.width()); |
| 411 EXPECT_EQ(100, initial_bounds.height()); |
| 412 |
| 413 // Expand the test page. |
| 414 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( |
| 415 panel->browser()->GetSelectedTabContents()->render_view_host(), |
| 416 std::wstring(), |
| 417 L"changeSize(50);")); |
| 418 |
| 419 // Wait till the bounds get changed. |
| 420 gfx::Rect bounds_on_grow; |
| 421 while ((bounds_on_grow = panel->GetBounds()) == initial_bounds) { |
| 422 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 423 MessageLoop::current()->RunAllPending(); |
| 424 } |
| 425 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); |
| 426 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height()); |
| 427 |
| 428 // Shrink the test page. |
| 429 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( |
| 430 panel->browser()->GetSelectedTabContents()->render_view_host(), |
| 431 std::wstring(), |
| 432 L"changeSize(-30);")); |
| 433 |
| 434 // Wait till the bounds get changed. |
| 435 gfx::Rect bounds_on_shrink; |
| 436 while ((bounds_on_shrink = panel->GetBounds()) == bounds_on_grow) { |
| 437 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 438 MessageLoop::current()->RunAllPending(); |
| 439 } |
| 440 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); |
| 441 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); |
| 442 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); |
| 443 |
| 444 panel->Close(); |
| 445 } |
| 389 }; | 446 }; |
| 390 | 447 |
| 391 // Panel is not supported for Linux view yet. | 448 // Panel is not supported for Linux view yet. |
| 392 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) | 449 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) |
| 393 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { | 450 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { |
| 394 Panel* panel = CreatePanel("PanelTest"); | 451 Panel* panel = CreatePanel("PanelTest"); |
| 395 PanelBrowserView* browser_view = GetBrowserView(panel); | 452 PanelBrowserView* browser_view = GetBrowserView(panel); |
| 396 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 453 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
| 397 | 454 |
| 398 // The bounds animation should not be triggered when the panel is up for the | 455 // The bounds animation should not be triggered when the panel is up for the |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 TestMinimizeAndRestore(true); | 584 TestMinimizeAndRestore(true); |
| 528 } | 585 } |
| 529 | 586 |
| 530 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DrawAttention) { | 587 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DrawAttention) { |
| 531 TestDrawAttention(); | 588 TestDrawAttention(); |
| 532 } | 589 } |
| 533 | 590 |
| 534 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ChangeAutoHideTaskBarThickness) { | 591 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ChangeAutoHideTaskBarThickness) { |
| 535 TestChangeAutoHideTaskBarThickness(); | 592 TestChangeAutoHideTaskBarThickness(); |
| 536 } | 593 } |
| 594 |
| 595 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, UpdatePreferredSize) { |
| 596 TestUpdatePreferredSize(); |
| 597 } |
| 537 #endif | 598 #endif |
| OLD | NEW |