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

Side by Side 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: GTK changes 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/bind.h" 5 #include "base/bind.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/download/download_service.h" 8 #include "chrome/browser/download/download_service.h"
9 #include "chrome/browser/download/download_service_factory.h" 9 #include "chrome/browser/download/download_service_factory.h"
10 #include "chrome/browser/net/url_request_mock_util.h" 10 #include "chrome/browser/net/url_request_mock_util.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 std::vector<gfx::Rect> test_begin_bounds = GetAllPanelBounds(); 144 std::vector<gfx::Rect> test_begin_bounds = GetAllPanelBounds();
145 std::vector<gfx::Rect> expected_bounds = test_begin_bounds; 145 std::vector<gfx::Rect> expected_bounds = test_begin_bounds;
146 std::vector<Panel::ExpansionState> expected_expansion_states( 146 std::vector<Panel::ExpansionState> expected_expansion_states(
147 panels.size(), Panel::EXPANDED); 147 panels.size(), Panel::EXPANDED);
148 std::vector<NativePanelTesting*> native_panels_testing(panels.size()); 148 std::vector<NativePanelTesting*> native_panels_testing(panels.size());
149 for (size_t i = 0; i < panels.size(); ++i) { 149 for (size_t i = 0; i < panels.size(); ++i) {
150 native_panels_testing[i] = 150 native_panels_testing[i] =
151 NativePanelTesting::Create(panels[i]->native_panel()); 151 NativePanelTesting::Create(panels[i]->native_panel());
152 } 152 }
153 153
154 // Test minimize. 154 // Verify titlebar click does not minimize.
155 for (size_t index = 0; index < panels.size(); ++index) { 155 for (size_t index = 0; index < panels.size(); ++index) {
156 // Press left mouse button. Verify nothing changed. 156 // Press left mouse button. Verify nothing changed.
157 native_panels_testing[index]->PressLeftMouseButtonTitlebar( 157 native_panels_testing[index]->PressLeftMouseButtonTitlebar(
158 panels[index]->GetBounds().origin()); 158 panels[index]->GetBounds().origin());
159 EXPECT_EQ(expected_bounds, GetAllPanelBounds()); 159 EXPECT_EQ(expected_bounds, GetAllPanelBounds());
160 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates()); 160 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates());
161 161
162 // Release mouse button. Verify minimized. 162 // Release mouse button. Verify nothing changed.
163 native_panels_testing[index]->ReleaseMouseButtonTitlebar(); 163 native_panels_testing[index]->ReleaseMouseButtonTitlebar();
164 EXPECT_EQ(expected_bounds, GetAllPanelBounds());
165 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates());
166 }
167
168 // Minimize all panels for next stage in test.
169 for (size_t index = 0; index < panels.size(); ++index) {
170 panels[index]->Minimize();
164 expected_bounds[index].set_height(Panel::kMinimizedPanelHeight); 171 expected_bounds[index].set_height(Panel::kMinimizedPanelHeight);
165 expected_bounds[index].set_y( 172 expected_bounds[index].set_y(
166 test_begin_bounds[index].y() + 173 test_begin_bounds[index].y() +
167 test_begin_bounds[index].height() - Panel::kMinimizedPanelHeight); 174 test_begin_bounds[index].height() - Panel::kMinimizedPanelHeight);
168 expected_expansion_states[index] = Panel::MINIMIZED; 175 expected_expansion_states[index] = Panel::MINIMIZED;
169 EXPECT_EQ(expected_bounds, GetAllPanelBounds()); 176 EXPECT_EQ(expected_bounds, GetAllPanelBounds());
170 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates()); 177 EXPECT_EQ(expected_expansion_states, GetAllPanelExpansionStates());
171 } 178 }
172 179
173 // Setup bounds and expansion states for minimized and titlebar-only 180 // Setup bounds and expansion states for minimized and titlebar-only
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 native_panel_testing->ReleaseMouseButtonTitlebar(); 1001 native_panel_testing->ReleaseMouseButtonTitlebar();
995 1002
996 MessageLoop::current()->RunAllPending(); 1003 MessageLoop::current()->RunAllPending();
997 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); 1004 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE);
998 EXPECT_FALSE(panel->IsDrawingAttention()); 1005 EXPECT_FALSE(panel->IsDrawingAttention());
999 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); 1006 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention());
1000 1007
1001 panel->Close(); 1008 panel->Close();
1002 } 1009 }
1003 1010
1004 // There was a bug when it was not possible to minimize the panel by clicking
1005 // on the titlebar right after it was restored and activated. This test verifies
1006 // it's possible.
1007 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, 1011 IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
1008 MinimizeImmediatelyAfterRestore) { 1012 MinimizeImmediatelyAfterRestore) {
1009 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_ACTIVE); 1013 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_ACTIVE);
1010 Panel* panel = CreatePanelWithParams(params); 1014 Panel* panel = CreatePanelWithParams(params);
1011 scoped_ptr<NativePanelTesting> native_panel_testing( 1015 scoped_ptr<NativePanelTesting> native_panel_testing(
1012 NativePanelTesting::Create(panel->native_panel())); 1016 NativePanelTesting::Create(panel->native_panel()));
1013 1017
1014 panel->SetExpansionState(Panel::MINIMIZED); // this should deactivate. 1018 panel->Minimize(); // this should deactivate.
1015 MessageLoop::current()->RunAllPending(); 1019 MessageLoop::current()->RunAllPending();
1016 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); 1020 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE);
1017 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); 1021 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state());
1018 1022
1019 panel->Activate(); 1023 panel->Activate();
1020 MessageLoop::current()->RunAllPending(); 1024 MessageLoop::current()->RunAllPending();
1021 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); 1025 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE);
1022 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); 1026 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state());
1023 1027
1024 // Test that click on the titlebar right after expansion minimizes the Panel. 1028 // Verify that minimizing a panel right after expansion works.
1025 native_panel_testing->PressLeftMouseButtonTitlebar( 1029 panel->Minimize();
1026 panel->GetBounds().origin());
1027 native_panel_testing->ReleaseMouseButtonTitlebar();
1028 MessageLoop::current()->RunAllPending(); 1030 MessageLoop::current()->RunAllPending();
1029 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); 1031 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state());
1030 panel->Close(); 1032 panel->Close();
1031 } 1033 }
1032 1034
1033 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FocusLostOnMinimize) { 1035 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FocusLostOnMinimize) {
1034 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); 1036 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE);
1035 Panel* panel = CreatePanelWithParams(params); 1037 Panel* panel = CreatePanelWithParams(params);
1036 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); 1038 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state());
1037 1039
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 // position when tall panel brings up its titlebar. 1670 // position when tall panel brings up its titlebar.
1669 CloseWindowAndWait(panel1->browser()); 1671 CloseWindowAndWait(panel1->browser());
1670 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up, 1672 EXPECT_EQ(balloon_bottom_after_tall_panel_titlebar_up,
1671 GetBalloonBottomPosition(balloon)); 1673 GetBalloonBottomPosition(balloon));
1672 1674
1673 // Closing the remaining tall panel should move the notification balloon back 1675 // Closing the remaining tall panel should move the notification balloon back
1674 // to its original position. 1676 // to its original position.
1675 CloseWindowAndWait(panel2->browser()); 1677 CloseWindowAndWait(panel2->browser());
1676 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); 1678 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon));
1677 } 1679 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698