OLD | NEW |
---|---|
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/download/download_service.h" | 7 #include "chrome/browser/download/download_service.h" |
8 #include "chrome/browser/download/download_service_factory.h" | 8 #include "chrome/browser/download/download_service_factory.h" |
9 #include "chrome/browser/net/url_request_mock_util.h" | 9 #include "chrome/browser/net/url_request_mock_util.h" |
10 #include "chrome/browser/prefs/browser_prefs.h" | 10 #include "chrome/browser/prefs/browser_prefs.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 | 249 |
250 // The below could be separate tests, just adding a TODO here for tracking. | 250 // The below could be separate tests, just adding a TODO here for tracking. |
251 // TODO(prasadt): Add test for dragging when in titlebar exposed state. | 251 // TODO(prasadt): Add test for dragging when in titlebar exposed state. |
252 // TODO(prasadt): Add test in presence of auto hiding task bar. | 252 // TODO(prasadt): Add test in presence of auto hiding task bar. |
253 | 253 |
254 for (size_t i = 0; i < panels.size(); ++i) | 254 for (size_t i = 0; i < panels.size(); ++i) |
255 delete native_panels_testing[i]; | 255 delete native_panels_testing[i]; |
256 } | 256 } |
257 }; | 257 }; |
258 | 258 |
259 // http://crbug.com/135377 | 259 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, CheckDockedPanelProperties) { |
260 #if defined(OS_LINUX) | |
261 #define MAYBE_CheckDockedPanelProperties DISABLED_CheckDockedPanelProperties | |
262 #else | |
263 #define MAYBE_CheckDockedPanelProperties CheckDockedPanelProperties | |
264 #endif | |
265 | |
266 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MAYBE_CheckDockedPanelProperties) { | |
267 PanelManager* panel_manager = PanelManager::GetInstance(); | 260 PanelManager* panel_manager = PanelManager::GetInstance(); |
268 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 261 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
269 | 262 |
270 // Create 3 docked panels that are in expanded, title-only or minimized states | 263 // Create 3 docked panels that are in expanded, title-only or minimized states |
271 // respectively. | 264 // respectively. |
272 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); | 265 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); |
273 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); | 266 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); |
274 panel2->SetExpansionState(Panel::TITLE_ONLY); | 267 panel2->SetExpansionState(Panel::TITLE_ONLY); |
275 WaitForExpansionStateChanged(panel2, Panel::TITLE_ONLY); | 268 WaitForExpansionStateChanged(panel2, Panel::TITLE_ONLY); |
276 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); | 269 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 EXPECT_EQ(panel::NOT_RESIZABLE, panel2->CanResizeByMouse()); | 310 EXPECT_EQ(panel::NOT_RESIZABLE, panel2->CanResizeByMouse()); |
318 EXPECT_EQ(panel::NOT_RESIZABLE, panel3->CanResizeByMouse()); | 311 EXPECT_EQ(panel::NOT_RESIZABLE, panel3->CanResizeByMouse()); |
319 | 312 |
320 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel1->attention_mode()); | 313 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel1->attention_mode()); |
321 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel2->attention_mode()); | 314 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel2->attention_mode()); |
322 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel3->attention_mode()); | 315 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel3->attention_mode()); |
323 | 316 |
324 panel_manager->CloseAll(); | 317 panel_manager->CloseAll(); |
325 } | 318 } |
326 | 319 |
327 // http://crbug.com/135377 | 320 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, CreatePanel) { |
328 #if defined(OS_LINUX) | |
329 #define MAYBE_CreatePanel DISABLED_CreatePanel | |
330 #else | |
331 #define MAYBE_CreatePanel CreatePanel | |
332 #endif | |
333 | |
334 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MAYBE_CreatePanel) { | |
335 PanelManager* panel_manager = PanelManager::GetInstance(); | 321 PanelManager* panel_manager = PanelManager::GetInstance(); |
336 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. | 322 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. |
337 | 323 |
338 Panel* panel = CreatePanel("PanelTest"); | 324 Panel* panel = CreatePanel("PanelTest"); |
339 EXPECT_EQ(1, panel_manager->num_panels()); | 325 EXPECT_EQ(1, panel_manager->num_panels()); |
340 | 326 |
341 gfx::Rect bounds = panel->GetBounds(); | 327 gfx::Rect bounds = panel->GetBounds(); |
342 EXPECT_GT(bounds.x(), 0); | 328 EXPECT_GT(bounds.x(), 0); |
343 EXPECT_GT(bounds.y(), 0); | 329 EXPECT_GT(bounds.y(), 0); |
344 EXPECT_GT(bounds.width(), 0); | 330 EXPECT_GT(bounds.width(), 0); |
345 EXPECT_GT(bounds.height(), 0); | 331 EXPECT_GT(bounds.height(), 0); |
346 | 332 |
347 EXPECT_EQ(bounds.right(), | 333 EXPECT_EQ(bounds.right(), |
348 panel_manager->docked_strip()->StartingRightPosition()); | 334 panel_manager->docked_strip()->StartingRightPosition()); |
349 | 335 |
350 CloseWindowAndWait(panel); | 336 CloseWindowAndWait(panel); |
351 | 337 |
352 EXPECT_EQ(0, panel_manager->num_panels()); | 338 EXPECT_EQ(0, panel_manager->num_panels()); |
353 } | 339 } |
354 | 340 |
355 // http://crbug.com/135377 | 341 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, CreateBigPanel) { |
356 #if defined(OS_LINUX) | |
357 #define MAYBE_CreateBigPanel DISABLED_CreateBigPanel | |
358 #else | |
359 #define MAYBE_CreateBigPanel CreateBigPanel | |
360 #endif | |
361 | |
362 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MAYBE_CreateBigPanel) { | |
363 gfx::Rect work_area = PanelManager::GetInstance()-> | 342 gfx::Rect work_area = PanelManager::GetInstance()-> |
364 display_settings_provider()->GetDisplayArea(); | 343 display_settings_provider()->GetDisplayArea(); |
365 Panel* panel = CreatePanelWithBounds("BigPanel", work_area); | 344 Panel* panel = CreatePanelWithBounds("BigPanel", work_area); |
366 gfx::Rect bounds = panel->GetBounds(); | 345 gfx::Rect bounds = panel->GetBounds(); |
367 EXPECT_EQ(panel->max_size().width(), bounds.width()); | 346 EXPECT_EQ(panel->max_size().width(), bounds.width()); |
368 EXPECT_LT(bounds.width(), work_area.width()); | 347 EXPECT_LT(bounds.width(), work_area.width()); |
369 EXPECT_EQ(panel->max_size().height(), bounds.height()); | 348 EXPECT_EQ(panel->max_size().height(), bounds.height()); |
370 EXPECT_LT(bounds.height(), work_area.height()); | 349 EXPECT_LT(bounds.height(), work_area.height()); |
371 panel->Close(); | 350 panel->Close(); |
372 } | 351 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 new_size.Enlarge(5, 5); | 444 new_size.Enlarge(5, 5); |
466 new_bounds.set_size(new_size); | 445 new_bounds.set_size(new_size); |
467 panel->SetBounds(new_bounds); | 446 panel->SetBounds(new_bounds); |
468 EXPECT_EQ(new_bounds.size().width(), panel->GetBounds().width()); | 447 EXPECT_EQ(new_bounds.size().width(), panel->GetBounds().width()); |
469 EXPECT_EQ(original_height, panel->GetBounds().height()); | 448 EXPECT_EQ(original_height, panel->GetBounds().height()); |
470 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size()); | 449 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size()); |
471 | 450 |
472 panel->Close(); | 451 panel->Close(); |
473 } | 452 } |
474 | 453 |
475 // http://crbug.com/135377 | 454 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, AnimateBounds) { |
476 #if defined(OS_LINUX) | |
477 #define MAYBE_AnimateBounds DISABLED_AnimateBounds | |
478 #else | |
479 #define MAYBE_AnimateBounds AnimateBounds | |
480 #endif | |
481 | |
482 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MAYBE_AnimateBounds) { | |
483 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); | 455 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); |
484 scoped_ptr<NativePanelTesting> panel_testing( | 456 scoped_ptr<NativePanelTesting> panel_testing( |
485 CreateNativePanelTesting(panel)); | 457 CreateNativePanelTesting(panel)); |
486 | 458 |
487 // Set bounds with animation. | 459 // Set bounds with animation. |
488 gfx::Rect bounds = gfx::Rect(10, 20, 150, 160); | 460 gfx::Rect bounds = gfx::Rect(10, 20, 150, 160); |
489 panel->SetPanelBounds(bounds); | 461 panel->SetPanelBounds(bounds); |
490 EXPECT_TRUE(panel_testing->IsAnimatingBounds()); | 462 EXPECT_TRUE(panel_testing->IsAnimatingBounds()); |
491 WaitForBoundsAnimationFinished(panel); | 463 WaitForBoundsAnimationFinished(panel); |
492 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); | 464 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
986 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 958 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
987 | 959 |
988 panel->Close(); | 960 panel->Close(); |
989 } | 961 } |
990 | 962 |
991 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionWhileMinimized) { | 963 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionWhileMinimized) { |
992 // We'll simulate mouse movements for test. | 964 // We'll simulate mouse movements for test. |
993 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 965 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
994 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 966 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
995 | 967 |
996 // Create 2 panels so we end up with an inactive panel that can | 968 // Create 2 panels so we end up with an inactive panel that can |
dcheng
2012/07/03 23:04:25
"Create 2 panels"... hmm!
| |
997 // be made to draw attention. | 969 // be made to draw attention. |
998 Panel* panel = CreatePanel("test panel1"); | 970 Panel* panel = CreatePanel("test panel1"); |
999 Panel* panel2 = CreatePanel("test panel2"); | 971 Panel* panel2 = CreatePanel("test panel2"); |
1000 Panel* panel3 = CreatePanel("test panel2"); | 972 Panel* panel3 = CreatePanel("test panel3"); |
1001 | 973 |
1002 scoped_ptr<NativePanelTesting> native_panel_testing( | 974 scoped_ptr<NativePanelTesting> native_panel_testing( |
1003 CreateNativePanelTesting(panel)); | 975 CreateNativePanelTesting(panel)); |
1004 | 976 |
1005 // Test that the attention is drawn and the title-bar is brought up when the | 977 // Test that the attention is drawn and the title-bar is brought up when the |
1006 // minimized panel is drawing attention. | 978 // minimized panel is drawing attention. |
1007 panel->Minimize(); | 979 panel->Minimize(); |
1008 WaitForExpansionStateChanged(panel, Panel::MINIMIZED); | 980 WaitForExpansionStateChanged(panel, Panel::MINIMIZED); |
1009 panel->FlashFrame(true); | 981 panel->FlashFrame(true); |
1010 EXPECT_TRUE(panel->IsDrawingAttention()); | 982 EXPECT_TRUE(panel->IsDrawingAttention()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1101 | 1073 |
1102 // Move mouse away and panel should go back to fully minimized state. | 1074 // Move mouse away and panel should go back to fully minimized state. |
1103 MoveMouseAndWaitForExpansionStateChange(panel1, hover_point); | 1075 MoveMouseAndWaitForExpansionStateChange(panel1, hover_point); |
1104 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 1076 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
1105 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state()); | 1077 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state()); |
1106 | 1078 |
1107 panel1->Close(); | 1079 panel1->Close(); |
1108 panel2->Close(); | 1080 panel2->Close(); |
1109 } | 1081 } |
1110 | 1082 |
1111 // http://crbug.com/135377 | 1083 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionWhenActive) { |
1112 #if defined(OS_LINUX) | |
1113 #define MAYBE_DrawAttentionWhenActive DISABLED_DrawAttentionWhenActive | |
1114 #else | |
1115 #define MAYBE_DrawAttentionWhenActive DrawAttentionWhenActive | |
1116 #endif | |
1117 | |
1118 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MAYBE_DrawAttentionWhenActive) { | |
1119 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); | 1084 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); |
1120 Panel* panel = CreatePanelWithParams(params); | 1085 Panel* panel = CreatePanelWithParams(params); |
1121 scoped_ptr<NativePanelTesting> native_panel_testing( | 1086 scoped_ptr<NativePanelTesting> native_panel_testing( |
1122 CreateNativePanelTesting(panel)); | 1087 CreateNativePanelTesting(panel)); |
1123 | 1088 |
1124 // Test that the attention should not be drawn if the expanded panel is in | 1089 // Test that the attention should not be drawn if the expanded panel is in |
1125 // focus. | 1090 // focus. |
1126 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 1091 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
1127 EXPECT_TRUE(panel->IsActive()); | 1092 EXPECT_TRUE(panel->IsActive()); |
1128 EXPECT_FALSE(panel->IsDrawingAttention()); | 1093 EXPECT_FALSE(panel->IsDrawingAttention()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1214 | 1179 |
1215 MessageLoop::current()->RunAllPending(); | 1180 MessageLoop::current()->RunAllPending(); |
1216 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 1181 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
1217 EXPECT_FALSE(panel->IsDrawingAttention()); | 1182 EXPECT_FALSE(panel->IsDrawingAttention()); |
1218 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1183 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
1219 | 1184 |
1220 panel->Close(); | 1185 panel->Close(); |
1221 } | 1186 } |
1222 | 1187 |
1223 | 1188 |
1224 // http://crbug.com/135377 | |
1225 #if defined(OS_LINUX) | |
1226 #define MAYBE_MinimizeImmediatelyAfterRestore \ | |
1227 DISABLED_MinimizeImmediatelyAfterRestore | |
1228 #else | |
1229 #define MAYBE_MinimizeImmediatelyAfterRestore MinimizeImmediatelyAfterRestore | |
1230 #endif | |
1231 | |
1232 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, | 1189 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, |
1233 MAYBE_MinimizeImmediatelyAfterRestore) { | 1190 MinimizeImmediatelyAfterRestore) { |
1234 CreatePanelParams params("Panel Test", gfx::Rect(), SHOW_AS_ACTIVE); | 1191 CreatePanelParams params("Panel Test", gfx::Rect(), SHOW_AS_ACTIVE); |
1235 Panel* panel = CreatePanelWithParams(params); | 1192 Panel* panel = CreatePanelWithParams(params); |
1236 scoped_ptr<NativePanelTesting> native_panel_testing( | 1193 scoped_ptr<NativePanelTesting> native_panel_testing( |
1237 CreateNativePanelTesting(panel)); | 1194 CreateNativePanelTesting(panel)); |
1238 | 1195 |
1239 panel->Minimize(); // this should deactivate. | 1196 panel->Minimize(); // this should deactivate. |
1240 MessageLoop::current()->RunAllPending(); | 1197 MessageLoop::current()->RunAllPending(); |
1241 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 1198 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
1242 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 1199 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
1243 | 1200 |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1795 Browser* tabbed_browser = browser::FindTabbedBrowser(profile, false); | 1752 Browser* tabbed_browser = browser::FindTabbedBrowser(profile, false); |
1796 EXPECT_EQ(1, tabbed_browser->tab_count()); | 1753 EXPECT_EQ(1, tabbed_browser->tab_count()); |
1797 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); | 1754 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); |
1798 chrome::CloseWindow(tabbed_browser); | 1755 chrome::CloseWindow(tabbed_browser); |
1799 | 1756 |
1800 EXPECT_EQ(1, panel_browser->tab_count()); | 1757 EXPECT_EQ(1, panel_browser->tab_count()); |
1801 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); | 1758 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); |
1802 | 1759 |
1803 chrome::CloseWindow(panel_browser); | 1760 chrome::CloseWindow(panel_browser); |
1804 } | 1761 } |
OLD | NEW |