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

Unified Diff: chrome/browser/ui/panels/panel_browsertest.cc

Issue 10106008: Change Panel titlebars to activate the panel on click (rather than minimize). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win compile Created 8 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/panels/panel_browsertest.cc
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index 9306b53ddaa6e11068d5ef4e77d6365acf275172..e55e30a65e7d66032f88e5b3c4388253d5277bff 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -151,7 +151,7 @@ class PanelBrowserTest : public BasePanelBrowserTest {
NativePanelTesting::Create(panels[i]->native_panel());
}
- // Test minimize.
+ // Verify titlebar click does not minimize.
for (size_t index = 0; index < panels.size(); ++index) {
// Press left mouse button. Verify nothing changed.
native_panels_testing[index]->PressLeftMouseButtonTitlebar(
@@ -159,8 +159,15 @@ class PanelBrowserTest : public BasePanelBrowserTest {
EXPECT_EQ(expected_bounds, GetAllPanelBounds());
EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates());
- // Release mouse button. Verify minimized.
+ // Release mouse button. Verify nothing changed.
native_panels_testing[index]->ReleaseMouseButtonTitlebar();
+ EXPECT_EQ(expected_bounds, GetAllPanelBounds());
+ EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates());
+ }
+
+ // Minimize all panels for next stage in test.
+ for (size_t index = 0; index < panels.size(); ++index) {
+ panels[index]->Minimize();
expected_bounds[index].set_height(Panel::kMinimizedPanelHeight);
expected_bounds[index].set_y(
test_begin_bounds[index].y() +
@@ -598,7 +605,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreThreePanels) {
PanelManager::GetInstance()->CloseAll();
}
-IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ToggleMinimizeAll) {
+IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoreAllWithTitlebarClick) {
// We'll simulate mouse movements for test.
PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher);
@@ -618,48 +625,56 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ToggleMinimizeAll) {
scoped_ptr<NativePanelTesting> test_panel3(
NativePanelTesting::Create(panel3->native_panel()));
- // Press and release mouse button on one panel's titlebar using a modifier
- // to minimize all panels. Nothing changes until mouse is released.
+ // Click on an expanded panel's titlebar using the apply-all modifier.
+ // Verify expansion state is unchanged.
test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(),
panel::APPLY_TO_ALL);
+ test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
- test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
+
+ // Click on a minimized panel's titlebar using the apply-all modifier.
+ panel1->Minimize();
+ panel2->Minimize();
+ panel3->Minimize();
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
- // Press and release on a panel titlebar to restore all panels.
// Nothing changes until mouse is released.
test_panel1->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin(),
panel::APPLY_TO_ALL);
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
+ // Verify all panels restored when mouse is released.
test_panel1->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
- // Minimize a single panel. Then minimize all panels to verify that apply-all
- // logic works even if not all panels have the same expansion state.
+ // Minimize a single panel. Then click on expanded panel with apply-all
+ // modifier. Verify nothing changes.
panel1->Minimize();
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
+
test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(),
panel::APPLY_TO_ALL);
test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
EXPECT_TRUE(panel1->IsMinimized());
- EXPECT_TRUE(panel2->IsMinimized());
- EXPECT_TRUE(panel3->IsMinimized());
+ EXPECT_FALSE(panel2->IsMinimized());
+ EXPECT_FALSE(panel3->IsMinimized());
- // Expand a single panel. Then restore all panels.
- panel3->Restore();
+ // Minimize another panel. Then click on a minimized panel with apply-all
+ // modifier to restore all panels.
+ panel2->Minimize();
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
+
test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(),
panel::APPLY_TO_ALL);
test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
@@ -672,6 +687,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ToggleMinimizeAll) {
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
+
test_panel1->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin(),
panel::APPLY_TO_ALL);
test_panel1->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
@@ -679,25 +695,32 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ToggleMinimizeAll) {
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
- // Click on the single expanded panel. Verify all are minimized.
+ // Click on the single expanded panel. Verify nothing changes.
panel1->Minimize();
panel3->Minimize();
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
+
test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(),
panel::APPLY_TO_ALL);
test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
EXPECT_TRUE(panel1->IsMinimized());
- EXPECT_TRUE(panel2->IsMinimized());
+ EXPECT_FALSE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
// Hover over a minimized panel and click on the titlebar while it is in
// title-only mode. Should restore all panels.
+ panel2->Minimize();
+ EXPECT_TRUE(panel1->IsMinimized());
+ EXPECT_TRUE(panel2->IsMinimized());
+ EXPECT_TRUE(panel3->IsMinimized());
+
MoveMouseAndWaitForExpansionStateChange(panel2, panel2->GetBounds().origin());
EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
EXPECT_EQ(Panel::TITLE_ONLY, panel2->expansion_state());
EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state());
+
test_panel3->PressLeftMouseButtonTitlebar(panel3->GetBounds().origin(),
panel::APPLY_TO_ALL);
test_panel3->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
@@ -705,29 +728,43 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ToggleMinimizeAll) {
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
- // Draw attention to a panel. Verify minimize all applies without
- // affecting draw attention state.
+ // Draw attention to a minimized panel. Click on a minimized panel that is
+ // not drawing attention. Verify restore all applies without affecting
+ // draw attention.
+ panel1->Minimize();
+ panel2->Minimize();
+ panel3->Minimize();
+ EXPECT_TRUE(panel1->IsMinimized());
+ EXPECT_TRUE(panel2->IsMinimized());
+ EXPECT_TRUE(panel3->IsMinimized());
+
panel1->FlashFrame(true);
EXPECT_TRUE(panel1->IsDrawingAttention());
- test_panel3->PressLeftMouseButtonTitlebar(panel3->GetBounds().origin(),
+
+ test_panel2->PressLeftMouseButtonTitlebar(panel3->GetBounds().origin(),
panel::APPLY_TO_ALL);
- test_panel3->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
+ test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
+ EXPECT_FALSE(panel1->IsMinimized());
+ EXPECT_FALSE(panel2->IsMinimized());
+ EXPECT_FALSE(panel3->IsMinimized());
+ EXPECT_TRUE(panel1->IsDrawingAttention());
+
+ // Restore all panels by clicking on the minimized panel that is drawing
+ // attention. Verify restore all applies and clears draw attention.
+ panel1->Minimize();
+ panel2->Minimize();
+ panel3->Minimize();
EXPECT_TRUE(panel1->IsMinimized());
EXPECT_TRUE(panel2->IsMinimized());
EXPECT_TRUE(panel3->IsMinimized());
- EXPECT_TRUE(panel1->IsDrawingAttention());
- EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
- // Restore all panels by clicking on the minimized panel that is drawing
- // attention. Verify restore all applies without affecting draw attention
- // state.
test_panel1->PressLeftMouseButtonTitlebar(panel1->GetBounds().origin(),
panel::APPLY_TO_ALL);
test_panel1->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
EXPECT_FALSE(panel1->IsMinimized());
EXPECT_FALSE(panel2->IsMinimized());
EXPECT_FALSE(panel3->IsMinimized());
- EXPECT_TRUE(panel1->IsDrawingAttention());
+ EXPECT_FALSE(panel1->IsDrawingAttention());
PanelManager::GetInstance()->CloseAll();
}
@@ -1026,7 +1063,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) {
scoped_ptr<NativePanelTesting> native_panel_testing(
NativePanelTesting::Create(panel->native_panel()));
- // Activate the panel.
+ // Deactivate the panel.
panel->Deactivate();
WaitForPanelActiveState(panel, SHOW_AS_INACTIVE);
@@ -1045,14 +1082,37 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) {
panel->Close();
}
-// TODO(dimich): try/enable on other platforms.
-#if defined(OS_MACOSX)
-#define MAYBE_DrawAttentionResetOnClick DrawAttentionResetOnClick
-#else
-#define MAYBE_DrawAttentionResetOnClick DISABLED_DrawAttentionResetOnClick
-#endif
+IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
+ DrawAttentionMinimizedNotResetOnActivate) {
+ // Create 2 panels so we end up with an inactive panel that can
+ // be made to draw attention.
+ Panel* panel1 = CreatePanel("test panel1");
+ Panel* panel2 = CreatePanel("test panel2");
+
+ panel1->Minimize();
+ EXPECT_TRUE(panel1->IsMinimized());
+ panel1->FlashFrame(true);
+ EXPECT_TRUE(panel1->IsDrawingAttention());
+
+ // Simulate panel being activated while minimized. Cannot call
+ // Activate() as that expands the panel.
+ panel1->OnActiveStateChanged(true);
+ EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged.
+
+ // Unminimize panel to show that attention would have been cleared
+ // if panel had not been minimized.
+ panel1->Restore();
+ EXPECT_FALSE(panel1->IsMinimized());
+ EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged.
-IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_DrawAttentionResetOnClick) {
+ panel1->OnActiveStateChanged(true);
+ EXPECT_FALSE(panel1->IsDrawingAttention()); // Attention cleared.
+
+ panel1->Close();
+ panel2->Close();
+}
+
+IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnClick) {
CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE);
Panel* panel = CreatePanelWithParams(params);
scoped_ptr<NativePanelTesting> native_panel_testing(
@@ -1076,9 +1136,6 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_DrawAttentionResetOnClick) {
panel->Close();
}
-// There was a bug when it was not possible to minimize the panel by clicking
-// on the titlebar right after it was restored and activated. This test verifies
-// it's possible.
IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
MinimizeImmediatelyAfterRestore) {
CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_ACTIVE);
@@ -1086,7 +1143,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
scoped_ptr<NativePanelTesting> native_panel_testing(
NativePanelTesting::Create(panel->native_panel()));
- panel->SetExpansionState(Panel::MINIMIZED); // this should deactivate.
+ panel->Minimize(); // this should deactivate.
MessageLoop::current()->RunAllPending();
WaitForPanelActiveState(panel, SHOW_AS_INACTIVE);
EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state());
@@ -1096,10 +1153,8 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
WaitForPanelActiveState(panel, SHOW_AS_ACTIVE);
EXPECT_EQ(Panel::EXPANDED, panel->expansion_state());
- // Test that click on the titlebar right after expansion minimizes the Panel.
- native_panel_testing->PressLeftMouseButtonTitlebar(
- panel->GetBounds().origin());
- native_panel_testing->ReleaseMouseButtonTitlebar();
+ // Verify that minimizing a panel right after expansion works.
+ panel->Minimize();
MessageLoop::current()->RunAllPending();
EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state());
panel->Close();
« no previous file with comments | « chrome/browser/ui/panels/panel_browser_window_gtk.cc ('k') | chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698