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" |
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_finder.h" | 15 #include "chrome/browser/ui/browser_finder.h" |
16 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/browser/ui/find_bar/find_bar.h" | 18 #include "chrome/browser/ui/find_bar/find_bar.h" |
19 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 19 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
20 #include "chrome/browser/ui/panels/base_panel_browser_test.h" | 20 #include "chrome/browser/ui/panels/old_base_panel_browser_test.h" |
21 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 21 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
22 #include "chrome/browser/ui/panels/native_panel.h" | 22 #include "chrome/browser/ui/panels/native_panel.h" |
23 #include "chrome/browser/ui/panels/panel.h" | 23 #include "chrome/browser/ui/panels/panel.h" |
24 #include "chrome/browser/ui/panels/panel_manager.h" | 24 #include "chrome/browser/ui/panels/panel_manager.h" |
25 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" | 25 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" |
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
27 #include "chrome/browser/web_applications/web_app.h" | 27 #include "chrome/browser/web_applications/web_app.h" |
28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
29 #include "chrome/common/extensions/extension_manifest_constants.h" | 29 #include "chrome/common/extensions/extension_manifest_constants.h" |
30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
32 #include "chrome/test/base/ui_test_utils.h" | 32 #include "chrome/test/base/ui_test_utils.h" |
33 #include "content/public/browser/download_manager.h" | 33 #include "content/public/browser/download_manager.h" |
34 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
36 #include "content/public/common/url_constants.h" | 36 #include "content/public/common/url_constants.h" |
37 #include "content/test/net/url_request_mock_http_job.h" | 37 #include "content/test/net/url_request_mock_http_job.h" |
38 #include "net/base/net_util.h" | 38 #include "net/base/net_util.h" |
39 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
40 #include "ui/gfx/screen.h" | 40 #include "ui/gfx/screen.h" |
41 | 41 |
42 using content::BrowserContext; | 42 using content::BrowserContext; |
43 using content::BrowserThread; | 43 using content::BrowserThread; |
44 using content::DownloadItem; | 44 using content::DownloadItem; |
45 using content::DownloadManager; | 45 using content::DownloadManager; |
46 using content::WebContents; | 46 using content::WebContents; |
47 using extensions::Extension; | 47 using extensions::Extension; |
48 | 48 |
49 class PanelBrowserTest : public BasePanelBrowserTest { | 49 class OldPanelBrowserTest : public OldBasePanelBrowserTest { |
50 public: | 50 public: |
51 PanelBrowserTest() : BasePanelBrowserTest() { | 51 OldPanelBrowserTest() : OldBasePanelBrowserTest() { |
52 } | 52 } |
53 | 53 |
54 protected: | 54 protected: |
55 // Helper function for debugging. | 55 // Helper function for debugging. |
56 void PrintAllPanelBounds() { | 56 void PrintAllPanelBounds() { |
57 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels(); | 57 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels(); |
58 DLOG(WARNING) << "PanelBounds:"; | 58 DLOG(WARNING) << "PanelBounds:"; |
59 for (size_t i = 0; i < panels.size(); ++i) { | 59 for (size_t i = 0; i < panels.size(); ++i) { |
60 DLOG(WARNING) << "#=" << i | 60 DLOG(WARNING) << "#=" << i |
61 << ", ptr=" << panels[i] | 61 << ", ptr=" << panels[i] |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 // The below could be separate tests, just adding a TODO here for tracking. | 249 // The below could be separate tests, just adding a TODO here for tracking. |
250 // TODO(prasadt): Add test for dragging when in titlebar exposed state. | 250 // TODO(prasadt): Add test for dragging when in titlebar exposed state. |
251 // TODO(prasadt): Add test in presence of auto hiding task bar. | 251 // TODO(prasadt): Add test in presence of auto hiding task bar. |
252 | 252 |
253 for (size_t i = 0; i < panels.size(); ++i) | 253 for (size_t i = 0; i < panels.size(); ++i) |
254 delete native_panels_testing[i]; | 254 delete native_panels_testing[i]; |
255 } | 255 } |
256 }; | 256 }; |
257 | 257 |
258 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CheckDockedPanelProperties) { | 258 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, CheckDockedPanelProperties) { |
259 PanelManager* panel_manager = PanelManager::GetInstance(); | 259 PanelManager* panel_manager = PanelManager::GetInstance(); |
260 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 260 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
261 | 261 |
262 // Create 3 docked panels that are in expanded, title-only or minimized states | 262 // Create 3 docked panels that are in expanded, title-only or minimized states |
263 // respectively. | 263 // respectively. |
264 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); | 264 Panel* panel1 = CreatePanelWithBounds("1", gfx::Rect(0, 0, 100, 100)); |
265 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); | 265 Panel* panel2 = CreatePanelWithBounds("2", gfx::Rect(0, 0, 100, 100)); |
266 panel2->SetExpansionState(Panel::TITLE_ONLY); | 266 panel2->SetExpansionState(Panel::TITLE_ONLY); |
267 WaitForExpansionStateChanged(panel2, Panel::TITLE_ONLY); | 267 WaitForExpansionStateChanged(panel2, Panel::TITLE_ONLY); |
268 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); | 268 Panel* panel3 = CreatePanelWithBounds("3", gfx::Rect(0, 0, 100, 100)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 EXPECT_EQ(panel::NOT_RESIZABLE, panel2->CanResizeByMouse()); | 309 EXPECT_EQ(panel::NOT_RESIZABLE, panel2->CanResizeByMouse()); |
310 EXPECT_EQ(panel::NOT_RESIZABLE, panel3->CanResizeByMouse()); | 310 EXPECT_EQ(panel::NOT_RESIZABLE, panel3->CanResizeByMouse()); |
311 | 311 |
312 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel1->attention_mode()); | 312 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel1->attention_mode()); |
313 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel2->attention_mode()); | 313 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel2->attention_mode()); |
314 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel3->attention_mode()); | 314 EXPECT_EQ(Panel::USE_PANEL_ATTENTION, panel3->attention_mode()); |
315 | 315 |
316 panel_manager->CloseAll(); | 316 panel_manager->CloseAll(); |
317 } | 317 } |
318 | 318 |
319 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreatePanel) { | 319 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, CreatePanel) { |
320 PanelManager* panel_manager = PanelManager::GetInstance(); | 320 PanelManager* panel_manager = PanelManager::GetInstance(); |
321 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. | 321 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. |
322 | 322 |
323 Panel* panel = CreatePanel("PanelTest"); | 323 Panel* panel = CreatePanel("PanelTest"); |
324 EXPECT_EQ(1, panel_manager->num_panels()); | 324 EXPECT_EQ(1, panel_manager->num_panels()); |
325 | 325 |
326 gfx::Rect bounds = panel->GetBounds(); | 326 gfx::Rect bounds = panel->GetBounds(); |
327 EXPECT_GT(bounds.x(), 0); | 327 EXPECT_GT(bounds.x(), 0); |
328 EXPECT_GT(bounds.y(), 0); | 328 EXPECT_GT(bounds.y(), 0); |
329 EXPECT_GT(bounds.width(), 0); | 329 EXPECT_GT(bounds.width(), 0); |
330 EXPECT_GT(bounds.height(), 0); | 330 EXPECT_GT(bounds.height(), 0); |
331 | 331 |
332 EXPECT_EQ(bounds.right(), | 332 EXPECT_EQ(bounds.right(), |
333 panel_manager->docked_strip()->StartingRightPosition()); | 333 panel_manager->docked_strip()->StartingRightPosition()); |
334 | 334 |
335 CloseWindowAndWait(panel); | 335 CloseWindowAndWait(panel); |
336 | 336 |
337 EXPECT_EQ(0, panel_manager->num_panels()); | 337 EXPECT_EQ(0, panel_manager->num_panels()); |
338 } | 338 } |
339 | 339 |
340 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateBigPanel) { | 340 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, CreateBigPanel) { |
341 gfx::Rect work_area = PanelManager::GetInstance()-> | 341 gfx::Rect work_area = PanelManager::GetInstance()-> |
342 display_settings_provider()->GetDisplayArea(); | 342 display_settings_provider()->GetDisplayArea(); |
343 Panel* panel = CreatePanelWithBounds("BigPanel", work_area); | 343 Panel* panel = CreatePanelWithBounds("BigPanel", work_area); |
344 gfx::Rect bounds = panel->GetBounds(); | 344 gfx::Rect bounds = panel->GetBounds(); |
345 EXPECT_EQ(panel->max_size().width(), bounds.width()); | 345 EXPECT_EQ(panel->max_size().width(), bounds.width()); |
346 EXPECT_LT(bounds.width(), work_area.width()); | 346 EXPECT_LT(bounds.width(), work_area.width()); |
347 EXPECT_EQ(panel->max_size().height(), bounds.height()); | 347 EXPECT_EQ(panel->max_size().height(), bounds.height()); |
348 EXPECT_LT(bounds.height(), work_area.height()); | 348 EXPECT_LT(bounds.height(), work_area.height()); |
349 panel->Close(); | 349 panel->Close(); |
350 } | 350 } |
351 | 351 |
352 // Flaky: http://crbug.com/105445 | 352 // Flaky: http://crbug.com/105445 |
353 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_AutoResize) { | 353 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DISABLED_AutoResize) { |
354 PanelManager* panel_manager = PanelManager::GetInstance(); | 354 PanelManager* panel_manager = PanelManager::GetInstance(); |
355 panel_manager->enable_auto_sizing(true); | 355 panel_manager->enable_auto_sizing(true); |
356 // Bigger space is needed by this test. | 356 // Bigger space is needed by this test. |
357 SetTestingAreas(gfx::Rect(0, 0, 1200, 900), gfx::Rect()); | 357 SetTestingAreas(gfx::Rect(0, 0, 1200, 900), gfx::Rect()); |
358 | 358 |
359 // Create a test panel with tab contents loaded. | 359 // Create a test panel with tab contents loaded. |
360 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); | 360 CreatePanelParams params("PanelTest1", gfx::Rect(), SHOW_AS_ACTIVE); |
361 GURL url(ui_test_utils::GetTestUrl( | 361 GURL url(ui_test_utils::GetTestUrl( |
362 FilePath(kTestDir), | 362 FilePath(kTestDir), |
363 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); | 363 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 content::Source<Panel>(panel)); | 410 content::Source<Panel>(panel)); |
411 panel->SetAutoResizable(true); | 411 panel->SetAutoResizable(true); |
412 auto_resize_enabled.Wait(); | 412 auto_resize_enabled.Wait(); |
413 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds(); | 413 gfx::Rect bounds_auto_resize_enabled = panel->GetBounds(); |
414 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width()); | 414 EXPECT_EQ(bounds_on_shrink.width(), bounds_auto_resize_enabled.width()); |
415 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height()); | 415 EXPECT_EQ(bounds_on_shrink.height(), bounds_auto_resize_enabled.height()); |
416 | 416 |
417 panel->Close(); | 417 panel->Close(); |
418 } | 418 } |
419 | 419 |
420 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, ResizePanel) { | 420 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, ResizePanel) { |
421 PanelManager* panel_manager = PanelManager::GetInstance(); | 421 PanelManager* panel_manager = PanelManager::GetInstance(); |
422 panel_manager->enable_auto_sizing(true); | 422 panel_manager->enable_auto_sizing(true); |
423 | 423 |
424 Panel* panel = CreatePanel("TestPanel"); | 424 Panel* panel = CreatePanel("TestPanel"); |
425 EXPECT_TRUE(panel->auto_resizable()); | 425 EXPECT_TRUE(panel->auto_resizable()); |
426 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 426 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
427 | 427 |
428 // Verify resizing turns off auto-resizing and that it works. | 428 // Verify resizing turns off auto-resizing and that it works. |
429 gfx::Rect original_bounds = panel->GetBounds(); | 429 gfx::Rect original_bounds = panel->GetBounds(); |
430 // These should be identical because the panel is expanded. | 430 // These should be identical because the panel is expanded. |
(...skipping 12 matching lines...) Expand all Loading... |
443 new_size.Enlarge(5, 5); | 443 new_size.Enlarge(5, 5); |
444 new_bounds.set_size(new_size); | 444 new_bounds.set_size(new_size); |
445 panel->SetBounds(new_bounds); | 445 panel->SetBounds(new_bounds); |
446 EXPECT_EQ(new_bounds.size().width(), panel->GetBounds().width()); | 446 EXPECT_EQ(new_bounds.size().width(), panel->GetBounds().width()); |
447 EXPECT_EQ(original_height, panel->GetBounds().height()); | 447 EXPECT_EQ(original_height, panel->GetBounds().height()); |
448 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size()); | 448 EXPECT_EQ(new_bounds.size(), panel->GetRestoredBounds().size()); |
449 | 449 |
450 panel->Close(); | 450 panel->Close(); |
451 } | 451 } |
452 | 452 |
453 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, AnimateBounds) { | 453 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, AnimateBounds) { |
454 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); | 454 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); |
455 scoped_ptr<NativePanelTesting> panel_testing( | 455 scoped_ptr<NativePanelTesting> panel_testing( |
456 NativePanelTesting::Create(panel->native_panel())); | 456 NativePanelTesting::Create(panel->native_panel())); |
457 | 457 |
458 // Set bounds with animation. | 458 // Set bounds with animation. |
459 gfx::Rect bounds = gfx::Rect(10, 20, 150, 160); | 459 gfx::Rect bounds = gfx::Rect(10, 20, 150, 160); |
460 panel->SetPanelBounds(bounds); | 460 panel->SetPanelBounds(bounds); |
461 EXPECT_TRUE(panel_testing->IsAnimatingBounds()); | 461 EXPECT_TRUE(panel_testing->IsAnimatingBounds()); |
462 WaitForBoundsAnimationFinished(panel); | 462 WaitForBoundsAnimationFinished(panel); |
463 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); | 463 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); |
464 EXPECT_EQ(bounds, panel->GetBounds()); | 464 EXPECT_EQ(bounds, panel->GetBounds()); |
465 | 465 |
466 // Set bounds without animation. | 466 // Set bounds without animation. |
467 bounds = gfx::Rect(30, 40, 200, 220); | 467 bounds = gfx::Rect(30, 40, 200, 220); |
468 panel->SetPanelBoundsInstantly(bounds); | 468 panel->SetPanelBoundsInstantly(bounds); |
469 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); | 469 EXPECT_FALSE(panel_testing->IsAnimatingBounds()); |
470 EXPECT_EQ(bounds, panel->GetBounds()); | 470 EXPECT_EQ(bounds, panel->GetBounds()); |
471 | 471 |
472 panel->Close(); | 472 panel->Close(); |
473 } | 473 } |
474 | 474 |
475 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoredBounds) { | 475 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, RestoredBounds) { |
476 // Disable mouse watcher. We don't care about mouse movements in this test. | 476 // Disable mouse watcher. We don't care about mouse movements in this test. |
477 PanelManager* panel_manager = PanelManager::GetInstance(); | 477 PanelManager* panel_manager = PanelManager::GetInstance(); |
478 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 478 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
479 panel_manager->SetMouseWatcherForTesting(mouse_watcher); | 479 panel_manager->SetMouseWatcherForTesting(mouse_watcher); |
480 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); | 480 Panel* panel = CreatePanelWithBounds("PanelTest", gfx::Rect(0, 0, 100, 100)); |
481 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 481 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
482 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); | 482 EXPECT_EQ(panel->GetBounds(), panel->GetRestoredBounds()); |
483 | 483 |
484 panel->SetExpansionState(Panel::MINIMIZED); | 484 panel->SetExpansionState(Panel::MINIMIZED); |
485 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 485 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 panel->SetExpansionState(Panel::EXPANDED); | 526 panel->SetExpansionState(Panel::EXPANDED); |
527 bounds = gfx::Rect(40, 60, 300, 400); | 527 bounds = gfx::Rect(40, 60, 300, 400); |
528 panel->SetPanelBounds(bounds); | 528 panel->SetPanelBounds(bounds); |
529 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); | 529 EXPECT_EQ(saved_restored_height, panel->GetRestoredBounds().height()); |
530 panel->set_full_size(bounds.size()); | 530 panel->set_full_size(bounds.size()); |
531 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); | 531 EXPECT_NE(saved_restored_height, panel->GetRestoredBounds().height()); |
532 | 532 |
533 panel->Close(); | 533 panel->Close(); |
534 } | 534 } |
535 | 535 |
536 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestore) { | 536 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestore) { |
537 // We'll simulate mouse movements for test. | 537 // We'll simulate mouse movements for test. |
538 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 538 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
539 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 539 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
540 | 540 |
541 // Test with one panel. | 541 // Test with one panel. |
542 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 542 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
543 TestMinimizeRestore(); | 543 TestMinimizeRestore(); |
544 | 544 |
545 PanelManager::GetInstance()->CloseAll(); | 545 PanelManager::GetInstance()->CloseAll(); |
546 } | 546 } |
547 | 547 |
548 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreTwoPanels) { | 548 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestoreTwoPanels) { |
549 // We'll simulate mouse movements for test. | 549 // We'll simulate mouse movements for test. |
550 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 550 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
551 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 551 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
552 | 552 |
553 // Test with two panels. | 553 // Test with two panels. |
554 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 554 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
555 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); | 555 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
556 TestMinimizeRestore(); | 556 TestMinimizeRestore(); |
557 | 557 |
558 PanelManager::GetInstance()->CloseAll(); | 558 PanelManager::GetInstance()->CloseAll(); |
559 } | 559 } |
560 | 560 |
561 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreThreePanels) { | 561 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestoreThreePanels) { |
562 // We'll simulate mouse movements for test. | 562 // We'll simulate mouse movements for test. |
563 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 563 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
564 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 564 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
565 | 565 |
566 // Test with three panels. | 566 // Test with three panels. |
567 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); | 567 CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100)); |
568 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); | 568 CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110)); |
569 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); | 569 CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120)); |
570 TestMinimizeRestore(); | 570 TestMinimizeRestore(); |
571 | 571 |
572 PanelManager::GetInstance()->CloseAll(); | 572 PanelManager::GetInstance()->CloseAll(); |
573 } | 573 } |
574 | 574 |
575 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MinimizeRestoreButtonClick) { | 575 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MinimizeRestoreButtonClick) { |
576 // Test with three panels. | 576 // Test with three panels. |
577 Panel* panel1 = CreatePanel("PanelTest1"); | 577 Panel* panel1 = CreatePanel("PanelTest1"); |
578 Panel* panel2 = CreatePanel("PanelTest2"); | 578 Panel* panel2 = CreatePanel("PanelTest2"); |
579 Panel* panel3 = CreatePanel("PanelTest3"); | 579 Panel* panel3 = CreatePanel("PanelTest3"); |
580 EXPECT_FALSE(panel1->IsMinimized()); | 580 EXPECT_FALSE(panel1->IsMinimized()); |
581 EXPECT_FALSE(panel2->IsMinimized()); | 581 EXPECT_FALSE(panel2->IsMinimized()); |
582 EXPECT_FALSE(panel3->IsMinimized()); | 582 EXPECT_FALSE(panel3->IsMinimized()); |
583 | 583 |
584 // Click restore button on an expanded panel. Expect no change. | 584 // Click restore button on an expanded panel. Expect no change. |
585 panel1->OnRestoreButtonClicked(panel::NO_MODIFIER); | 585 panel1->OnRestoreButtonClicked(panel::NO_MODIFIER); |
(...skipping 26 matching lines...) Expand all Loading... |
612 EXPECT_FALSE(panel2->IsMinimized()); | 612 EXPECT_FALSE(panel2->IsMinimized()); |
613 EXPECT_TRUE(panel3->IsMinimized()); | 613 EXPECT_TRUE(panel3->IsMinimized()); |
614 | 614 |
615 // Restore all panels by clicking restore button on a minimized panel. | 615 // Restore all panels by clicking restore button on a minimized panel. |
616 panel3->OnRestoreButtonClicked(panel::APPLY_TO_ALL); | 616 panel3->OnRestoreButtonClicked(panel::APPLY_TO_ALL); |
617 EXPECT_FALSE(panel1->IsMinimized()); | 617 EXPECT_FALSE(panel1->IsMinimized()); |
618 EXPECT_FALSE(panel2->IsMinimized()); | 618 EXPECT_FALSE(panel2->IsMinimized()); |
619 EXPECT_FALSE(panel3->IsMinimized()); | 619 EXPECT_FALSE(panel3->IsMinimized()); |
620 } | 620 } |
621 | 621 |
622 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, RestoreAllWithTitlebarClick) { | 622 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, RestoreAllWithTitlebarClick) { |
623 // We'll simulate mouse movements for test. | 623 // We'll simulate mouse movements for test. |
624 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 624 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
625 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 625 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
626 | 626 |
627 // Test with three panels. | 627 // Test with three panels. |
628 Panel* panel1 = CreatePanel("PanelTest1"); | 628 Panel* panel1 = CreatePanel("PanelTest1"); |
629 Panel* panel2 = CreatePanel("PanelTest2"); | 629 Panel* panel2 = CreatePanel("PanelTest2"); |
630 Panel* panel3 = CreatePanel("PanelTest3"); | 630 Panel* panel3 = CreatePanel("PanelTest3"); |
631 EXPECT_FALSE(panel1->IsMinimized()); | 631 EXPECT_FALSE(panel1->IsMinimized()); |
632 EXPECT_FALSE(panel2->IsMinimized()); | 632 EXPECT_FALSE(panel2->IsMinimized()); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 785 |
786 #if defined(OS_MACOSX) | 786 #if defined(OS_MACOSX) |
787 // This test doesn't pass on Snow Leopard (10.6), although it works just | 787 // This test doesn't pass on Snow Leopard (10.6), although it works just |
788 // fine on Lion (10.7). The problem is not having a real run loop around | 788 // fine on Lion (10.7). The problem is not having a real run loop around |
789 // the window close is at fault, given how window controllers in Chrome | 789 // the window close is at fault, given how window controllers in Chrome |
790 // autorelease themselves on a -performSelector:withObject:afterDelay: | 790 // autorelease themselves on a -performSelector:withObject:afterDelay: |
791 #define MAYBE_ActivatePanelOrTabbedWindow DISABLED_ActivatePanelOrTabbedWindow | 791 #define MAYBE_ActivatePanelOrTabbedWindow DISABLED_ActivatePanelOrTabbedWindow |
792 #else | 792 #else |
793 #define MAYBE_ActivatePanelOrTabbedWindow ActivatePanelOrTabbedWindow | 793 #define MAYBE_ActivatePanelOrTabbedWindow ActivatePanelOrTabbedWindow |
794 #endif | 794 #endif |
795 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_ActivatePanelOrTabbedWindow) { | 795 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MAYBE_ActivatePanelOrTabbedWindow) { |
796 CreatePanelParams params1("Panel1", gfx::Rect(), SHOW_AS_ACTIVE); | 796 CreatePanelParams params1("Panel1", gfx::Rect(), SHOW_AS_ACTIVE); |
797 Panel* panel1 = CreatePanelWithParams(params1); | 797 Panel* panel1 = CreatePanelWithParams(params1); |
798 CreatePanelParams params2("Panel2", gfx::Rect(), SHOW_AS_ACTIVE); | 798 CreatePanelParams params2("Panel2", gfx::Rect(), SHOW_AS_ACTIVE); |
799 Panel* panel2 = CreatePanelWithParams(params2); | 799 Panel* panel2 = CreatePanelWithParams(params2); |
800 | 800 |
801 // Need tab contents in order to trigger deactivation upon close. | 801 // Need tab contents in order to trigger deactivation upon close. |
802 CreateTestTabContents(panel2->browser()); | 802 CreateTestTabContents(panel2->browser()); |
803 | 803 |
804 ASSERT_FALSE(panel1->IsActive()); | 804 ASSERT_FALSE(panel1->IsActive()); |
805 ASSERT_TRUE(panel2->IsActive()); | 805 ASSERT_TRUE(panel2->IsActive()); |
(...skipping 27 matching lines...) Expand all Loading... |
833 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); | 833 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE); |
834 panel1->Close(); | 834 panel1->Close(); |
835 } | 835 } |
836 | 836 |
837 // TODO(jianli): To be enabled for other platforms. | 837 // TODO(jianli): To be enabled for other platforms. |
838 #if defined(OS_WIN) | 838 #if defined(OS_WIN) |
839 #define MAYBE_ActivateDeactivateBasic ActivateDeactivateBasic | 839 #define MAYBE_ActivateDeactivateBasic ActivateDeactivateBasic |
840 #else | 840 #else |
841 #define MAYBE_ActivateDeactivateBasic DISABLED_ActivateDeactivateBasic | 841 #define MAYBE_ActivateDeactivateBasic DISABLED_ActivateDeactivateBasic |
842 #endif | 842 #endif |
843 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_ActivateDeactivateBasic) { | 843 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MAYBE_ActivateDeactivateBasic) { |
844 // Create an active panel. | 844 // Create an active panel. |
845 Panel* panel = CreatePanel("PanelTest"); | 845 Panel* panel = CreatePanel("PanelTest"); |
846 scoped_ptr<NativePanelTesting> native_panel_testing( | 846 scoped_ptr<NativePanelTesting> native_panel_testing( |
847 NativePanelTesting::Create(panel->native_panel())); | 847 NativePanelTesting::Create(panel->native_panel())); |
848 EXPECT_TRUE(panel->IsActive()); | 848 EXPECT_TRUE(panel->IsActive()); |
849 EXPECT_TRUE(native_panel_testing->VerifyActiveState(true)); | 849 EXPECT_TRUE(native_panel_testing->VerifyActiveState(true)); |
850 | 850 |
851 // Deactivate the panel. | 851 // Deactivate the panel. |
852 panel->Deactivate(); | 852 panel->Deactivate(); |
853 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 853 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
854 EXPECT_FALSE(panel->IsActive()); | 854 EXPECT_FALSE(panel->IsActive()); |
855 EXPECT_TRUE(native_panel_testing->VerifyActiveState(false)); | 855 EXPECT_TRUE(native_panel_testing->VerifyActiveState(false)); |
856 | 856 |
857 // Reactivate the panel. | 857 // Reactivate the panel. |
858 panel->Activate(); | 858 panel->Activate(); |
859 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 859 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
860 EXPECT_TRUE(panel->IsActive()); | 860 EXPECT_TRUE(panel->IsActive()); |
861 EXPECT_TRUE(native_panel_testing->VerifyActiveState(true)); | 861 EXPECT_TRUE(native_panel_testing->VerifyActiveState(true)); |
862 } | 862 } |
863 // TODO(jianli): To be enabled for other platforms. | 863 // TODO(jianli): To be enabled for other platforms. |
864 #if defined(OS_WIN) | 864 #if defined(OS_WIN) |
865 #define MAYBE_ActivateDeactivateMultiple ActivateDeactivateMultiple | 865 #define MAYBE_ActivateDeactivateMultiple ActivateDeactivateMultiple |
866 #else | 866 #else |
867 #define MAYBE_ActivateDeactivateMultiple DISABLED_ActivateDeactivateMultiple | 867 #define MAYBE_ActivateDeactivateMultiple DISABLED_ActivateDeactivateMultiple |
868 #endif | 868 #endif |
869 | 869 |
870 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_ActivateDeactivateMultiple) { | 870 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, MAYBE_ActivateDeactivateMultiple) { |
871 BrowserWindow* tabbed_window = browser()->window(); | 871 BrowserWindow* tabbed_window = browser()->window(); |
872 | 872 |
873 // Create 4 panels in the following screen layout: | 873 // Create 4 panels in the following screen layout: |
874 // P3 P2 P1 P0 | 874 // P3 P2 P1 P0 |
875 const int kNumPanels = 4; | 875 const int kNumPanels = 4; |
876 for (int i = 0; i < kNumPanels; ++i) | 876 for (int i = 0; i < kNumPanels; ++i) |
877 CreatePanelWithBounds(MakePanelName(i), gfx::Rect(0, 0, 100, 100)); | 877 CreatePanelWithBounds(MakePanelName(i), gfx::Rect(0, 0, 100, 100)); |
878 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels(); | 878 const std::vector<Panel*>& panels = PanelManager::GetInstance()->panels(); |
879 | 879 |
880 std::vector<bool> expected_active_states; | 880 std::vector<bool> expected_active_states; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 | 915 |
916 // Minimizing active panel P0 should activate last active tabbed window. | 916 // Minimizing active panel P0 should activate last active tabbed window. |
917 panels[0]->SetExpansionState(Panel::MINIMIZED); | 917 panels[0]->SetExpansionState(Panel::MINIMIZED); |
918 last_active_states = expected_active_states; | 918 last_active_states = expected_active_states; |
919 expected_active_states = ProduceExpectedActiveStates(-1); // -1 means none. | 919 expected_active_states = ProduceExpectedActiveStates(-1); // -1 means none. |
920 WaitForPanelActiveStates(last_active_states, expected_active_states); | 920 WaitForPanelActiveStates(last_active_states, expected_active_states); |
921 EXPECT_EQ(expected_active_states, GetAllPanelActiveStates()); | 921 EXPECT_EQ(expected_active_states, GetAllPanelActiveStates()); |
922 EXPECT_TRUE(tabbed_window->IsActive()); | 922 EXPECT_TRUE(tabbed_window->IsActive()); |
923 } | 923 } |
924 | 924 |
925 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionBasic) { | 925 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionBasic) { |
926 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); | 926 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); |
927 Panel* panel = CreatePanelWithParams(params); | 927 Panel* panel = CreatePanelWithParams(params); |
928 scoped_ptr<NativePanelTesting> native_panel_testing( | 928 scoped_ptr<NativePanelTesting> native_panel_testing( |
929 NativePanelTesting::Create(panel->native_panel())); | 929 NativePanelTesting::Create(panel->native_panel())); |
930 | 930 |
931 // Test that the attention is drawn when the expanded panel is not in focus. | 931 // Test that the attention is drawn when the expanded panel is not in focus. |
932 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 932 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
933 EXPECT_FALSE(panel->IsActive()); | 933 EXPECT_FALSE(panel->IsActive()); |
934 EXPECT_FALSE(panel->IsDrawingAttention()); | 934 EXPECT_FALSE(panel->IsDrawingAttention()); |
935 panel->FlashFrame(true); | 935 panel->FlashFrame(true); |
(...skipping 16 matching lines...) Expand all Loading... |
952 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | 952 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
953 | 953 |
954 // Stop drawing attention. Titlebar should no longer be visible. | 954 // Stop drawing attention. Titlebar should no longer be visible. |
955 panel->FlashFrame(false); | 955 panel->FlashFrame(false); |
956 EXPECT_FALSE(panel->IsDrawingAttention()); | 956 EXPECT_FALSE(panel->IsDrawingAttention()); |
957 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 957 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
958 | 958 |
959 panel->Close(); | 959 panel->Close(); |
960 } | 960 } |
961 | 961 |
962 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhileMinimized) { | 962 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionWhileMinimized) { |
963 // We'll simulate mouse movements for test. | 963 // We'll simulate mouse movements for test. |
964 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 964 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
965 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 965 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
966 | 966 |
967 // Create 2 panels so we end up with an inactive panel that can | 967 // Create 2 panels so we end up with an inactive panel that can |
968 // be made to draw attention. | 968 // be made to draw attention. |
969 Panel* panel = CreatePanel("test panel1"); | 969 Panel* panel = CreatePanel("test panel1"); |
970 Panel* panel2 = CreatePanel("test panel2"); | 970 Panel* panel2 = CreatePanel("test panel2"); |
971 Panel* panel3 = CreatePanel("test panel2"); | 971 Panel* panel3 = CreatePanel("test panel2"); |
972 | 972 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 1004 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
1005 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1005 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
1006 | 1006 |
1007 panel->Close(); | 1007 panel->Close(); |
1008 panel2->Close(); | 1008 panel2->Close(); |
1009 panel3->Close(); | 1009 panel3->Close(); |
1010 } | 1010 } |
1011 | 1011 |
1012 // Verify that minimized state of a panel is correct after draw attention | 1012 // Verify that minimized state of a panel is correct after draw attention |
1013 // is stopped when there are other minimized panels. | 1013 // is stopped when there are other minimized panels. |
1014 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, StopDrawingAttentionWhileMinimized) { | 1014 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, |
| 1015 StopDrawingAttentionWhileMinimized) { |
1015 // We'll simulate mouse movements for test. | 1016 // We'll simulate mouse movements for test. |
1016 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | 1017 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); |
1017 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | 1018 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); |
1018 | 1019 |
1019 Panel* panel1 = CreatePanel("panel1"); | 1020 Panel* panel1 = CreatePanel("panel1"); |
1020 Panel* panel2 = CreatePanel("panel2"); | 1021 Panel* panel2 = CreatePanel("panel2"); |
1021 | 1022 |
1022 panel1->Minimize(); | 1023 panel1->Minimize(); |
1023 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 1024 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
1024 panel2->Minimize(); | 1025 panel2->Minimize(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 | 1072 |
1072 // Move mouse away and panel should go back to fully minimized state. | 1073 // Move mouse away and panel should go back to fully minimized state. |
1073 MoveMouseAndWaitForExpansionStateChange(panel1, hover_point); | 1074 MoveMouseAndWaitForExpansionStateChange(panel1, hover_point); |
1074 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 1075 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
1075 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state()); | 1076 EXPECT_EQ(Panel::MINIMIZED, panel2->expansion_state()); |
1076 | 1077 |
1077 panel1->Close(); | 1078 panel1->Close(); |
1078 panel2->Close(); | 1079 panel2->Close(); |
1079 } | 1080 } |
1080 | 1081 |
1081 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionWhenActive) { | 1082 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionWhenActive) { |
1082 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); | 1083 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); |
1083 Panel* panel = CreatePanelWithParams(params); | 1084 Panel* panel = CreatePanelWithParams(params); |
1084 scoped_ptr<NativePanelTesting> native_panel_testing( | 1085 scoped_ptr<NativePanelTesting> native_panel_testing( |
1085 NativePanelTesting::Create(panel->native_panel())); | 1086 NativePanelTesting::Create(panel->native_panel())); |
1086 | 1087 |
1087 // Test that the attention should not be drawn if the expanded panel is in | 1088 // Test that the attention should not be drawn if the expanded panel is in |
1088 // focus. | 1089 // focus. |
1089 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 1090 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
1090 EXPECT_TRUE(panel->IsActive()); | 1091 EXPECT_TRUE(panel->IsActive()); |
1091 EXPECT_FALSE(panel->IsDrawingAttention()); | 1092 EXPECT_FALSE(panel->IsDrawingAttention()); |
1092 panel->FlashFrame(true); | 1093 panel->FlashFrame(true); |
1093 EXPECT_FALSE(panel->IsDrawingAttention()); | 1094 EXPECT_FALSE(panel->IsDrawingAttention()); |
1094 MessageLoop::current()->RunAllPending(); | 1095 MessageLoop::current()->RunAllPending(); |
1095 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1096 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
1096 | 1097 |
1097 panel->Close(); | 1098 panel->Close(); |
1098 } | 1099 } |
1099 | 1100 |
1100 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnActivate) { | 1101 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionResetOnActivate) { |
1101 // Create 2 panels so we end up with an inactive panel that can | 1102 // Create 2 panels so we end up with an inactive panel that can |
1102 // be made to draw attention. | 1103 // be made to draw attention. |
1103 Panel* panel = CreatePanel("test panel1"); | 1104 Panel* panel = CreatePanel("test panel1"); |
1104 Panel* panel2 = CreatePanel("test panel2"); | 1105 Panel* panel2 = CreatePanel("test panel2"); |
1105 | 1106 |
1106 scoped_ptr<NativePanelTesting> native_panel_testing( | 1107 scoped_ptr<NativePanelTesting> native_panel_testing( |
1107 NativePanelTesting::Create(panel->native_panel())); | 1108 NativePanelTesting::Create(panel->native_panel())); |
1108 | 1109 |
1109 panel->FlashFrame(true); | 1110 panel->FlashFrame(true); |
1110 EXPECT_TRUE(panel->IsDrawingAttention()); | 1111 EXPECT_TRUE(panel->IsDrawingAttention()); |
1111 MessageLoop::current()->RunAllPending(); | 1112 MessageLoop::current()->RunAllPending(); |
1112 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 1113 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
1113 | 1114 |
1114 // Test that the attention is cleared when panel gets focus. | 1115 // Test that the attention is cleared when panel gets focus. |
1115 panel->Activate(); | 1116 panel->Activate(); |
1116 MessageLoop::current()->RunAllPending(); | 1117 MessageLoop::current()->RunAllPending(); |
1117 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 1118 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
1118 EXPECT_FALSE(panel->IsDrawingAttention()); | 1119 EXPECT_FALSE(panel->IsDrawingAttention()); |
1119 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1120 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
1120 | 1121 |
1121 panel->Close(); | 1122 panel->Close(); |
1122 panel2->Close(); | 1123 panel2->Close(); |
1123 } | 1124 } |
1124 | 1125 |
1125 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1126 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, |
1126 DrawAttentionMinimizedNotResetOnActivate) { | 1127 DrawAttentionMinimizedNotResetOnActivate) { |
1127 // Create 2 panels so we end up with an inactive panel that can | 1128 // Create 2 panels so we end up with an inactive panel that can |
1128 // be made to draw attention. | 1129 // be made to draw attention. |
1129 Panel* panel1 = CreatePanel("test panel1"); | 1130 Panel* panel1 = CreatePanel("test panel1"); |
1130 Panel* panel2 = CreatePanel("test panel2"); | 1131 Panel* panel2 = CreatePanel("test panel2"); |
1131 | 1132 |
1132 panel1->Minimize(); | 1133 panel1->Minimize(); |
1133 EXPECT_TRUE(panel1->IsMinimized()); | 1134 EXPECT_TRUE(panel1->IsMinimized()); |
1134 panel1->FlashFrame(true); | 1135 panel1->FlashFrame(true); |
1135 EXPECT_TRUE(panel1->IsDrawingAttention()); | 1136 EXPECT_TRUE(panel1->IsDrawingAttention()); |
1136 | 1137 |
1137 // Simulate panel being activated while minimized. Cannot call | 1138 // Simulate panel being activated while minimized. Cannot call |
1138 // Activate() as that expands the panel. | 1139 // Activate() as that expands the panel. |
1139 panel1->OnActiveStateChanged(true); | 1140 panel1->OnActiveStateChanged(true); |
1140 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. | 1141 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. |
1141 | 1142 |
1142 // Unminimize panel to show that attention would have been cleared | 1143 // Unminimize panel to show that attention would have been cleared |
1143 // if panel had not been minimized. | 1144 // if panel had not been minimized. |
1144 panel1->Restore(); | 1145 panel1->Restore(); |
1145 EXPECT_FALSE(panel1->IsMinimized()); | 1146 EXPECT_FALSE(panel1->IsMinimized()); |
1146 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. | 1147 EXPECT_TRUE(panel1->IsDrawingAttention()); // Unchanged. |
1147 | 1148 |
1148 panel1->OnActiveStateChanged(true); | 1149 panel1->OnActiveStateChanged(true); |
1149 EXPECT_FALSE(panel1->IsDrawingAttention()); // Attention cleared. | 1150 EXPECT_FALSE(panel1->IsDrawingAttention()); // Attention cleared. |
1150 | 1151 |
1151 panel1->Close(); | 1152 panel1->Close(); |
1152 panel2->Close(); | 1153 panel2->Close(); |
1153 } | 1154 } |
1154 | 1155 |
1155 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DrawAttentionResetOnClick) { | 1156 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, DrawAttentionResetOnClick) { |
1156 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); | 1157 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); |
1157 Panel* panel = CreatePanelWithParams(params); | 1158 Panel* panel = CreatePanelWithParams(params); |
1158 scoped_ptr<NativePanelTesting> native_panel_testing( | 1159 scoped_ptr<NativePanelTesting> native_panel_testing( |
1159 NativePanelTesting::Create(panel->native_panel())); | 1160 NativePanelTesting::Create(panel->native_panel())); |
1160 | 1161 |
1161 panel->FlashFrame(true); | 1162 panel->FlashFrame(true); |
1162 EXPECT_TRUE(panel->IsDrawingAttention()); | 1163 EXPECT_TRUE(panel->IsDrawingAttention()); |
1163 MessageLoop::current()->RunAllPending(); | 1164 MessageLoop::current()->RunAllPending(); |
1164 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); | 1165 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention()); |
1165 | 1166 |
1166 // Test that the attention is cleared when panel gets focus. | 1167 // Test that the attention is cleared when panel gets focus. |
1167 native_panel_testing->PressLeftMouseButtonTitlebar( | 1168 native_panel_testing->PressLeftMouseButtonTitlebar( |
1168 panel->GetBounds().origin()); | 1169 panel->GetBounds().origin()); |
1169 native_panel_testing->ReleaseMouseButtonTitlebar(); | 1170 native_panel_testing->ReleaseMouseButtonTitlebar(); |
1170 | 1171 |
1171 MessageLoop::current()->RunAllPending(); | 1172 MessageLoop::current()->RunAllPending(); |
1172 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 1173 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
1173 EXPECT_FALSE(panel->IsDrawingAttention()); | 1174 EXPECT_FALSE(panel->IsDrawingAttention()); |
1174 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); | 1175 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention()); |
1175 | 1176 |
1176 panel->Close(); | 1177 panel->Close(); |
1177 } | 1178 } |
1178 | 1179 |
1179 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1180 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, |
1180 MinimizeImmediatelyAfterRestore) { | 1181 MinimizeImmediatelyAfterRestore) { |
1181 CreatePanelParams params("Panel Test", gfx::Rect(), SHOW_AS_ACTIVE); | 1182 CreatePanelParams params("Panel Test", gfx::Rect(), SHOW_AS_ACTIVE); |
1182 Panel* panel = CreatePanelWithParams(params); | 1183 Panel* panel = CreatePanelWithParams(params); |
1183 scoped_ptr<NativePanelTesting> native_panel_testing( | 1184 scoped_ptr<NativePanelTesting> native_panel_testing( |
1184 NativePanelTesting::Create(panel->native_panel())); | 1185 NativePanelTesting::Create(panel->native_panel())); |
1185 | 1186 |
1186 panel->Minimize(); // this should deactivate. | 1187 panel->Minimize(); // this should deactivate. |
1187 MessageLoop::current()->RunAllPending(); | 1188 MessageLoop::current()->RunAllPending(); |
1188 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 1189 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
1189 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 1190 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
1190 | 1191 |
1191 panel->Restore(); | 1192 panel->Restore(); |
1192 MessageLoop::current()->RunAllPending(); | 1193 MessageLoop::current()->RunAllPending(); |
1193 WaitForExpansionStateChanged(panel, Panel::EXPANDED); | 1194 WaitForExpansionStateChanged(panel, Panel::EXPANDED); |
1194 | 1195 |
1195 // Verify that minimizing a panel right after expansion works. | 1196 // Verify that minimizing a panel right after expansion works. |
1196 panel->Minimize(); | 1197 panel->Minimize(); |
1197 MessageLoop::current()->RunAllPending(); | 1198 MessageLoop::current()->RunAllPending(); |
1198 WaitForExpansionStateChanged(panel, Panel::MINIMIZED); | 1199 WaitForExpansionStateChanged(panel, Panel::MINIMIZED); |
1199 | 1200 |
1200 panel->Close(); | 1201 panel->Close(); |
1201 } | 1202 } |
1202 | 1203 |
1203 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, FocusLostOnMinimize) { | 1204 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, FocusLostOnMinimize) { |
1204 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); | 1205 CreatePanelParams params("Initially Active", gfx::Rect(), SHOW_AS_ACTIVE); |
1205 Panel* panel = CreatePanelWithParams(params); | 1206 Panel* panel = CreatePanelWithParams(params); |
1206 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 1207 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
1207 | 1208 |
1208 panel->SetExpansionState(Panel::MINIMIZED); | 1209 panel->SetExpansionState(Panel::MINIMIZED); |
1209 MessageLoop::current()->RunAllPending(); | 1210 MessageLoop::current()->RunAllPending(); |
1210 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); | 1211 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE); |
1211 panel->Close(); | 1212 panel->Close(); |
1212 } | 1213 } |
1213 | 1214 |
1214 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateInactiveSwitchToActive) { | 1215 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, CreateInactiveSwitchToActive) { |
1215 // Compiz will not activate initially inactive window. | 1216 // Compiz will not activate initially inactive window. |
1216 if (SkipTestIfCompizWM()) | 1217 if (SkipTestIfCompizWM()) |
1217 return; | 1218 return; |
1218 | 1219 |
1219 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); | 1220 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); |
1220 Panel* panel = CreatePanelWithParams(params); | 1221 Panel* panel = CreatePanelWithParams(params); |
1221 | 1222 |
1222 panel->Activate(); | 1223 panel->Activate(); |
1223 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); | 1224 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE); |
1224 | 1225 |
1225 panel->Close(); | 1226 panel->Close(); |
1226 } | 1227 } |
1227 | 1228 |
1228 // TODO(dimich): try/enable on other platforms. See bug 103253 for details on | 1229 // TODO(dimich): try/enable on other platforms. See bug 103253 for details on |
1229 // why this is disabled on windows. | 1230 // why this is disabled on windows. |
1230 #if defined(OS_MACOSX) | 1231 #if defined(OS_MACOSX) |
1231 #define MAYBE_MinimizeTwoPanelsWithoutTabbedWindow \ | 1232 #define MAYBE_MinimizeTwoPanelsWithoutTabbedWindow \ |
1232 MinimizeTwoPanelsWithoutTabbedWindow | 1233 MinimizeTwoPanelsWithoutTabbedWindow |
1233 #else | 1234 #else |
1234 #define MAYBE_MinimizeTwoPanelsWithoutTabbedWindow \ | 1235 #define MAYBE_MinimizeTwoPanelsWithoutTabbedWindow \ |
1235 DISABLED_MinimizeTwoPanelsWithoutTabbedWindow | 1236 DISABLED_MinimizeTwoPanelsWithoutTabbedWindow |
1236 #endif | 1237 #endif |
1237 | 1238 |
1238 // When there are 2 panels and no chrome window, minimizing one panel does | 1239 // When there are 2 panels and no chrome window, minimizing one panel does |
1239 // not expand/focuses another. | 1240 // not expand/focuses another. |
1240 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1241 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, |
1241 MAYBE_MinimizeTwoPanelsWithoutTabbedWindow) { | 1242 MAYBE_MinimizeTwoPanelsWithoutTabbedWindow) { |
1242 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); | 1243 CreatePanelParams params("Initially Inactive", gfx::Rect(), SHOW_AS_INACTIVE); |
1243 Panel* panel1 = CreatePanelWithParams(params); | 1244 Panel* panel1 = CreatePanelWithParams(params); |
1244 Panel* panel2 = CreatePanelWithParams(params); | 1245 Panel* panel2 = CreatePanelWithParams(params); |
1245 | 1246 |
1246 // Close main tabbed window. | 1247 // Close main tabbed window. |
1247 ui_test_utils::WindowedNotificationObserver signal( | 1248 ui_test_utils::WindowedNotificationObserver signal( |
1248 chrome::NOTIFICATION_BROWSER_CLOSED, | 1249 chrome::NOTIFICATION_BROWSER_CLOSED, |
1249 content::Source<Browser>(browser())); | 1250 content::Source<Browser>(browser())); |
1250 browser()->CloseWindow(); | 1251 browser()->CloseWindow(); |
(...skipping 19 matching lines...) Expand all Loading... |
1270 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 1271 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
1271 | 1272 |
1272 // Another check for the same. | 1273 // Another check for the same. |
1273 EXPECT_FALSE(panel1->IsActive()); | 1274 EXPECT_FALSE(panel1->IsActive()); |
1274 EXPECT_FALSE(panel2->IsActive()); | 1275 EXPECT_FALSE(panel2->IsActive()); |
1275 | 1276 |
1276 panel1->Close(); | 1277 panel1->Close(); |
1277 panel2->Close(); | 1278 panel2->Close(); |
1278 } | 1279 } |
1279 | 1280 |
1280 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1281 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, |
1281 NonExtensionDomainPanelsCloseOnUninstall) { | 1282 NonExtensionDomainPanelsCloseOnUninstall) { |
1282 // Create a test extension. | 1283 // Create a test extension. |
1283 DictionaryValue empty_value; | 1284 DictionaryValue empty_value; |
1284 scoped_refptr<Extension> extension = | 1285 scoped_refptr<Extension> extension = |
1285 CreateExtension(FILE_PATH_LITERAL("TestExtension"), | 1286 CreateExtension(FILE_PATH_LITERAL("TestExtension"), |
1286 Extension::INVALID, empty_value); | 1287 Extension::INVALID, empty_value); |
1287 std::string extension_app_name = | 1288 std::string extension_app_name = |
1288 web_app::GenerateApplicationNameFromExtensionId(extension->id()); | 1289 web_app::GenerateApplicationNameFromExtensionId(extension->id()); |
1289 | 1290 |
1290 PanelManager* panel_manager = PanelManager::GetInstance(); | 1291 PanelManager* panel_manager = PanelManager::GetInstance(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 | 1332 |
1332 // Wait for the panels opened by the first extension to close. | 1333 // Wait for the panels opened by the first extension to close. |
1333 signal.Wait(); | 1334 signal.Wait(); |
1334 signal1.Wait(); | 1335 signal1.Wait(); |
1335 | 1336 |
1336 // Verify that the panel that's left is the panel from the second extension. | 1337 // Verify that the panel that's left is the panel from the second extension. |
1337 EXPECT_EQ(panel_other, panel_manager->panels()[0]); | 1338 EXPECT_EQ(panel_other, panel_manager->panels()[0]); |
1338 panel_other->Close(); | 1339 panel_other->Close(); |
1339 } | 1340 } |
1340 | 1341 |
1341 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, OnBeforeUnloadOnClose) { | 1342 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, OnBeforeUnloadOnClose) { |
1342 PanelManager* panel_manager = PanelManager::GetInstance(); | 1343 PanelManager* panel_manager = PanelManager::GetInstance(); |
1343 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. | 1344 EXPECT_EQ(0, panel_manager->num_panels()); // No panels initially. |
1344 | 1345 |
1345 const string16 title_first_close = UTF8ToUTF16("TitleFirstClose"); | 1346 const string16 title_first_close = UTF8ToUTF16("TitleFirstClose"); |
1346 const string16 title_second_close = UTF8ToUTF16("TitleSecondClose"); | 1347 const string16 title_second_close = UTF8ToUTF16("TitleSecondClose"); |
1347 | 1348 |
1348 // Create a test panel with tab contents loaded. | 1349 // Create a test panel with tab contents loaded. |
1349 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 300, 300), | 1350 CreatePanelParams params("PanelTest1", gfx::Rect(0, 0, 300, 300), |
1350 SHOW_AS_ACTIVE); | 1351 SHOW_AS_ACTIVE); |
1351 params.url = ui_test_utils::GetTestUrl( | 1352 params.url = ui_test_utils::GetTestUrl( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 panel->Close(); | 1384 panel->Close(); |
1384 alert = ui_test_utils::WaitForAppModalDialog(); | 1385 alert = ui_test_utils::WaitForAppModalDialog(); |
1385 alert->native_dialog()->AcceptAppModalDialog(); | 1386 alert->native_dialog()->AcceptAppModalDialog(); |
1386 signal.Wait(); | 1387 signal.Wait(); |
1387 EXPECT_EQ(0, panel_manager->num_panels()); | 1388 EXPECT_EQ(0, panel_manager->num_panels()); |
1388 } | 1389 } |
1389 | 1390 |
1390 // http://crbug.com/126381 - should find a better notification to wait | 1391 // http://crbug.com/126381 - should find a better notification to wait |
1391 // for resize completion. Bounds animation could happen for all sorts of | 1392 // for resize completion. Bounds animation could happen for all sorts of |
1392 // reasons. | 1393 // reasons. |
1393 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DISABLED_CreateWithExistingContents) { | 1394 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, |
| 1395 DISABLED_CreateWithExistingContents) { |
1394 PanelManager::GetInstance()->enable_auto_sizing(true); | 1396 PanelManager::GetInstance()->enable_auto_sizing(true); |
1395 | 1397 |
1396 // Load contents into regular tabbed browser. | 1398 // Load contents into regular tabbed browser. |
1397 GURL url(ui_test_utils::GetTestUrl( | 1399 GURL url(ui_test_utils::GetTestUrl( |
1398 FilePath(kTestDir), | 1400 FilePath(kTestDir), |
1399 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); | 1401 FilePath(FILE_PATH_LITERAL("update-preferred-size.html")))); |
1400 ui_test_utils::NavigateToURL(browser(), url); | 1402 ui_test_utils::NavigateToURL(browser(), url); |
1401 EXPECT_EQ(1, browser()->tab_count()); | 1403 EXPECT_EQ(1, browser()->tab_count()); |
1402 | 1404 |
1403 Profile* profile = browser()->profile(); | 1405 Profile* profile = browser()->profile(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 content::Source<Panel>(panel)); | 1437 content::Source<Panel>(panel)); |
1436 panel_browser->ConvertPopupToTabbedBrowser(); | 1438 panel_browser->ConvertPopupToTabbedBrowser(); |
1437 signal.Wait(); | 1439 signal.Wait(); |
1438 EXPECT_EQ(0, PanelManager::GetInstance()->num_panels()); | 1440 EXPECT_EQ(0, PanelManager::GetInstance()->num_panels()); |
1439 | 1441 |
1440 Browser* tabbed_browser = browser::FindTabbedBrowser(profile, false); | 1442 Browser* tabbed_browser = browser::FindTabbedBrowser(profile, false); |
1441 EXPECT_EQ(contents, tabbed_browser->GetSelectedTabContentsWrapper()); | 1443 EXPECT_EQ(contents, tabbed_browser->GetSelectedTabContentsWrapper()); |
1442 tabbed_browser->window()->Close(); | 1444 tabbed_browser->window()->Close(); |
1443 } | 1445 } |
1444 | 1446 |
1445 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, SizeClamping) { | 1447 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, SizeClamping) { |
1446 // Using '0' sizes is equivalent of not providing sizes in API and causes | 1448 // Using '0' sizes is equivalent of not providing sizes in API and causes |
1447 // minimum sizes to be applied to facilitate auto-sizing. | 1449 // minimum sizes to be applied to facilitate auto-sizing. |
1448 CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE); | 1450 CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE); |
1449 Panel* panel = CreatePanelWithParams(params); | 1451 Panel* panel = CreatePanelWithParams(params); |
1450 EXPECT_EQ(panel->min_size().width(), panel->GetBounds().width()); | 1452 EXPECT_EQ(panel->min_size().width(), panel->GetBounds().width()); |
1451 EXPECT_EQ(panel->min_size().height(), panel->GetBounds().height()); | 1453 EXPECT_EQ(panel->min_size().height(), panel->GetBounds().height()); |
1452 int reasonable_width = panel->min_size().width() + 10; | 1454 int reasonable_width = panel->min_size().width() + 10; |
1453 int reasonable_height = panel->min_size().height() + 20; | 1455 int reasonable_height = panel->min_size().height() + 20; |
1454 | 1456 |
1455 panel->Close(); | 1457 panel->Close(); |
(...skipping 11 matching lines...) Expand all Loading... |
1467 // Using just one size should auto-compute some reasonable other size. | 1469 // Using just one size should auto-compute some reasonable other size. |
1468 int given_height = 200; | 1470 int given_height = 200; |
1469 CreatePanelParams params2("Panel2", gfx::Rect(0, 0, 0, given_height), | 1471 CreatePanelParams params2("Panel2", gfx::Rect(0, 0, 0, given_height), |
1470 SHOW_AS_ACTIVE); | 1472 SHOW_AS_ACTIVE); |
1471 panel = CreatePanelWithParams(params2); | 1473 panel = CreatePanelWithParams(params2); |
1472 EXPECT_GT(panel->GetBounds().width(), 0); | 1474 EXPECT_GT(panel->GetBounds().width(), 0); |
1473 EXPECT_EQ(given_height, panel->GetBounds().height()); | 1475 EXPECT_EQ(given_height, panel->GetBounds().height()); |
1474 panel->Close(); | 1476 panel->Close(); |
1475 } | 1477 } |
1476 | 1478 |
1477 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, TightAutosizeAroundSingleLine) { | 1479 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, TightAutosizeAroundSingleLine) { |
1478 PanelManager::GetInstance()->enable_auto_sizing(true); | 1480 PanelManager::GetInstance()->enable_auto_sizing(true); |
1479 // Using 0 sizes triggers auto-sizing. | 1481 // Using 0 sizes triggers auto-sizing. |
1480 CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE); | 1482 CreatePanelParams params("Panel", gfx::Rect(), SHOW_AS_ACTIVE); |
1481 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>"); | 1483 params.url = GURL("data:text/html;charset=utf-8,<!doctype html><body>"); |
1482 Panel* panel = CreatePanelWithParams(params); | 1484 Panel* panel = CreatePanelWithParams(params); |
1483 | 1485 |
1484 int initial_width = panel->GetBounds().width(); | 1486 int initial_width = panel->GetBounds().width(); |
1485 int initial_height = panel->GetBounds().height(); | 1487 int initial_height = panel->GetBounds().height(); |
1486 | 1488 |
1487 // Inject some HTML content into the panel. | 1489 // Inject some HTML content into the panel. |
1488 ui_test_utils::WindowedNotificationObserver enlarge( | 1490 ui_test_utils::WindowedNotificationObserver enlarge( |
1489 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 1491 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
1490 content::Source<Panel>(panel)); | 1492 content::Source<Panel>(panel)); |
1491 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( | 1493 EXPECT_TRUE(ui_test_utils::ExecuteJavaScript( |
1492 panel->WebContents()->GetRenderViewHost(), | 1494 panel->WebContents()->GetRenderViewHost(), |
1493 std::wstring(), | 1495 std::wstring(), |
1494 L"document.body.innerHTML =" | 1496 L"document.body.innerHTML =" |
1495 L"'<nobr>line of text and a <button>Button</button>';")); | 1497 L"'<nobr>line of text and a <button>Button</button>';")); |
1496 enlarge.Wait(); | 1498 enlarge.Wait(); |
1497 | 1499 |
1498 // The panel should have become larger in both dimensions (the minimums | 1500 // The panel should have become larger in both dimensions (the minimums |
1499 // has to be set to be smaller then a simple 1-line content, so the autosize | 1501 // has to be set to be smaller then a simple 1-line content, so the autosize |
1500 // can work correctly. | 1502 // can work correctly. |
1501 EXPECT_GT(panel->GetBounds().width(), initial_width); | 1503 EXPECT_GT(panel->GetBounds().width(), initial_width); |
1502 EXPECT_GT(panel->GetBounds().height(), initial_height); | 1504 EXPECT_GT(panel->GetBounds().height(), initial_height); |
1503 | 1505 |
1504 panel->Close(); | 1506 panel->Close(); |
1505 } | 1507 } |
1506 | 1508 |
1507 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1509 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, |
1508 DefaultMaxSizeOnDisplaySettingsChange) { | 1510 DefaultMaxSizeOnDisplaySettingsChange) { |
1509 Panel* panel = CreatePanelWithBounds("1", gfx::Rect(0, 0, 240, 220)); | 1511 Panel* panel = CreatePanelWithBounds("1", gfx::Rect(0, 0, 240, 220)); |
1510 | 1512 |
1511 gfx::Size old_max_size = panel->max_size(); | 1513 gfx::Size old_max_size = panel->max_size(); |
1512 gfx::Size old_full_size = panel->full_size(); | 1514 gfx::Size old_full_size = panel->full_size(); |
1513 | 1515 |
1514 // Shrink the work area. Expect max size and full size become smaller. | 1516 // Shrink the work area. Expect max size and full size become smaller. |
1515 gfx::Size smaller_work_area_size = gfx::Size(500, 300); | 1517 gfx::Size smaller_work_area_size = gfx::Size(500, 300); |
1516 SetTestingAreas(gfx::Rect(gfx::Point(0, 0), smaller_work_area_size), | 1518 SetTestingAreas(gfx::Rect(gfx::Point(0, 0), smaller_work_area_size), |
1517 gfx::Rect()); | 1519 gfx::Rect()); |
1518 EXPECT_GT(old_max_size.width(), panel->max_size().width()); | 1520 EXPECT_GT(old_max_size.width(), panel->max_size().width()); |
1519 EXPECT_GT(old_max_size.height(), panel->max_size().height()); | 1521 EXPECT_GT(old_max_size.height(), panel->max_size().height()); |
1520 EXPECT_GT(smaller_work_area_size.width(), panel->max_size().width()); | 1522 EXPECT_GT(smaller_work_area_size.width(), panel->max_size().width()); |
1521 EXPECT_GT(smaller_work_area_size.height(), panel->max_size().height()); | 1523 EXPECT_GT(smaller_work_area_size.height(), panel->max_size().height()); |
1522 EXPECT_GT(old_full_size.width(), panel->full_size().width()); | 1524 EXPECT_GT(old_full_size.width(), panel->full_size().width()); |
1523 EXPECT_GT(old_full_size.height(), panel->full_size().height()); | 1525 EXPECT_GT(old_full_size.height(), panel->full_size().height()); |
1524 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); | 1526 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); |
1525 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); | 1527 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); |
1526 | 1528 |
1527 panel->Close(); | 1529 panel->Close(); |
1528 } | 1530 } |
1529 | 1531 |
1530 IN_PROC_BROWSER_TEST_F(PanelBrowserTest, | 1532 IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, |
1531 CustomMaxSizeOnDisplaySettingsChange) { | 1533 CustomMaxSizeOnDisplaySettingsChange) { |
1532 PanelManager* panel_manager = PanelManager::GetInstance(); | 1534 PanelManager* panel_manager = PanelManager::GetInstance(); |
1533 Panel* panel = CreatePanelWithBounds("1", gfx::Rect(0, 0, 240, 220)); | 1535 Panel* panel = CreatePanelWithBounds("1", gfx::Rect(0, 0, 240, 220)); |
1534 | 1536 |
1535 // Trigger custom max size by user resizing. | 1537 // Trigger custom max size by user resizing. |
1536 gfx::Size bigger_size = gfx::Size(550, 400); | 1538 gfx::Size bigger_size = gfx::Size(550, 400); |
1537 gfx::Point mouse_location = panel->GetBounds().origin(); | 1539 gfx::Point mouse_location = panel->GetBounds().origin(); |
1538 panel_manager->StartResizingByMouse(panel, | 1540 panel_manager->StartResizingByMouse(panel, |
1539 mouse_location, | 1541 mouse_location, |
1540 panel::RESIZE_TOP_LEFT); | 1542 panel::RESIZE_TOP_LEFT); |
(...skipping 17 matching lines...) Expand all Loading... |
1558 EXPECT_EQ(smaller_work_area_size.height(), panel->max_size().height()); | 1560 EXPECT_EQ(smaller_work_area_size.height(), panel->max_size().height()); |
1559 EXPECT_GT(old_full_size.width(), panel->full_size().width()); | 1561 EXPECT_GT(old_full_size.width(), panel->full_size().width()); |
1560 EXPECT_GT(old_full_size.height(), panel->full_size().height()); | 1562 EXPECT_GT(old_full_size.height(), panel->full_size().height()); |
1561 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); | 1563 EXPECT_GE(panel->max_size().width(), panel->full_size().width()); |
1562 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); | 1564 EXPECT_GE(panel->max_size().height(), panel->full_size().height()); |
1563 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); | 1565 EXPECT_EQ(smaller_work_area_size.height(), panel->full_size().height()); |
1564 | 1566 |
1565 panel->Close(); | 1567 panel->Close(); |
1566 } | 1568 } |
1567 | 1569 |
1568 class PanelDownloadTest : public PanelBrowserTest { | 1570 class OldPanelDownloadTest : public OldPanelBrowserTest { |
1569 public: | 1571 public: |
1570 PanelDownloadTest() : PanelBrowserTest() { } | 1572 OldPanelDownloadTest() : OldPanelBrowserTest() { } |
1571 | 1573 |
1572 // Creates a temporary directory for downloads that is auto-deleted | 1574 // Creates a temporary directory for downloads that is auto-deleted |
1573 // on destruction. | 1575 // on destruction. |
1574 bool CreateDownloadDirectory(Profile* profile) { | 1576 bool CreateDownloadDirectory(Profile* profile) { |
1575 bool created = downloads_directory_.CreateUniqueTempDir(); | 1577 bool created = downloads_directory_.CreateUniqueTempDir(); |
1576 if (!created) | 1578 if (!created) |
1577 return false; | 1579 return false; |
1578 profile->GetPrefs()->SetFilePath( | 1580 profile->GetPrefs()->SetFilePath( |
1579 prefs::kDownloadDefaultDirectory, | 1581 prefs::kDownloadDefaultDirectory, |
1580 downloads_directory_.path()); | 1582 downloads_directory_.path()); |
1581 return true; | 1583 return true; |
1582 } | 1584 } |
1583 | 1585 |
1584 protected: | 1586 protected: |
1585 void SetUpOnMainThread() OVERRIDE { | 1587 void SetUpOnMainThread() OVERRIDE { |
1586 PanelBrowserTest::SetUpOnMainThread(); | 1588 OldPanelBrowserTest::SetUpOnMainThread(); |
1587 | 1589 |
1588 BrowserThread::PostTask( | 1590 BrowserThread::PostTask( |
1589 BrowserThread::IO, FROM_HERE, | 1591 BrowserThread::IO, FROM_HERE, |
1590 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); | 1592 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); |
1591 } | 1593 } |
1592 | 1594 |
1593 private: | 1595 private: |
1594 // Location of the downloads directory for download tests. | 1596 // Location of the downloads directory for download tests. |
1595 ScopedTempDir downloads_directory_; | 1597 ScopedTempDir downloads_directory_; |
1596 }; | 1598 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 } | 1638 } |
1637 | 1639 |
1638 private: | 1640 private: |
1639 DownloadManager* download_manager_; | 1641 DownloadManager* download_manager_; |
1640 bool saw_download_; | 1642 bool saw_download_; |
1641 bool waiting_; | 1643 bool waiting_; |
1642 }; | 1644 }; |
1643 | 1645 |
1644 // Verify that the download shelf is opened in the existing tabbed browser | 1646 // Verify that the download shelf is opened in the existing tabbed browser |
1645 // when a download is started in a Panel. | 1647 // when a download is started in a Panel. |
1646 IN_PROC_BROWSER_TEST_F(PanelDownloadTest, Download) { | 1648 IN_PROC_BROWSER_TEST_F(OldPanelDownloadTest, Download) { |
1647 Profile* profile = browser()->profile(); | 1649 Profile* profile = browser()->profile(); |
1648 ASSERT_TRUE(CreateDownloadDirectory(profile)); | 1650 ASSERT_TRUE(CreateDownloadDirectory(profile)); |
1649 Browser* panel_browser = Browser::CreateWithParams( | 1651 Browser* panel_browser = Browser::CreateWithParams( |
1650 Browser::CreateParams::CreateForApp( | 1652 Browser::CreateParams::CreateForApp( |
1651 Browser::TYPE_PANEL, "PanelTest", gfx::Rect(), profile)); | 1653 Browser::TYPE_PANEL, "PanelTest", gfx::Rect(), profile)); |
1652 EXPECT_EQ(2U, BrowserList::size()); | 1654 EXPECT_EQ(2U, BrowserList::size()); |
1653 ASSERT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 1655 ASSERT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
1654 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); | 1656 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); |
1655 | 1657 |
1656 scoped_ptr<DownloadObserver> observer(new DownloadObserver(profile)); | 1658 scoped_ptr<DownloadObserver> observer(new DownloadObserver(profile)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 | 1691 |
1690 // See crbug 113779. | 1692 // See crbug 113779. |
1691 #if defined(OS_MACOSX) | 1693 #if defined(OS_MACOSX) |
1692 #define MAYBE_DownloadNoTabbedBrowser DISABLED_DownloadNoTabbedBrowser | 1694 #define MAYBE_DownloadNoTabbedBrowser DISABLED_DownloadNoTabbedBrowser |
1693 #else | 1695 #else |
1694 #define MAYBE_DownloadNoTabbedBrowser DownloadNoTabbedBrowser | 1696 #define MAYBE_DownloadNoTabbedBrowser DownloadNoTabbedBrowser |
1695 #endif | 1697 #endif |
1696 // Verify that a new tabbed browser is created to display a download | 1698 // Verify that a new tabbed browser is created to display a download |
1697 // shelf when a download is started in a Panel and there is no existing | 1699 // shelf when a download is started in a Panel and there is no existing |
1698 // tabbed browser. | 1700 // tabbed browser. |
1699 IN_PROC_BROWSER_TEST_F(PanelDownloadTest, MAYBE_DownloadNoTabbedBrowser) { | 1701 IN_PROC_BROWSER_TEST_F(OldPanelDownloadTest, MAYBE_DownloadNoTabbedBrowser) { |
1700 Profile* profile = browser()->profile(); | 1702 Profile* profile = browser()->profile(); |
1701 ASSERT_TRUE(CreateDownloadDirectory(profile)); | 1703 ASSERT_TRUE(CreateDownloadDirectory(profile)); |
1702 Browser* panel_browser = Browser::CreateWithParams( | 1704 Browser* panel_browser = Browser::CreateWithParams( |
1703 Browser::CreateParams::CreateForApp( | 1705 Browser::CreateParams::CreateForApp( |
1704 Browser::TYPE_PANEL, "PanelTest", gfx::Rect(), profile)); | 1706 Browser::TYPE_PANEL, "PanelTest", gfx::Rect(), profile)); |
1705 EXPECT_EQ(2U, BrowserList::size()); | 1707 EXPECT_EQ(2U, BrowserList::size()); |
1706 ASSERT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 1708 ASSERT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
1707 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); | 1709 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); |
1708 | 1710 |
1709 ui_test_utils::WindowedNotificationObserver signal( | 1711 ui_test_utils::WindowedNotificationObserver signal( |
(...skipping 19 matching lines...) Expand all Loading... |
1729 Browser* tabbed_browser = browser::FindTabbedBrowser(profile, false); | 1731 Browser* tabbed_browser = browser::FindTabbedBrowser(profile, false); |
1730 EXPECT_EQ(1, tabbed_browser->tab_count()); | 1732 EXPECT_EQ(1, tabbed_browser->tab_count()); |
1731 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); | 1733 ASSERT_TRUE(tabbed_browser->window()->IsDownloadShelfVisible()); |
1732 tabbed_browser->CloseWindow(); | 1734 tabbed_browser->CloseWindow(); |
1733 | 1735 |
1734 EXPECT_EQ(1, panel_browser->tab_count()); | 1736 EXPECT_EQ(1, panel_browser->tab_count()); |
1735 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); | 1737 ASSERT_FALSE(panel_browser->window()->IsDownloadShelfVisible()); |
1736 | 1738 |
1737 panel_browser->CloseWindow(); | 1739 panel_browser->CloseWindow(); |
1738 } | 1740 } |
OLD | NEW |