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