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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_CheckDockedPanelProperties) { | 262 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_CheckDockedPanelProperties) { |
263 PanelManager* panel_manager = PanelManager::GetInstance(); | 263 PanelManager* panel_manager = PanelManager::GetInstance(); |
264 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 264 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
265 | 265 |
266 // Create 3 docked panels that are in expanded, title-only or minimized states | 266 // Create 3 docked panels that are in expanded, title-only or minimized states |
267 // respectively. | 267 // respectively. |
268 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); | 268 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); |
269 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); | 269 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); |
270 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); | 270 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); |
271 panel2->SetExpansionState(Panel::TITLE_ONLY); | 271 panel2->SetExpansionState(Panel::TITLE_ONLY); |
272 WaitForExpansionStateChanged(panel2, Panel::TITLE_ONLY); | 272 EXPECT_EQ(Panel::TITLE_ONLY, panel2->expansion_state()); |
273 panel3->SetExpansionState(Panel::MINIMIZED); | 273 panel3->SetExpansionState(Panel::MINIMIZED); |
274 WaitForExpansionStateChanged(panel3, Panel::MINIMIZED); | 274 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); |
275 scoped_ptr<NativePanelTesting> panel1_testing( | 275 scoped_ptr<NativePanelTesting> panel1_testing( |
276 CreateNativePanelTesting(panel1)); | 276 CreateNativePanelTesting(panel1)); |
277 scoped_ptr<NativePanelTesting> panel2_testing( | 277 scoped_ptr<NativePanelTesting> panel2_testing( |
278 CreateNativePanelTesting(panel2)); | 278 CreateNativePanelTesting(panel2)); |
279 scoped_ptr<NativePanelTesting> panel3_testing( | 279 scoped_ptr<NativePanelTesting> panel3_testing( |
280 CreateNativePanelTesting(panel3)); | 280 CreateNativePanelTesting(panel3)); |
281 | 281 |
282 // Ensure that the layout message can get a chance to be processed so that | 282 // Ensure that the layout message can get a chance to be processed so that |
283 // the button visibility can be updated. | 283 // the button visibility can be updated. |
284 MessageLoop::current()->RunAllPending(); | 284 MessageLoop::current()->RunAllPending(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 SetTestingAreas(gfx::Rect(0, 0, 1200, 900), gfx::Rect()); | 360 SetTestingAreas(gfx::Rect(0, 0, 1200, 900), gfx::Rect()); |
361 | 361 |
362 // Create a test panel with web contents loaded. | 362 // Create a test panel with web contents loaded. |
363 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); | 363 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); |
364 GURL url(ui_test_utils::GetTestUrl( | 364 GURL url(ui_test_utils::GetTestUrl( |
365 FilePath(kTestDir), | 365 FilePath(kTestDir), |
366 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); | 366 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); |
367 params.url = url; | 367 params.url = url; |
368 Panel* panel = CreatePanelWithParams(params); | 368 Panel* panel = CreatePanelWithParams(params); |
369 | 369 |
| 370 // Ensure panel has auto resized to original web content size. |
| 371 // The resize will update the docked panel strip. |
| 372 content::WindowedNotificationObserver initial_resize( |
| 373 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, |
| 374 content::NotificationService::AllSources()); |
| 375 if (panel->GetBounds().height() < panel->TitleOnlyHeight()) |
| 376 initial_resize.Wait(); |
| 377 |
370 // Expand the test page. The resize will update the docked panel strip. | 378 // Expand the test page. The resize will update the docked panel strip. |
371 gfx::Rect initial_bounds = panel->GetBounds(); | 379 gfx::Rect initial_bounds = panel->GetBounds(); |
372 content::WindowedNotificationObserver enlarge( | 380 content::WindowedNotificationObserver enlarge( |
373 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | 381 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, |
374 content::NotificationService::AllSources()); | 382 content::NotificationService::AllSources()); |
375 EXPECT_TRUE(content::ExecuteJavaScript( | 383 EXPECT_TRUE(content::ExecuteJavaScript( |
376 panel->GetWebContents()->GetRenderViewHost(), | 384 panel->GetWebContents()->GetRenderViewHost(), |
377 std::wstring(), | 385 std::wstring(), |
378 L"changeSize(50);")); | 386 L"changeSize(50);")); |
379 enlarge.Wait(); | 387 enlarge.Wait(); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 panel1->Minimize(); | 747 panel1->Minimize(); |
740 panel2->Minimize(); | 748 panel2->Minimize(); |
741 panel3->Minimize(); | 749 panel3->Minimize(); |
742 EXPECT_TRUE(panel1->IsMinimized()); | 750 EXPECT_TRUE(panel1->IsMinimized()); |
743 EXPECT_TRUE(panel2->IsMinimized()); | 751 EXPECT_TRUE(panel2->IsMinimized()); |
744 EXPECT_TRUE(panel3->IsMinimized()); | 752 EXPECT_TRUE(panel3->IsMinimized()); |
745 | 753 |
746 panel1->FlashFrame(true); | 754 panel1->FlashFrame(true); |
747 EXPECT_TRUE(panel1->IsDrawingAttention()); | 755 EXPECT_TRUE(panel1->IsDrawingAttention()); |
748 | 756 |
749 test_panel2->PressLeftMouseButtonTitlebar(panel3->GetBounds().origin(), | 757 test_panel2->PressLeftMouseButtonTitlebar(panel2->GetBounds().origin(), |
750 panel::APPLY_TO_ALL); | 758 panel::APPLY_TO_ALL); |
751 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); | 759 test_panel2->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL); |
752 EXPECT_FALSE(panel1->IsMinimized()); | 760 EXPECT_FALSE(panel1->IsMinimized()); |
753 EXPECT_FALSE(panel2->IsMinimized()); | 761 EXPECT_FALSE(panel2->IsMinimized()); |
754 EXPECT_FALSE(panel3->IsMinimized()); | 762 EXPECT_FALSE(panel3->IsMinimized()); |
755 EXPECT_TRUE(panel1->IsDrawingAttention()); | 763 EXPECT_TRUE(panel1->IsDrawingAttention()); |
756 | 764 |
757 // Restore all panels by clicking on the minimized panel that is drawing | 765 // Restore all panels by clicking on the minimized panel that is drawing |
758 // attention. Verify restore all applies and clears draw attention. | 766 // attention. Verify restore all applies and clears draw attention. |
759 panel1->Minimize(); | 767 panel1->Minimize(); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 Panel* panel = CreatePanel("test panel1"); | 1042 Panel* panel = CreatePanel("test panel1"); |
1035 Panel* panel2 = CreatePanel("test panel2"); | 1043 Panel* panel2 = CreatePanel("test panel2"); |
1036 Panel* panel3 = CreatePanel("test panel3"); | 1044 Panel* panel3 = CreatePanel("test panel3"); |
1037 | 1045 |
1038 scoped_ptr<NativePanelTesting> native_panel_testing( | 1046 scoped_ptr<NativePanelTesting> native_panel_testing( |
1039 CreateNativePanelTesting(panel)); | 1047 CreateNativePanelTesting(panel)); |
1040 | 1048 |
1041 // Test that the attention is drawn and the title-bar is brought up when the | 1049 // Test that the attention is drawn and the title-bar is brought up when the |
1042 // minimized panel is drawing attention. | 1050 // minimized panel is drawing attention. |
1043 panel->Minimize(); | 1051 panel->Minimize(); |
1044 WaitForExpansionStateChanged(panel, Panel::MINIMIZED); | 1052 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
1045 panel->FlashFrame(true); | 1053 panel->FlashFrame(true); |
1046 EXPECT_TRUE(panel->IsDrawingAttention()); | 1054 EXPECT_TRUE(panel->IsDrawingAttention()); |
1047 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | 1055 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
1048 MessageLoop::current()->RunAllPending(); | 1056 MessageLoop::current()->RunAllPending(); |
1049 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 1057 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
1050 | 1058 |
1051 // Test that we cannot bring up other minimized panel if the mouse is over | 1059 // Test that we cannot bring up other minimized panel if the mouse is over |
1052 // the panel that draws attension. | 1060 // the panel that draws attension. |
1053 panel2->Minimize(); | 1061 panel2->Minimize(); |
1054 gfx::Point hover_point(panel->GetBounds().origin()); | 1062 gfx::Point hover_point(panel->GetBounds().origin()); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 panel->Close(); | 1252 panel->Close(); |
1245 } | 1253 } |
1246 | 1254 |
1247 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1255 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, |
1248 MinimizeImmediatelyAfterRestore) { | 1256 MinimizeImmediatelyAfterRestore) { |
1249 CreatePanelParams params("Panel Test", gfx::Rect(), SHOW_AS_ACTIVE); | 1257 CreatePanelParams params("Panel Test", gfx::Rect(), SHOW_AS_ACTIVE); |
1250 Panel* panel = CreatePanelWithParams(params); | 1258 Panel* panel = CreatePanelWithParams(params); |
1251 scoped_ptr<NativePanelTesting> native_panel_testing( | 1259 scoped_ptr<NativePanelTesting> native_panel_testing( |
1252 CreateNativePanelTesting(panel)); | 1260 CreateNativePanelTesting(panel)); |
1253 | 1261 |
| 1262 PanelActiveStateObserver signal(panel, false); |
1254 panel->Minimize(); // this should deactivate. | 1263 panel->Minimize(); // this should deactivate. |
1255 MessageLoop::current()->RunAllPending(); | 1264 signal.Wait(); |
1256 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | |
1257 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 1265 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
1258 | 1266 |
1259 panel->Restore(); | 1267 panel->Restore(); |
1260 MessageLoop::current()->RunAllPending(); | 1268 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
1261 WaitForExpansionStateChanged(panel, Panel::EXPANDED); | |
1262 | 1269 |
1263 // Verify that minimizing a panel right after expansion works. | 1270 // Verify that minimizing a panel right after expansion works. |
1264 panel->Minimize(); | 1271 panel->Minimize(); |
1265 MessageLoop::current()->RunAllPending(); | 1272 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
1266 WaitForExpansionStateChanged(panel, Panel::MINIMIZED); | |
1267 | 1273 |
1268 panel->Close(); | 1274 panel->Close(); |
1269 } | 1275 } |
1270 | 1276 |
1271 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FocusLostOnMinimize) { | 1277 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FocusLostOnMinimize) { |
1272 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); | 1278 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); |
1273 Panel* panel = CreatePanelWithParams(params); | 1279 Panel* panel = CreatePanelWithParams(params); |
1274 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 1280 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
1275 | 1281 |
1276 PanelActiveStateObserver signal(panel, false); | 1282 PanelActiveStateObserver signal(panel, false); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 content::NativeWebKeyboardEvent key_event(key_msg); | 1590 content::NativeWebKeyboardEvent key_event(key_msg); |
1585 key_event.modifiers = content::NativeWebKeyboardEvent::ControlKey; | 1591 key_event.modifiers = content::NativeWebKeyboardEvent::ControlKey; |
1586 #else | 1592 #else |
1587 content::NativeWebKeyboardEvent key_event; | 1593 content::NativeWebKeyboardEvent key_event; |
1588 #endif | 1594 #endif |
1589 panel->HandleKeyboardEvent(key_event); | 1595 panel->HandleKeyboardEvent(key_event); |
1590 signal.Wait(); | 1596 signal.Wait(); |
1591 EXPECT_EQ(0, panel_manager->num_panels()); | 1597 EXPECT_EQ(0, panel_manager->num_panels()); |
1592 } | 1598 } |
1593 | 1599 |
OLD | NEW |