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

Side by Side Diff: chrome/browser/ui/panels/panel_browsertest.cc

Issue 1149263003: Add user_gesture param to BaseWindow::Activate Base URL: https://chromium.googlesource.com/chromium/src.git@ug2_WebContentsDelegate_ActivateContents
Patch Set: Update callers Created 5 years, 7 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
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/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/devtools/devtools_window.h" 10 #include "chrome/browser/devtools/devtools_window.h"
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ActivatePanelOrTabbedWindow) { 947 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ActivatePanelOrTabbedWindow) {
948 if (!WmSupportWindowActivation()) { 948 if (!WmSupportWindowActivation()) {
949 LOG(WARNING) << "Skipping test due to WM problems."; 949 LOG(WARNING) << "Skipping test due to WM problems.";
950 return; 950 return;
951 } 951 }
952 952
953 Panel* panel1 = CreatePanel("Panel1"); 953 Panel* panel1 = CreatePanel("Panel1");
954 Panel* panel2 = CreatePanel("Panel2"); 954 Panel* panel2 = CreatePanel("Panel2");
955 955
956 // Activate main tabbed window. 956 // Activate main tabbed window.
957 browser()->window()->Activate(); 957 browser()->window()->Activate(false /* user_gesture */);
958 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); 958 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE);
959 959
960 // Activate a panel. 960 // Activate a panel.
961 panel2->Activate(); 961 panel2->Activate(false /* user_gesture */);
962 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); 962 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE);
963 963
964 // Activate the main tabbed window back. 964 // Activate the main tabbed window back.
965 browser()->window()->Activate(); 965 browser()->window()->Activate(false /* user_gesture */);
966 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); 966 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE);
967 967
968 // Activate another panel. 968 // Activate another panel.
969 panel1->Activate(); 969 panel1->Activate(false /* user_gesture */);
970 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); 970 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE);
971 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); 971 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE);
972 972
973 // Switch focus between panels. 973 // Switch focus between panels.
974 panel2->Activate(); 974 panel2->Activate(false /* user_gesture */);
975 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); 975 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE);
976 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE); 976 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE);
977 977
978 PanelManager::GetInstance()->CloseAll(); 978 PanelManager::GetInstance()->CloseAll();
979 } 979 }
980 980
981 // TODO(jianli): To be enabled for other platforms. 981 // TODO(jianli): To be enabled for other platforms.
982 #if defined(OS_WIN) || defined(OS_LINUX) 982 #if defined(OS_WIN) || defined(OS_LINUX)
983 #define MAYBE_ActivateDeactivateBasic ActivateDeactivateBasic 983 #define MAYBE_ActivateDeactivateBasic ActivateDeactivateBasic
984 #else 984 #else
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 1029
1030 std::vector<bool> expected_active_states; 1030 std::vector<bool> expected_active_states;
1031 std::vector<bool> last_active_states; 1031 std::vector<bool> last_active_states;
1032 1032
1033 // The last created panel, P3, should be active. 1033 // The last created panel, P3, should be active.
1034 expected_active_states = ProduceExpectedActiveStates(3); 1034 expected_active_states = ProduceExpectedActiveStates(3);
1035 EXPECT_EQ(expected_active_states, GetAllPanelActiveStates()); 1035 EXPECT_EQ(expected_active_states, GetAllPanelActiveStates());
1036 EXPECT_FALSE(tabbed_window->IsActive()); 1036 EXPECT_FALSE(tabbed_window->IsActive());
1037 1037
1038 // Activating P1 should cause P3 to lose focus. 1038 // Activating P1 should cause P3 to lose focus.
1039 panels[1]->Activate(); 1039 panels[1]->Activate(false /* user_gesture */);
1040 last_active_states = expected_active_states; 1040 last_active_states = expected_active_states;
1041 expected_active_states = ProduceExpectedActiveStates(1); 1041 expected_active_states = ProduceExpectedActiveStates(1);
1042 WaitForPanelActiveStates(last_active_states, expected_active_states); 1042 WaitForPanelActiveStates(last_active_states, expected_active_states);
1043 EXPECT_EQ(expected_active_states, GetAllPanelActiveStates()); 1043 EXPECT_EQ(expected_active_states, GetAllPanelActiveStates());
1044 1044
1045 // Minimizing inactive panel P2 should not affect other panels' active states. 1045 // Minimizing inactive panel P2 should not affect other panels' active states.
1046 panels[2]->SetExpansionState(Panel::MINIMIZED); 1046 panels[2]->SetExpansionState(Panel::MINIMIZED);
1047 EXPECT_EQ(expected_active_states, GetAllPanelActiveStates()); 1047 EXPECT_EQ(expected_active_states, GetAllPanelActiveStates());
1048 EXPECT_FALSE(tabbed_window->IsActive()); 1048 EXPECT_FALSE(tabbed_window->IsActive());
1049 } 1049 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 MoveMouse(hover_point); 1105 MoveMouse(hover_point);
1106 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); 1106 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
1107 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state()); 1107 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state());
1108 1108
1109 // Test that we cannot bring down the panel that is drawing the attention. 1109 // Test that we cannot bring down the panel that is drawing the attention.
1110 hover_point.set_y(hover_point.y() - 200); 1110 hover_point.set_y(hover_point.y() - 200);
1111 MoveMouse(hover_point); 1111 MoveMouse(hover_point);
1112 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); 1112 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
1113 1113
1114 // Test that the attention is cleared when activated. 1114 // Test that the attention is cleared when activated.
1115 panel1->Activate(); 1115 panel1->Activate(false /* user_gesture */);
1116 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); 1116 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE);
1117 EXPECT_FALSE(panel1->IsDrawingAttention()); 1117 EXPECT_FALSE(panel1->IsDrawingAttention());
1118 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); 1118 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
1119 EXPECT_FALSE(native_panel1_testing->VerifyDrawingAttention()); 1119 EXPECT_FALSE(native_panel1_testing->VerifyDrawingAttention());
1120 1120
1121 PanelManager::GetInstance()->CloseAll(); 1121 PanelManager::GetInstance()->CloseAll();
1122 } 1122 }
1123 1123
1124 // Verify that minimized state of a panel is correct after draw attention 1124 // Verify that minimized state of a panel is correct after draw attention
1125 // is stopped when there are other minimized panels. 1125 // is stopped when there are other minimized panels.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) { 1210 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) {
1211 Panel* panel = CreateInactivePanel("P1"); 1211 Panel* panel = CreateInactivePanel("P1");
1212 scoped_ptr<NativePanelTesting> native_panel_testing( 1212 scoped_ptr<NativePanelTesting> native_panel_testing(
1213 CreateNativePanelTesting(panel)); 1213 CreateNativePanelTesting(panel));
1214 1214
1215 panel->FlashFrame(true); 1215 panel->FlashFrame(true);
1216 EXPECT_TRUE(panel->IsDrawingAttention()); 1216 EXPECT_TRUE(panel->IsDrawingAttention());
1217 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); 1217 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention());
1218 1218
1219 // Test that the attention is cleared when panel gets focus. 1219 // Test that the attention is cleared when panel gets focus.
1220 panel->Activate(); 1220 panel->Activate(false /* user_gesture */);
1221 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); 1221 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE);
1222 EXPECT_FALSE(panel->IsDrawingAttention()); 1222 EXPECT_FALSE(panel->IsDrawingAttention());
1223 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); 1223 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention());
1224 1224
1225 panel->Close(); 1225 panel->Close();
1226 } 1226 }
1227 1227
1228 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, 1228 IN_PROC_BROWSER_TEST_F(PanelBrowserTest,
1229 DrawAttentionMinimizedNotResetOnActivate) { 1229 DrawAttentionMinimizedNotResetOnActivate) {
1230 Panel* panel = CreateInactivePanel("P1"); 1230 Panel* panel = CreateInactivePanel("P1");
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 1308
1309 PanelActiveStateObserver signal(panel, false); 1309 PanelActiveStateObserver signal(panel, false);
1310 panel->Minimize(); 1310 panel->Minimize();
1311 signal.Wait(); 1311 signal.Wait();
1312 panel->Close(); 1312 panel->Close();
1313 } 1313 }
1314 1314
1315 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateInactiveSwitchToActive) { 1315 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateInactiveSwitchToActive) {
1316 Panel* panel = CreateInactivePanel("1"); 1316 Panel* panel = CreateInactivePanel("1");
1317 1317
1318 panel->Activate(); 1318 panel->Activate(false /* user_gesture */);
1319 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); 1319 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE);
1320 1320
1321 panel->Close(); 1321 panel->Close();
1322 } 1322 }
1323 1323
1324 // TODO(dimich): try/enable on other platforms. See bug 103253 for details on 1324 // TODO(dimich): try/enable on other platforms. See bug 103253 for details on
1325 // why this is disabled on windows. 1325 // why this is disabled on windows.
1326 #if defined(OS_MACOSX) 1326 #if defined(OS_MACOSX)
1327 #define MAYBE_MinimizeTwoPanelsWithoutTabbedWindow \ 1327 #define MAYBE_MinimizeTwoPanelsWithoutTabbedWindow \
1328 MinimizeTwoPanelsWithoutTabbedWindow 1328 MinimizeTwoPanelsWithoutTabbedWindow
(...skipping 12 matching lines...) Expand all
1341 1341
1342 // Close main tabbed window. 1342 // Close main tabbed window.
1343 content::WindowedNotificationObserver signal( 1343 content::WindowedNotificationObserver signal(
1344 chrome::NOTIFICATION_BROWSER_CLOSED, 1344 chrome::NOTIFICATION_BROWSER_CLOSED,
1345 content::Source<Browser>(browser())); 1345 content::Source<Browser>(browser()));
1346 chrome::CloseWindow(browser()); 1346 chrome::CloseWindow(browser());
1347 signal.Wait(); 1347 signal.Wait();
1348 1348
1349 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); 1349 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
1350 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); 1350 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state());
1351 panel1->Activate(); 1351 panel1->Activate(false /* user_gesture */);
1352 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); 1352 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE);
1353 1353
1354 panel1->SetExpansionState(Panel::MINIMIZED); 1354 panel1->SetExpansionState(Panel::MINIMIZED);
1355 base::MessageLoop::current()->RunUntilIdle(); 1355 base::MessageLoop::current()->RunUntilIdle();
1356 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE); 1356 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE);
1357 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); 1357 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state());
1358 1358
1359 panel2->SetExpansionState(Panel::MINIMIZED); 1359 panel2->SetExpansionState(Panel::MINIMIZED);
1360 base::MessageLoop::current()->RunUntilIdle(); 1360 base::MessageLoop::current()->RunUntilIdle();
1361 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); 1361 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 #else 1772 #else
1773 #define MAYBE_FocusChangeEventOnMinimize FocusChangeEventOnMinimize 1773 #define MAYBE_FocusChangeEventOnMinimize FocusChangeEventOnMinimize
1774 #endif 1774 #endif
1775 IN_PROC_BROWSER_TEST_F(PanelExtensionApiTest, 1775 IN_PROC_BROWSER_TEST_F(PanelExtensionApiTest,
1776 MAYBE_FocusChangeEventOnMinimize) { 1776 MAYBE_FocusChangeEventOnMinimize) {
1777 // This is needed so the subsequently created panels can be activated. 1777 // This is needed so the subsequently created panels can be activated.
1778 // On a Mac, it transforms background-only test process into foreground one. 1778 // On a Mac, it transforms background-only test process into foreground one.
1779 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); 1779 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
1780 ASSERT_TRUE(RunExtensionTest("panels/focus_change_on_minimize")) << message_; 1780 ASSERT_TRUE(RunExtensionTest("panels/focus_change_on_minimize")) << message_;
1781 } 1781 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698