Chromium Code Reviews| 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 class WaitForStableInitialSize : public TestPanelNotificationObserver { |
| 345 // http://crbug.com/145740 | 344 public: |
| 346 #define MAYBE_AutoResize FLAKY_AutoResize | 345 explicit WaitForStableInitialSize(Panel* panel) |
| 347 #else | 346 : TestPanelNotificationObserver( |
| 348 #define MAYBE_AutoResize AutoResize | 347 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, |
| 349 #endif | 348 content::NotificationService::AllSources()), |
| 350 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_AutoResize) { | 349 panel_(panel) {} |
| 350 virtual ~WaitForStableInitialSize() {} | |
| 351 | |
| 352 protected: | |
| 353 virtual bool AtExpectedState() OVERRIDE { | |
| 354 return panel_->GetBounds().height() > panel_->TitleOnlyHeight(); | |
| 355 } | |
| 356 Panel* panel_; | |
| 357 }; | |
| 358 | |
| 359 class WaitForAutoResizeWider : public TestPanelNotificationObserver { | |
| 360 public: | |
| 361 explicit WaitForAutoResizeWider(Panel* panel) | |
| 362 : TestPanelNotificationObserver( | |
| 363 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | |
| 364 content::NotificationService::AllSources()), | |
| 365 panel_(panel), | |
| 366 initial_size_(panel->GetBounds().size()) {} | |
| 367 virtual ~WaitForAutoResizeWider() {} | |
| 368 | |
| 369 protected: | |
| 370 virtual bool AtExpectedState() OVERRIDE { | |
| 371 return panel_->GetBounds().width() > initial_size_.width(); | |
| 372 } | |
| 373 Panel* panel_; | |
| 374 gfx::Size initial_size_; | |
| 375 }; | |
| 376 | |
| 377 class WaitForAutoResizeNarrower : public TestPanelNotificationObserver { | |
| 378 public: | |
| 379 explicit WaitForAutoResizeNarrower(Panel* panel) | |
| 380 : TestPanelNotificationObserver( | |
| 381 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | |
| 382 content::NotificationService::AllSources()), | |
| 383 panel_(panel), | |
| 384 initial_size_(panel->GetBounds().size()) {} | |
| 385 virtual ~WaitForAutoResizeNarrower() {} | |
| 386 | |
| 387 protected: | |
| 388 virtual bool AtExpectedState() OVERRIDE { | |
| 389 return panel_->GetBounds().width() < initial_size_.width(); | |
| 390 } | |
| 391 Panel* panel_; | |
| 392 gfx::Size initial_size_; | |
| 393 }; | |
| 394 | |
| 395 | |
| 396 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AutoResize) { | |
| 351 PanelManager* panel_manager = PanelManager::GetInstance(); | 397 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 352 panel_manager->enable_auto_sizing(true); | 398 panel_manager->enable_auto_sizing(true); |
| 353 // Bigger space is needed by this test. | 399 // Bigger space is needed by this test. |
| 354 SetTestingAreas(gfx::Rect(0, 0, 1200, 900), gfx::Rect()); | 400 SetTestingAreas(gfx::Rect(0, 0, 1200, 900), gfx::Rect()); |
| 355 | 401 |
| 356 // Create a test panel with web contents loaded. | 402 // Create a test panel with web contents loaded. |
| 357 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); | 403 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); |
| 358 GURL url(ui_test_utils::GetTestUrl( | 404 GURL url(ui_test_utils::GetTestUrl( |
| 359 FilePath(kTestDir), | 405 FilePath(kTestDir), |
| 360 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); | 406 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); |
| 361 params.url = url; | 407 params.url = url; |
| 362 Panel* panel = CreatePanelWithParams(params); | 408 Panel* panel = CreatePanelWithParams(params); |
| 363 | 409 |
| 364 // Ensure panel has auto resized to original web content size. | 410 // Ensure panel has auto resized to original web content size. |
| 365 // The resize will update the docked panel strip. | 411 // The resize will update the docked panel strip. |
| 366 content::WindowedNotificationObserver initial_resize( | 412 WaitForStableInitialSize initial_resize(panel); |
| 367 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | 413 initial_resize.Wait(); |
| 368 content::NotificationService::AllSources()); | 414 gfx::Rect initial_bounds = panel->GetBounds(); |
| 369 if (panel->GetBounds().height() < panel->TitleOnlyHeight()) | |
| 370 initial_resize.Wait(); | |
| 371 | 415 |
| 372 // Expand the test page. The resize will update the docked panel strip. | 416 // Expand the test page. The resize will update the docked panel strip. |
| 373 gfx::Rect initial_bounds = panel->GetBounds(); | 417 WaitForAutoResizeWider enlarge(panel); |
| 374 content::WindowedNotificationObserver enlarge( | |
| 375 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | |
| 376 content::NotificationService::AllSources()); | |
| 377 EXPECT_TRUE(content::ExecuteJavaScript( | 418 EXPECT_TRUE(content::ExecuteJavaScript( |
| 378 panel->GetWebContents()->GetRenderViewHost(), | 419 panel->GetWebContents()->GetRenderViewHost(), |
| 379 std::wstring(), | 420 std::wstring(), |
| 380 L"changeSize(50);")); | 421 L"changeSize(50);")); |
| 381 enlarge.Wait(); | 422 enlarge.Wait(); |
| 382 gfx::Rect bounds_on_grow = panel->GetBounds(); | 423 gfx::Rect bounds_on_grow = panel->GetBounds(); |
| 383 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); | 424 EXPECT_GT(bounds_on_grow.width(), initial_bounds.width()); |
| 384 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height()); | 425 EXPECT_EQ(bounds_on_grow.height(), initial_bounds.height()); |
| 385 | 426 |
| 386 // Shrink the test page. The resize will update the docked panel strip. | 427 // Shrink the test page. The resize will update the docked panel strip. |
| 387 content::WindowedNotificationObserver shrink( | 428 WaitForAutoResizeNarrower shrink(panel); |
| 388 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | |
| 389 content::NotificationService::AllSources()); | |
| 390 EXPECT_TRUE(content::ExecuteJavaScript( | 429 EXPECT_TRUE(content::ExecuteJavaScript( |
| 391 panel->GetWebContents()->GetRenderViewHost(), | 430 panel->GetWebContents()->GetRenderViewHost(), |
| 392 std::wstring(), | 431 std::wstring(), |
| 393 L"changeSize(-30);")); | 432 L"changeSize(-30);")); |
| 394 shrink.Wait(); | 433 shrink.Wait(); |
| 395 gfx::Rect bounds_on_shrink = panel->GetBounds(); | 434 gfx::Rect bounds_on_shrink = panel->GetBounds(); |
| 396 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); | 435 EXPECT_LT(bounds_on_shrink.width(), bounds_on_grow.width()); |
| 397 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); | 436 EXPECT_GT(bounds_on_shrink.width(), initial_bounds.width()); |
| 398 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); | 437 EXPECT_EQ(bounds_on_shrink.height(), initial_bounds.height()); |
| 399 | 438 |
| 400 // Verify resizing turns off auto-resizing and panel no longer auto-resizes. | 439 // Verify resizing turns off auto-resizing and panel no longer auto-resizes. |
| 401 gfx::Rect previous_bounds = panel->GetBounds(); | 440 gfx::Rect previous_bounds = panel->GetBounds(); |
| 402 // These should be identical because the panel is expanded. | 441 // These should be identical because the panel is expanded. |
| 403 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size()); | 442 EXPECT_EQ(previous_bounds.size(), panel->GetRestoredBounds().size()); |
| 404 gfx::Size new_size(previous_bounds.size()); | 443 gfx::Size new_size(previous_bounds.size()); |
| 405 new_size.Enlarge(5, 5); | 444 new_size.Enlarge(5, 5); |
| 406 gfx::Rect new_bounds(previous_bounds.origin(), new_size); | 445 gfx::Rect new_bounds(previous_bounds.origin(), new_size); |
| 407 panel->SetBounds(new_bounds); | 446 panel->SetBounds(new_bounds); |
| 408 EXPECT_FALSE(panel->auto_resizable()); | 447 EXPECT_FALSE(panel->auto_resizable()); |
| 409 EXPECT_EQ(new_bounds.size(), panel->GetBounds().size()); | 448 EXPECT_EQ(new_bounds.size(), panel->GetBounds().size()); |
| 410 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size()); | 449 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size()); |
| 411 | 450 |
| 412 // Turn back on auto-resize and verify that panel auto resizes. | 451 // Turn back on auto-resize and verify that panel auto resizes. |
| 413 content::WindowedNotificationObserver auto_resize_enabled( | 452 content::WindowedNotificationObserver auto_resize_enabled( |
| 414 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, | 453 chrome::NOTIFICATION_PANEL_STRIP_UPDATED, |
|
Dmitry Titov
2012/09/13 23:06:21
Should this too be modified?
jennb
2012/09/13 23:10:39
This should only result in one strip update here s
| |
| 415 content::NotificationService::AllSources()); | 454 content::NotificationService::AllSources()); |
| 416 panel->SetAutoResizable(true); | 455 panel->SetAutoResizable(true); |
| 417 auto_resize_enabled.Wait(); | 456 auto_resize_enabled.Wait(); |
| 418 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds(); | 457 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds(); |
| 419 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width()); | 458 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width()); |
| 420 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height()); | 459 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height()); |
| 421 | 460 |
| 422 panel->Close(); | 461 panel->Close(); |
| 423 } | 462 } |
| 424 | 463 |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 docked_strip->StartingRightPosition() - initial_starting_right_position, | 928 docked_strip->StartingRightPosition() - initial_starting_right_position, |
| 890 right_bar_thickness_delta); | 929 right_bar_thickness_delta); |
| 891 EXPECT_EQ(docked_strip->display_area().bottom() - bottom_bar_thickness, | 930 EXPECT_EQ(docked_strip->display_area().bottom() - bottom_bar_thickness, |
| 892 panel->GetBounds().bottom()); | 931 panel->GetBounds().bottom()); |
| 893 EXPECT_EQ(docked_strip->StartingRightPosition(), | 932 EXPECT_EQ(docked_strip->StartingRightPosition(), |
| 894 panel->GetBounds().right()); | 933 panel->GetBounds().right()); |
| 895 | 934 |
| 896 panel->Close(); | 935 panel->Close(); |
| 897 } | 936 } |
| 898 | 937 |
| 899 #if defined(OS_MACOSX) | 938 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ActivatePanelOrTabbedWindow) { |
| 900 // This test doesn't pass on Snow Leopard (10.6), although it works just | 939 Panel* panel1 = CreatePanel("Panel1"); |
| 901 // fine on Lion (10.7). The problem is not having a real run loop around | 940 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 | 941 |
| 914 ASSERT_FALSE(panel1->IsActive()); | |
| 915 ASSERT_TRUE(panel2->IsActive()); | |
| 916 // Activate main tabbed window. | 942 // Activate main tabbed window. |
| 917 browser()->window()->Activate(); | 943 browser()->window()->Activate(); |
| 918 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); | 944 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); |
| 919 | 945 |
| 920 // Activate a panel. | 946 // Activate a panel. |
| 921 panel2->Activate(); | 947 panel2->Activate(); |
| 922 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); | 948 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); |
| 923 | 949 |
| 924 // Activate the main tabbed window back. | 950 // Activate the main tabbed window back. |
| 925 browser()->window()->Activate(); | 951 browser()->window()->Activate(); |
| 926 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); | 952 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 | 953 |
| 931 // Activate another panel. | 954 // Activate another panel. |
| 932 panel1->Activate(); | 955 panel1->Activate(); |
| 933 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); | 956 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); |
| 934 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); | 957 WaitForPanelActiveState(panel2, SHOW_AS_INACTIVE); |
| 935 | 958 |
| 936 // Switch focus between panels. | 959 // Switch focus between panels. |
| 937 panel2->Activate(); | 960 panel2->Activate(); |
| 938 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); | 961 WaitForPanelActiveState(panel2, SHOW_AS_ACTIVE); |
| 939 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE); | 962 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE); |
| 940 | 963 |
| 941 // Close active panel, focus should move to the remaining one. | 964 PanelManager::GetInstance()->CloseAll(); |
| 942 CloseWindowAndWait(panel2); | |
| 943 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); | |
| 944 panel1->Close(); | |
| 945 } | 965 } |
| 946 | 966 |
| 947 // TODO(jianli): To be enabled for other platforms. | 967 // TODO(jianli): To be enabled for other platforms. |
| 948 #if defined(OS_WIN) | 968 #if defined(OS_WIN) |
| 949 #define MAYBE_ActivateDeactivateBasic ActivateDeactivateBasic | 969 #define MAYBE_ActivateDeactivateBasic ActivateDeactivateBasic |
| 950 #else | 970 #else |
| 951 #define MAYBE_ActivateDeactivateBasic DISABLED_ActivateDeactivateBasic | 971 #define MAYBE_ActivateDeactivateBasic DISABLED_ActivateDeactivateBasic |
| 952 #endif | 972 #endif |
| 953 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_ActivateDeactivateBasic) { | 973 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_ActivateDeactivateBasic) { |
| 954 // Create an active panel. | 974 // Create an active panel. |
| 955 Panel* panel = CreatePanel("PanelTest"); | 975 Panel* panel = CreatePanel("PanelTest"); |
| 956 scoped_ptr<NativePanelTesting> native_panel_testing( | 976 scoped_ptr<NativePanelTesting> native_panel_testing( |
| 957 CreateNativePanelTesting(panel)); | 977 CreateNativePanelTesting(panel)); |
| 958 EXPECT_TRUE(panel->IsActive()); | 978 |
| 979 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); // doublecheck active state | |
| 959 EXPECT_TRUE(native_panel_testing->VerifyActiveState(true)); | 980 EXPECT_TRUE(native_panel_testing->VerifyActiveState(true)); |
| 960 | 981 |
| 961 // Deactivate the panel. | 982 // Deactivate the panel. |
| 962 panel->Deactivate(); | 983 panel->Deactivate(); |
| 963 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 984 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
| 964 EXPECT_FALSE(panel->IsActive()); | |
| 965 EXPECT_TRUE(native_panel_testing->VerifyActiveState(false)); | 985 EXPECT_TRUE(native_panel_testing->VerifyActiveState(false)); |
| 966 | 986 |
| 967 // This test does not reactivate the panel because the panel might not be | 987 // This test does not reactivate the panel because the panel might not be |
| 968 // reactivated programmatically once it is deactivated. | 988 // reactivated programmatically once it is deactivated. |
| 969 } | 989 } |
| 970 | 990 |
| 971 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ActivateDeactivateMultiple) { | 991 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ActivateDeactivateMultiple) { |
| 972 BrowserWindow* tabbed_window = browser()->window(); | 992 BrowserWindow* tabbed_window = browser()->window(); |
| 973 | 993 |
| 974 // Create 4 panels in the following screen layout: | 994 // Create 4 panels in the following screen layout: |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1156 | 1176 |
| 1157 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhenActive) { | 1177 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhenActive) { |
| 1158 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); | 1178 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); |
| 1159 Panel* panel = CreatePanelWithParams(params); | 1179 Panel* panel = CreatePanelWithParams(params); |
| 1160 scoped_ptr<NativePanelTesting> native_panel_testing( | 1180 scoped_ptr<NativePanelTesting> native_panel_testing( |
| 1161 CreateNativePanelTesting(panel)); | 1181 CreateNativePanelTesting(panel)); |
| 1162 | 1182 |
| 1163 // Test that the attention should not be drawn if the expanded panel is in | 1183 // Test that the attention should not be drawn if the expanded panel is in |
| 1164 // focus. | 1184 // focus. |
| 1165 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 1185 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
| 1166 EXPECT_TRUE(panel->IsActive()); | 1186 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); // doublecheck active state |
| 1167 EXPECT_FALSE(panel->IsDrawingAttention()); | 1187 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 1168 panel->FlashFrame(true); | 1188 panel->FlashFrame(true); |
| 1169 EXPECT_FALSE(panel->IsDrawingAttention()); | 1189 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 1170 MessageLoop::current()->RunAllPending(); | 1190 MessageLoop::current()->RunAllPending(); |
| 1171 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1191 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
| 1172 | 1192 |
| 1173 panel->Close(); | 1193 panel->Close(); |
| 1174 } | 1194 } |
| 1175 | 1195 |
| 1176 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) { | 1196 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) { |
| 1177 // Create 2 panels so we end up with an inactive panel that can | 1197 // Create 2 panels so we end up with an inactive panel that can |
| 1178 // be made to draw attention. | 1198 // be made to draw attention. |
| 1179 Panel* panel = CreatePanel("test panel1"); | 1199 Panel* panel = CreatePanel("test panel1"); |
| 1180 Panel* panel2 = CreatePanel("test panel2"); | 1200 Panel* panel2 = CreatePanel("test panel2"); |
| 1201 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | |
| 1181 | 1202 |
| 1182 scoped_ptr<NativePanelTesting> native_panel_testing( | 1203 scoped_ptr<NativePanelTesting> native_panel_testing( |
| 1183 CreateNativePanelTesting(panel)); | 1204 CreateNativePanelTesting(panel)); |
| 1184 | 1205 |
| 1185 panel->FlashFrame(true); | 1206 panel->FlashFrame(true); |
| 1186 EXPECT_TRUE(panel->IsDrawingAttention()); | 1207 EXPECT_TRUE(panel->IsDrawingAttention()); |
| 1187 MessageLoop::current()->RunAllPending(); | 1208 MessageLoop::current()->RunAllPending(); |
| 1188 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 1209 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
| 1189 | 1210 |
| 1190 // Test that the attention is cleared when panel gets focus. | 1211 // Test that the attention is cleared when panel gets focus. |
| 1191 panel->Activate(); | 1212 panel->Activate(); |
| 1192 MessageLoop::current()->RunAllPending(); | 1213 MessageLoop::current()->RunAllPending(); |
| 1193 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 1214 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
| 1194 EXPECT_FALSE(panel->IsDrawingAttention()); | 1215 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 1195 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1216 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
| 1196 | 1217 |
| 1197 panel->Close(); | 1218 panel->Close(); |
| 1198 panel2->Close(); | 1219 panel2->Close(); |
| 1199 } | 1220 } |
| 1200 | 1221 |
| 1201 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1222 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, |
| 1202 DrawAttentionMinimizedNotResetOnActivate) { | 1223 DrawAttentionMinimizedNotResetOnActivate) { |
| 1203 // Create 2 panels so we end up with an inactive panel that can | 1224 // Create 2 panels so we end up with an inactive panel that can |
| 1204 // be made to draw attention. | 1225 // be made to draw attention. |
| 1205 Panel* panel1 = CreatePanel("test panel1"); | 1226 Panel* panel1 = CreatePanel("test panel1"); |
| 1206 Panel* panel2 = CreatePanel("test panel2"); | 1227 Panel* panel2 = CreatePanel("test panel2"); |
| 1228 WaitForPanelActiveState(panel1, SHOW_AS_INACTIVE); | |
| 1207 | 1229 |
| 1208 panel1->Minimize(); | 1230 panel1->Minimize(); |
| 1209 EXPECT_TRUE(panel1->IsMinimized()); | 1231 EXPECT_TRUE(panel1->IsMinimized()); |
| 1210 panel1->FlashFrame(true); | 1232 panel1->FlashFrame(true); |
| 1211 EXPECT_TRUE(panel1->IsDrawingAttention()); | 1233 EXPECT_TRUE(panel1->IsDrawingAttention()); |
| 1212 | 1234 |
| 1213 // Simulate panel being activated while minimized. Cannot call | 1235 // Simulate panel being activated while minimized. Cannot call |
| 1214 // Activate() as that expands the panel. | 1236 // Activate() as that expands the panel. |
| 1215 panel1->OnActiveStateChanged(true); | 1237 panel1->OnActiveStateChanged(true); |
| 1216 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. | 1238 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. |
| 1217 | 1239 |
| 1218 // Unminimize panel to show that attention would have been cleared | 1240 // Unminimize panel to show that attention would have been cleared |
| 1219 // if panel had not been minimized. | 1241 // if panel had not been minimized. |
| 1220 panel1->Restore(); | 1242 panel1->Restore(); |
| 1221 EXPECT_FALSE(panel1->IsMinimized()); | 1243 EXPECT_FALSE(panel1->IsMinimized()); |
| 1222 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. | 1244 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. |
| 1223 | 1245 |
| 1224 panel1->OnActiveStateChanged(true); | 1246 panel1->OnActiveStateChanged(true); |
| 1225 EXPECT_FALSE(panel1->IsDrawingAttention()); // Attention cleared. | 1247 EXPECT_FALSE(panel1->IsDrawingAttention()); // Attention cleared. |
| 1226 | 1248 |
| 1227 panel1->Close(); | 1249 panel1->Close(); |
| 1228 panel2->Close(); | 1250 panel2->Close(); |
| 1229 } | 1251 } |
| 1230 | 1252 |
| 1231 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnClick) { | 1253 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnClick) { |
| 1232 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); | 1254 // Create 2 panels so we end up with an inactive panel that can |
| 1233 Panel* panel = CreatePanelWithParams(params); | 1255 // be made to draw attention. |
| 1256 Panel* panel = CreatePanel("test panel1"); | |
| 1257 Panel* panel2 = CreatePanel("test panel2"); | |
| 1258 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | |
| 1259 | |
| 1234 scoped_ptr<NativePanelTesting> native_panel_testing( | 1260 scoped_ptr<NativePanelTesting> native_panel_testing( |
| 1235 CreateNativePanelTesting(panel)); | 1261 CreateNativePanelTesting(panel)); |
| 1236 | 1262 |
| 1237 panel->FlashFrame(true); | 1263 panel->FlashFrame(true); |
| 1238 EXPECT_TRUE(panel->IsDrawingAttention()); | 1264 EXPECT_TRUE(panel->IsDrawingAttention()); |
| 1239 MessageLoop::current()->RunAllPending(); | 1265 MessageLoop::current()->RunAllPending(); |
| 1240 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 1266 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
| 1241 | 1267 |
| 1242 // Test that the attention is cleared when panel gets focus. | 1268 // Test that the attention is cleared when panel gets focus. |
| 1243 native_panel_testing->PressLeftMouseButtonTitlebar( | 1269 native_panel_testing->PressLeftMouseButtonTitlebar( |
| 1244 panel->GetBounds().origin()); | 1270 panel->GetBounds().origin()); |
| 1245 native_panel_testing->ReleaseMouseButtonTitlebar(); | 1271 native_panel_testing->ReleaseMouseButtonTitlebar(); |
| 1246 | 1272 |
| 1247 MessageLoop::current()->RunAllPending(); | 1273 MessageLoop::current()->RunAllPending(); |
| 1248 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 1274 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
| 1249 EXPECT_FALSE(panel->IsDrawingAttention()); | 1275 EXPECT_FALSE(panel->IsDrawingAttention()); |
| 1250 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1276 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
| 1251 | 1277 |
| 1252 panel->Close(); | 1278 panel->Close(); |
| 1279 panel2->Close(); | |
| 1253 } | 1280 } |
| 1254 | 1281 |
| 1255 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1282 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, |
| 1256 MinimizeImmediatelyAfterRestore) { | 1283 MinimizeImmediatelyAfterRestore) { |
| 1257 CreatePanelParams params("Panel Test", gfx::Rect(), SHOW_AS_ACTIVE); | 1284 CreatePanelParams params("Panel Test", gfx::Rect(), SHOW_AS_ACTIVE); |
| 1258 Panel* panel = CreatePanelWithParams(params); | 1285 Panel* panel = CreatePanelWithParams(params); |
| 1259 scoped_ptr<NativePanelTesting> native_panel_testing( | 1286 scoped_ptr<NativePanelTesting> native_panel_testing( |
| 1260 CreateNativePanelTesting(panel)); | 1287 CreateNativePanelTesting(panel)); |
| 1261 | 1288 |
| 1262 PanelActiveStateObserver signal(panel, false); | 1289 PanelActiveStateObserver signal(panel, false); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1589 ::MSG key_msg = { NULL, WM_KEYDOWN, ui::VKEY_W, 0 }; | 1616 ::MSG key_msg = { NULL, WM_KEYDOWN, ui::VKEY_W, 0 }; |
| 1590 content::NativeWebKeyboardEvent key_event(key_msg); | 1617 content::NativeWebKeyboardEvent key_event(key_msg); |
| 1591 key_event.modifiers = content::NativeWebKeyboardEvent::ControlKey; | 1618 key_event.modifiers = content::NativeWebKeyboardEvent::ControlKey; |
| 1592 #else | 1619 #else |
| 1593 content::NativeWebKeyboardEvent key_event; | 1620 content::NativeWebKeyboardEvent key_event; |
| 1594 #endif | 1621 #endif |
| 1595 panel->HandleKeyboardEvent(key_event); | 1622 panel->HandleKeyboardEvent(key_event); |
| 1596 signal.Wait(); | 1623 signal.Wait(); |
| 1597 EXPECT_EQ(0, panel_manager->num_panels()); | 1624 EXPECT_EQ(0, panel_manager->num_panels()); |
| 1598 } | 1625 } |
| OLD | NEW |