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/net/url_request_mock_util.h" | 7 #include "chrome/browser/net/url_request_mock_util.h" |
8 #include "chrome/browser/prefs/browser_prefs.h" | 8 #include "chrome/browser/prefs/browser_prefs.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 | 239 |
240 // The below could be separate tests, just adding a TODO here for tracking. | 240 // The below could be separate tests, just adding a TODO here for tracking. |
241 // TODO(prasadt): Add test for dragging when in titlebar exposed state. | 241 // TODO(prasadt): Add test for dragging when in titlebar exposed state. |
242 // TODO(prasadt): Add test in presence of auto hiding task bar. | 242 // TODO(prasadt): Add test in presence of auto hiding task bar. |
243 | 243 |
244 for (size_t i = 0; i < panels.size(); ++i) | 244 for (size_t i = 0; i < panels.size(); ++i) |
245 delete native_panels_testing[i]; | 245 delete native_panels_testing[i]; |
246 } | 246 } |
247 }; | 247 }; |
248 | 248 |
249 // Flaky (sometimes timeout): http://crbug.com/140971 | 249 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CheckDockedPanelProperties) { |
250 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_CheckDockedPanelProperties) { | |
251 PanelManager* panel_manager = PanelManager::GetInstance(); | 250 PanelManager* panel_manager = PanelManager::GetInstance(); |
252 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 251 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
253 | 252 |
254 // Create 3 docked panels that are in expanded, title-only or minimized states | 253 // Create 3 docked panels that are in expanded, title-only or minimized states |
255 // respectively. | 254 // respectively. |
256 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); | 255 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); |
257 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); | 256 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); |
258 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); | 257 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); |
259 panel2->SetExpansionState(Panel::TITLE_ONLY); | 258 panel2->SetExpansionState(Panel::TITLE_ONLY); |
260 EXPECT_EQ(Panel::TITLE_ONLY, panel2->expansion_state()); | 259 EXPECT_EQ(Panel::TITLE_ONLY, panel2->expansion_state()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 display_settings_provider()->GetDisplayArea(); | 333 display_settings_provider()->GetDisplayArea(); |
335 Panel* panel = CreatePanelWithBounds("BigPanel", work_area); | 334 Panel* panel = CreatePanelWithBounds("BigPanel", work_area); |
336 gfx::Rect bounds = panel->GetBounds(); | 335 gfx::Rect bounds = panel->GetBounds(); |
337 EXPECT_EQ(panel->max_size().width(), bounds.width()); | 336 EXPECT_EQ(panel->max_size().width(), bounds.width()); |
338 EXPECT_LT(bounds.width(), work_area.width()); | 337 EXPECT_LT(bounds.width(), work_area.width()); |
339 EXPECT_EQ(panel->max_size().height(), bounds.height()); | 338 EXPECT_EQ(panel->max_size().height(), bounds.height()); |
340 EXPECT_LT(bounds.height(), work_area.height()); | 339 EXPECT_LT(bounds.height(), work_area.height()); |
341 panel->Close(); | 340 panel->Close(); |
342 } | 341 } |
343 | 342 |
344 #if defined(OS_LINUX) | 343 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AutoResize) { |
345 // http://crbug.com/145740 | |
346 #define MAYBE_AutoResize FLAKY_AutoResize | |
347 #else | |
348 #define MAYBE_AutoResize AutoResize | |
349 #endif | |
350 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_AutoResize) { | |
351 PanelManager* panel_manager = PanelManager::GetInstance(); | 344 PanelManager* panel_manager = PanelManager::GetInstance(); |
352 panel_manager->enable_auto_sizing(true); | 345 panel_manager->enable_auto_sizing(true); |
353 // Bigger space is needed by this test. | 346 // Bigger space is needed by this test. |
354 SetTestingAreas(gfx::Rect(0, 0, 1200, 900), gfx::Rect()); | 347 SetTestingAreas(gfx::Rect(0, 0, 1200, 900), gfx::Rect()); |
355 | 348 |
356 // Create a test panel with web contents loaded. | 349 // Create a test panel with web contents loaded. |
357 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); | 350 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); |
358 GURL url(ui_test_utils::GetTestUrl( | 351 GURL url(ui_test_utils::GetTestUrl( |
359 FilePath(kTestDir), | 352 FilePath(kTestDir), |
360 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); | 353 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); |
361 params.url = url; | 354 params.url = url; |
362 Panel* panel = CreatePanelWithParams(params); | 355 Panel* panel = CreatePanelWithParams(params); |
363 | 356 |
364 // Ensure panel has auto resized to original web content size. | 357 // Ensure panel has auto resized to original web content size. |
365 // The resize will update the docked panel strip. | 358 // The resize will update the docked panel strip. |
366 content::WindowedNotificationObserver initial_resize( | 359 content::WindowedNotificationObserver initial_resize( |
367 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | 360 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, |
368 content::NotificationService::AllSources()); | 361 content::NotificationService::AllSources()); |
369 if (panel->GetBounds().height() < panel->TitleOnlyHeight()) | 362 if (panel->GetBounds().height() < panel->TitleOnlyHeight()) |
jennb
2012/09/13 00:45:34
This test may have been flaky due to GTK returning
| |
370 initial_resize.Wait(); | 363 initial_resize.Wait(); |
371 | 364 |
372 // Expand the test page. The resize will update the docked panel strip. | 365 // Expand the test page. The resize will update the docked panel strip. |
373 gfx::Rect initial_bounds = panel->GetBounds(); | 366 gfx::Rect initial_bounds = panel->GetBounds(); |
374 content::WindowedNotificationObserver enlarge( | 367 content::WindowedNotificationObserver enlarge( |
375 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | 368 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, |
376 content::NotificationService::AllSources()); | 369 content::NotificationService::AllSources()); |
377 EXPECT_TRUE(content::ExecuteJavaScript( | 370 EXPECT_TRUE(content::ExecuteJavaScript( |
378 panel->GetWebContents()->GetRenderViewHost(), | 371 panel->GetWebContents()->GetRenderViewHost(), |
379 std::wstring(), | 372 std::wstring(), |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
889 docked_strip->StartingRightPosition() - initial_starting_right_position, | 882 docked_strip->StartingRightPosition() - initial_starting_right_position, |
890 right_bar_thickness_delta); | 883 right_bar_thickness_delta); |
891 EXPECT_EQ(docked_strip->display_area().bottom() - bottom_bar_thickness, | 884 EXPECT_EQ(docked_strip->display_area().bottom() - bottom_bar_thickness, |
892 panel->GetBounds().bottom()); | 885 panel->GetBounds().bottom()); |
893 EXPECT_EQ(docked_strip->StartingRightPosition(), | 886 EXPECT_EQ(docked_strip->StartingRightPosition(), |
894 panel->GetBounds().right()); | 887 panel->GetBounds().right()); |
895 | 888 |
896 panel->Close(); | 889 panel->Close(); |
897 } | 890 } |
898 | 891 |
899 #if defined(OS_MACOSX) | 892 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ActivatePanelOrTabbedWindow) { |
900 // This test doesn't pass on Snow Leopard (10.6), although it works just | 893 Panel* panel1 = CreatePanel("Panel1"); |
Dmitry Titov
2012/09/13 18:19:00
I wonder why do we need panel1 here?
| |
901 // fine on Lion (10.7). The problem is not having a real run loop around | 894 Panel* panel2 = CreatePanel("Panel2"); |
902 // the window close is at fault, given how window controllers in Chrome | |
903 // autorelease themselves on a -performSelector:withObject:afterDelay: | |
904 #define MAYBE_ActivatePanelOrTabbedWindow DISABLED_ActivatePanelOrTabbedWindow | |
905 #else | |
906 #define MAYBE_ActivatePanelOrTabbedWindow DISABLED_ActivatePanelOrTabbedWindow | |
907 #endif | |
908 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_ActivatePanelOrTabbedWindow) { | |
909 CreatePanelParams params1("Panel1", gfx::Rect(), SHOW_AS_ACTIVE); | |
910 Panel* panel1 = CreatePanelWithParams(params1); | |
911 CreatePanelParams params2("Panel2", gfx::Rect(), SHOW_AS_ACTIVE); | |
912 Panel* panel2 = CreatePanelWithParams(params2); | |
913 | 895 |
914 ASSERT_FALSE(panel1->IsActive()); | |
915 ASSERT_TRUE(panel2->IsActive()); | |
916 // Activate main tabbed window. | 896 // Activate main tabbed window. |
917 browser()->window()->Activate(); | 897 browser()->window()->Activate(); |
918 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); | 898 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); |
919 | 899 |
920 // Activate a panel. | 900 // Activate a panel. |
921 panel2->Activate(); | 901 panel2->Activate(); |
922 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); | 902 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); |
923 | 903 |
924 // Activate the main tabbed window back. | 904 // Activate the main tabbed window back. |
925 browser()->window()->Activate(); | 905 browser()->window()->Activate(); |
926 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); | 906 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); |
927 // Close the main tabbed window. That should move focus back to panel. | |
928 chrome::CloseWindow(browser()); | |
929 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); | |
930 | 907 |
931 // Activate another panel. | 908 // Activate another panel. |
932 panel1->Activate(); | 909 panel1->Activate(); |
933 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); | 910 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); |
934 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); | 911 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); |
935 | 912 |
936 // Switch focus between panels. | 913 // Switch focus between panels. |
937 panel2->Activate(); | 914 panel2->Activate(); |
938 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); | 915 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); |
939 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE); | 916 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE); |
940 | 917 |
941 // Close active panel, focus should move to the remaining one. | 918 PanelManager::GetInstance()->CloseAll(); |
942 CloseWindowAndWait(panel2); | |
943 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); | |
944 panel1->Close(); | |
945 } | 919 } |
946 | 920 |
947 // TODO(jianli): To be enabled for other platforms. | 921 // TODO(jianli): To be enabled for other platforms. |
948 #if defined(OS_WIN) | 922 #if defined(OS_WIN) |
949 #define MAYBE_ActivateDeactivateBasic ActivateDeactivateBasic | 923 #define MAYBE_ActivateDeactivateBasic ActivateDeactivateBasic |
950 #else | 924 #else |
951 #define MAYBE_ActivateDeactivateBasic DISABLED_ActivateDeactivateBasic | 925 #define MAYBE_ActivateDeactivateBasic DISABLED_ActivateDeactivateBasic |
952 #endif | 926 #endif |
953 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_ActivateDeactivateBasic) { | 927 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_ActivateDeactivateBasic) { |
954 // Create an active panel. | 928 // Create an active panel. |
955 Panel* panel = CreatePanel("PanelTest"); | 929 Panel* panel = CreatePanel("PanelTest"); |
956 scoped_ptr<NativePanelTesting> native_panel_testing( | 930 scoped_ptr<NativePanelTesting> native_panel_testing( |
957 CreateNativePanelTesting(panel)); | 931 CreateNativePanelTesting(panel)); |
958 EXPECT_TRUE(panel->IsActive()); | 932 |
933 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); // doublecheck active state | |
959 EXPECT_TRUE(native_panel_testing->VerifyActiveState(true)); | 934 EXPECT_TRUE(native_panel_testing->VerifyActiveState(true)); |
960 | 935 |
961 // Deactivate the panel. | 936 // Deactivate the panel. |
962 panel->Deactivate(); | 937 panel->Deactivate(); |
963 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 938 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
964 EXPECT_FALSE(panel->IsActive()); | |
965 EXPECT_TRUE(native_panel_testing->VerifyActiveState(false)); | 939 EXPECT_TRUE(native_panel_testing->VerifyActiveState(false)); |
966 | 940 |
967 // This test does not reactivate the panel because the panel might not be | 941 // This test does not reactivate the panel because the panel might not be |
968 // reactivated programmatically once it is deactivated. | 942 // reactivated programmatically once it is deactivated. |
969 } | 943 } |
970 | 944 |
971 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ActivateDeactivateMultiple) { | 945 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ActivateDeactivateMultiple) { |
972 BrowserWindow* tabbed_window = browser()->window(); | 946 BrowserWindow* tabbed_window = browser()->window(); |
973 | 947 |
974 // Create 4 panels in the following screen layout: | 948 // Create 4 panels in the following screen layout: |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1589 ::MSG key_msg = { NULL, WM_KEYDOWN, ui::VKEY_W, 0 }; | 1563 ::MSG key_msg = { NULL, WM_KEYDOWN, ui::VKEY_W, 0 }; |
1590 content::NativeWebKeyboardEvent key_event(key_msg); | 1564 content::NativeWebKeyboardEvent key_event(key_msg); |
1591 key_event.modifiers = content::NativeWebKeyboardEvent::ControlKey; | 1565 key_event.modifiers = content::NativeWebKeyboardEvent::ControlKey; |
1592 #else | 1566 #else |
1593 content::NativeWebKeyboardEvent key_event; | 1567 content::NativeWebKeyboardEvent key_event; |
1594 #endif | 1568 #endif |
1595 panel->HandleKeyboardEvent(key_event); | 1569 panel->HandleKeyboardEvent(key_event); |
1596 signal.Wait(); | 1570 signal.Wait(); |
1597 EXPECT_EQ(0, panel_manager->num_panels()); | 1571 EXPECT_EQ(0, panel_manager->num_panels()); |
1598 } | 1572 } |
OLD | NEW |