Commit 3827b1a0 authored by jianli@chromium.org's avatar jianli@chromium.org

Fix a couple panel overflow related bugs.

1) Moving mouse to left screen edge causes the expanded overflow panels to shrink back.
2) Overflow panel is brought to normal area cannot be dragged correctly.

BUG=106434
TEST=Enable overflow test plus manual test by moving mouse to left screen edge or clicking on overflow panel

Review URL: http://codereview.chromium.org/8802021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113053 0039d316-1c4b-4281-b951-d872f2087c98
parent 55e973d0
......@@ -254,6 +254,17 @@ void BasePanelBrowserTest::WaitForBoundsAnimationFinished(Panel* panel) {
EXPECT_TRUE(!panel_testing->IsAnimatingBounds());
}
void BasePanelBrowserTest::WaitForExpansionStateChanged(
Panel* panel, Panel::ExpansionState expansion_state) {
ui_test_utils::WindowedNotificationObserver signal(
chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE,
content::Source<Panel>(panel));
if (panel->expansion_state() == expansion_state)
return;
signal.Wait();
EXPECT_EQ(expansion_state, panel->expansion_state());
}
Panel* BasePanelBrowserTest::CreatePanelWithParams(
const CreatePanelParams& params) {
#if defined(OS_MACOSX)
......
......@@ -10,12 +10,11 @@
#include "base/values.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "ui/gfx/rect.h"
class Panel;
class BasePanelBrowserTest : public InProcessBrowserTest {
public:
class MockAutoHidingDesktopBar : public AutoHidingDesktopBar {
......@@ -63,6 +62,8 @@ class BasePanelBrowserTest : public InProcessBrowserTest {
void WaitForPanelActiveState(Panel* panel, ActiveState state);
void WaitForWindowSizeAvailable(Panel* panel);
void WaitForBoundsAnimationFinished(Panel* panel);
void WaitForExpansionStateChanged(Panel* panel,
Panel::ExpansionState expansion_state);
void CreateTestTabContents(Browser* browser);
......
......@@ -115,23 +115,27 @@ class PanelBrowserTest : public BasePanelBrowserTest {
EXPECT_EQ(0, panel_overflow_strip->num_panels());
// Open a panel that would overflow.
Panel* panel4 = CreatePanelWithBounds(
CreatePanelParams params4(
web_app::GenerateApplicationNameFromExtensionId(extension2->id()),
gfx::Rect(0, 0, 280, 200));
gfx::Rect(0, 0, 280, 200),
SHOW_AS_INACTIVE);
Panel* panel4 = CreatePanelWithParams(params4);
WaitForExpansionStateChanged(panel4, Panel::IN_OVERFLOW);
ASSERT_EQ(4, panel_manager->num_panels());
EXPECT_EQ(3, panel_strip->num_panels());
EXPECT_EQ(1, panel_overflow_strip->num_panels());
EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
// Open another panel that would overflow.
Panel* panel5 = CreatePanelWithBounds(
CreatePanelParams params5(
web_app::GenerateApplicationNameFromExtensionId(extension3->id()),
gfx::Rect(0, 0, 300, 200));
gfx::Rect(0, 0, 300, 200),
SHOW_AS_INACTIVE);
Panel* panel5 = CreatePanelWithParams(params5);
WaitForExpansionStateChanged(panel5, Panel::IN_OVERFLOW);
ASSERT_EQ(5, panel_manager->num_panels());
EXPECT_EQ(3, panel_strip->num_panels());
EXPECT_EQ(2, panel_overflow_strip->num_panels());
EXPECT_EQ(Panel::IN_OVERFLOW, panel4->expansion_state());
EXPECT_EQ(Panel::IN_OVERFLOW, panel5->expansion_state());
// Close a visible panel. Expect an overflow panel to move over.
CloseWindowAndWait(panel2->browser());
......@@ -546,7 +550,14 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FindBar) {
panel->Close();
}
IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_CreatePanelOnOverflow) {
// TODO(jianli): remove the guard when overflow support is enabled on other
// platforms. http://crbug.com/105073
#if defined(OS_WIN)
#define MAYBE_CreatePanelOnOverflow CreatePanelOnOverflow
#else
#define MAYBE_CreatePanelOnOverflow DISABLED_CreatePanelOnOverflow
#endif
IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_CreatePanelOnOverflow) {
TestCreatePanelOnOverflow();
}
......@@ -847,7 +858,8 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateSettingsMenu) {
"http://home", "options.html");
}
IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AutoResize) {
// Flaky: http://crbug.com/105445
IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FLAKY_AutoResize) {
PanelManager::GetInstance()->enable_auto_sizing(true);
PanelManager::GetInstance()->SetWorkAreaForTesting(
gfx::Rect(0, 0, 1200, 900)); // bigger space is needed by this test
......
......@@ -157,8 +157,7 @@ bool PanelOverflowStrip::ShouldShowOverflowTitles(
int width = are_overflow_titles_shown_ ? kOverflowAreaHoverWidth
: display_area_.width();
return display_area_.x() <= mouse_position.x() &&
mouse_position.x() <= display_area_.x() + width &&
return mouse_position.x() <= display_area_.x() + width &&
panels_.back()->GetBounds().y() <= mouse_position.y() &&
mouse_position.y() <= display_area_.bottom();
}
......
......@@ -101,6 +101,7 @@ void PanelStrip::AddPanel(Panel* panel) {
}
int y = display_area_.bottom() - height;
panel->SetPanelBounds(gfx::Rect(x, y, width, height));
panel->SetExpansionState(Panel::EXPANDED);
} else {
// Initialize the newly created panel. Does not bump any panels from strip.
if (height == 0 && width == 0) {
......@@ -149,6 +150,7 @@ void PanelStrip::AddPanel(Panel* panel) {
panel->Initialize(gfx::Rect(x, y, width, height));
}
DCHECK(panel->expansion_state() == Panel::EXPANDED);
panels_.push_back(panel);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment