Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/ui/panels/old_panel_browsertest.cc

Issue 10836159: Fix bug 141013: OldPanelBrowserTest.CheckDockedPanelProperties is flaky (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 13 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
14 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 14 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_commands.h" 16 #include "chrome/browser/ui/browser_commands.h"
17 #include "chrome/browser/ui/browser_list.h" 17 #include "chrome/browser/ui/browser_list.h"
18 #include "chrome/browser/ui/browser_tabstrip.h" 18 #include "chrome/browser/ui/browser_tabstrip.h"
19 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/find_bar/find_bar.h" 20 #include "chrome/browser/ui/find_bar/find_bar.h"
21 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 21 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
22 #include "chrome/browser/ui/panels/old_base_panel_browser_test.h" 22 #include "chrome/browser/ui/panels/old_base_panel_browser_test.h"
23 #include "chrome/browser/ui/panels/docked_panel_strip.h" 23 #include "chrome/browser/ui/panels/docked_panel_strip.h"
24 #include "chrome/browser/ui/panels/native_panel.h" 24 #include "chrome/browser/ui/panels/native_panel.h"
25 #include "chrome/browser/ui/panels/panel.h" 25 #include "chrome/browser/ui/panels/panel.h"
26 #include "chrome/browser/ui/panels/panel_manager.h" 26 #include "chrome/browser/ui/panels/panel_manager.h"
27 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h"
28 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
29 #include "chrome/browser/web_applications/web_app.h" 28 #include "chrome/browser/web_applications/web_app.h"
30 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/extensions/extension_manifest_constants.h" 30 #include "chrome/common/extensions/extension_manifest_constants.h"
32 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
33 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
34 #include "chrome/test/base/ui_test_utils.h" 33 #include "chrome/test/base/ui_test_utils.h"
35 #include "content/public/browser/download_manager.h" 34 #include "content/public/browser/download_manager.h"
36 #include "content/public/browser/notification_service.h" 35 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 249
251 // 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.
252 // TODO(prasadt): Add test for dragging when in titlebar exposed state. 251 // TODO(prasadt): Add test for dragging when in titlebar exposed state.
253 // TODO(prasadt): Add test in presence of auto hiding task bar. 252 // TODO(prasadt): Add test in presence of auto hiding task bar.
254 253
255 for (size_t i = 0; i < panels.size(); ++i) 254 for (size_t i = 0; i < panels.size(); ++i)
256 delete native_panels_testing[i]; 255 delete native_panels_testing[i];
257 } 256 }
258 }; 257 };
259 258
260 // http://crbug.com/141013 259 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, CheckDockedPanelProperties) {
261 #if defined(OS_WIN)
262 #define MAYBE_CheckDockedPanelProperties DISABLED_CheckDockedPanelProperties
263 #else
264 #define MAYBE_CheckDockedPanelProperties CheckDockedPanelProperties
265 #endif
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // Set bounds without animation. 467 // Set bounds without animation.
475 bounds = gfx::Rect(30, 40, 200, 220); 468 bounds = gfx::Rect(30, 40, 200, 220);
476 panel->SetPanelBoundsInstantly(bounds); 469 panel->SetPanelBoundsInstantly(bounds);
477 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); 470 EXPECT_FALSE(panel_testing->IsAnimatingBounds());
478 EXPECT_EQ(bounds, panel->GetBounds()); 471 EXPECT_EQ(bounds, panel->GetBounds());
479 472
480 panel->Close(); 473 panel->Close();
481 } 474 }
482 475
483 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, RestoredBounds) { 476 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, RestoredBounds) {
484 // Disable mouse watcher. We don't care about mouse movements in this test.
485 PanelManager* panel_manager = PanelManager::GetInstance();
486 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
487 panel_manager->SetMouseWatcherForTesting(mouse_watcher);
488 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); 477 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100));
489 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); 478 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state());
490 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); 479 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds());
491 480
492 panel->SetExpansionState(Panel::MINIMIZED); 481 panel->SetExpansionState(Panel::MINIMIZED);
493 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); 482 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state());
494 gfx::Rect bounds = panel->GetBounds(); 483 gfx::Rect bounds = panel->GetBounds();
495 gfx::Rect restored = panel->GetRestoredBounds(); 484 gfx::Rect restored = panel->GetRestoredBounds();
496 EXPECT_EQ(bounds.x(), restored.x()); 485 EXPECT_EQ(bounds.x(), restored.x());
497 EXPECT_GT(bounds.y(), restored.y()); 486 EXPECT_GT(bounds.y(), restored.y());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 bounds = gfx::Rect(40, 60, 300, 400); 524 bounds = gfx::Rect(40, 60, 300, 400);
536 panel->SetPanelBounds(bounds); 525 panel->SetPanelBounds(bounds);
537 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); 526 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height());
538 panel->set_full_size(bounds.size()); 527 panel->set_full_size(bounds.size());
539 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); 528 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height());
540 529
541 panel->Close(); 530 panel->Close();
542 } 531 }
543 532
544 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestore) { 533 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestore) {
545 // We'll simulate mouse movements for test.
546 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
547 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher);
548
549 // Test with one panel. 534 // Test with one panel.
550 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); 535 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100));
551 TestMinimizeRestore(); 536 TestMinimizeRestore();
552 537
553 PanelManager::GetInstance()->CloseAll(); 538 PanelManager::GetInstance()->CloseAll();
554 } 539 }
555 540
556 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestoreTwoPanels) { 541 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestoreTwoPanels) {
557 // We'll simulate mouse movements for test.
558 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
559 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher);
560
561 // Test with two panels. 542 // Test with two panels.
562 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); 543 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100));
563 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); 544 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110));
564 TestMinimizeRestore(); 545 TestMinimizeRestore();
565 546
566 PanelManager::GetInstance()->CloseAll(); 547 PanelManager::GetInstance()->CloseAll();
567 } 548 }
568 549
569 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestoreThreePanels) { 550 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestoreThreePanels) {
570 // We'll simulate mouse movements for test.
571 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
572 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher);
573
574 // Test with three panels. 551 // Test with three panels.
575 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); 552 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100));
576 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); 553 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110));
577 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); 554 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120));
578 TestMinimizeRestore(); 555 TestMinimizeRestore();
579 556
580 PanelManager::GetInstance()->CloseAll(); 557 PanelManager::GetInstance()->CloseAll();
581 } 558 }
582 559
583 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestoreButtonClick) { 560 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestoreButtonClick) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 EXPECT_TRUE(panel3->IsMinimized()); 598 EXPECT_TRUE(panel3->IsMinimized());
622 599
623 // Restore all panels by clicking restore button on a minimized panel. 600 // Restore all panels by clicking restore button on a minimized panel.
624 panel3->OnRestoreButtonClicked(panel::APPLY_TO_ALL); 601 panel3->OnRestoreButtonClicked(panel::APPLY_TO_ALL);
625 EXPECT_FALSE(panel1->IsMinimized()); 602 EXPECT_FALSE(panel1->IsMinimized());
626 EXPECT_FALSE(panel2->IsMinimized()); 603 EXPECT_FALSE(panel2->IsMinimized());
627 EXPECT_FALSE(panel3->IsMinimized()); 604 EXPECT_FALSE(panel3->IsMinimized());
628 } 605 }
629 606
630 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, RestoreAllWithTitlebarClick) { 607 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, RestoreAllWithTitlebarClick) {
631 // We'll simulate mouse movements for test.
632 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
633 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher);
634
635 // Test with three panels. 608 // Test with three panels.
636 Panel* panel1 = CreatePanel("PanelTest1"); 609 Panel* panel1 = CreatePanel("PanelTest1");
637 Panel* panel2 = CreatePanel("PanelTest2"); 610 Panel* panel2 = CreatePanel("PanelTest2");
638 Panel* panel3 = CreatePanel("PanelTest3"); 611 Panel* panel3 = CreatePanel("PanelTest3");
639 EXPECT_FALSE(panel1->IsMinimized()); 612 EXPECT_FALSE(panel1->IsMinimized());
640 EXPECT_FALSE(panel2->IsMinimized()); 613 EXPECT_FALSE(panel2->IsMinimized());
641 EXPECT_FALSE(panel3->IsMinimized()); 614 EXPECT_FALSE(panel3->IsMinimized());
642 615
643 scoped_ptr<NativePanelTesting> test_panel1( 616 scoped_ptr<NativePanelTesting> test_panel1(
644 CreateNativePanelTesting(panel1)); 617 CreateNativePanelTesting(panel1));
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 934
962 // Stop drawing attention. Titlebar should no longer be visible. 935 // Stop drawing attention. Titlebar should no longer be visible.
963 panel->FlashFrame(false); 936 panel->FlashFrame(false);
964 EXPECT_FALSE(panel->IsDrawingAttention()); 937 EXPECT_FALSE(panel->IsDrawingAttention());
965 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); 938 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state());
966 939
967 panel->Close(); 940 panel->Close();
968 } 941 }
969 942
970 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionWhileMinimized) { 943 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionWhileMinimized) {
971 // We'll simulate mouse movements for test.
972 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
973 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher);
974
975 // Create 3 panels so we end up with an inactive panel that can 944 // Create 3 panels so we end up with an inactive panel that can
976 // be made to draw attention. 945 // be made to draw attention.
977 Panel* panel = CreatePanel("test panel1"); 946 Panel* panel = CreatePanel("test panel1");
978 Panel* panel2 = CreatePanel("test panel2"); 947 Panel* panel2 = CreatePanel("test panel2");
979 Panel* panel3 = CreatePanel("test panel3"); 948 Panel* panel3 = CreatePanel("test panel3");
980 949
981 scoped_ptr<NativePanelTesting> native_panel_testing( 950 scoped_ptr<NativePanelTesting> native_panel_testing(
982 CreateNativePanelTesting(panel)); 951 CreateNativePanelTesting(panel));
983 952
984 // Test that the attention is drawn and the title-bar is brought up when the 953 // Test that the attention is drawn and the title-bar is brought up when the
(...skipping 29 matching lines...) Expand all
1014 983
1015 panel->Close(); 984 panel->Close();
1016 panel2->Close(); 985 panel2->Close();
1017 panel3->Close(); 986 panel3->Close();
1018 } 987 }
1019 988
1020 // Verify that minimized state of a panel is correct after draw attention 989 // Verify that minimized state of a panel is correct after draw attention
1021 // is stopped when there are other minimized panels. 990 // is stopped when there are other minimized panels.
1022 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, 991 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest,
1023 StopDrawingAttentionWhileMinimized) { 992 StopDrawingAttentionWhileMinimized) {
1024 // We'll simulate mouse movements for test.
1025 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher();
1026 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher);
1027
1028 Panel* panel1 = CreatePanel("panel1"); 993 Panel* panel1 = CreatePanel("panel1");
1029 Panel* panel2 = CreatePanel("panel2"); 994 Panel* panel2 = CreatePanel("panel2");
1030 995
1031 panel1->Minimize(); 996 panel1->Minimize();
1032 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); 997 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state());
1033 panel2->Minimize(); 998 panel2->Minimize();
1034 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state()); 999 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state());
1035 1000
1036 // Verify panel returns to minimized state when no longer drawing attention. 1001 // Verify panel returns to minimized state when no longer drawing attention.
1037 panel1->FlashFrame(true); 1002 panel1->FlashFrame(true);
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 EXPECT_GE(smaller_work_area_size.width(), panel->max_size().width()); 1497 EXPECT_GE(smaller_work_area_size.width(), panel->max_size().width());
1533 EXPECT_EQ(smaller_work_area_size.height(), panel->max_size().height()); 1498 EXPECT_EQ(smaller_work_area_size.height(), panel->max_size().height());
1534 EXPECT_GT(old_full_size.width(), panel->full_size().width()); 1499 EXPECT_GT(old_full_size.width(), panel->full_size().width());
1535 EXPECT_GT(old_full_size.height(), panel->full_size().height()); 1500 EXPECT_GT(old_full_size.height(), panel->full_size().height());
1536 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); 1501 EXPECT_GE(panel->max_size().width(), panel->full_size().width());
1537 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); 1502 EXPECT_GE(panel->max_size().height(), panel->full_size().height());
1538 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); 1503 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height());
1539 1504
1540 panel->Close(); 1505 panel->Close();
1541 } 1506 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698