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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "chrome/browser/ui/panels/base_panel_browser_test.h" | 6 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
7 #include "chrome/browser/ui/panels/detached_panel_strip.h" | 7 #include "chrome/browser/ui/panels/detached_panel_strip.h" |
8 #include "chrome/browser/ui/panels/docked_panel_strip.h" | 8 #include "chrome/browser/ui/panels/docked_panel_strip.h" |
9 #include "chrome/browser/ui/panels/native_panel.h" | 9 #include "chrome/browser/ui/panels/native_panel.h" |
10 #include "chrome/browser/ui/panels/panel.h" | 10 #include "chrome/browser/ui/panels/panel.h" |
11 #include "chrome/browser/ui/panels/panel_drag_controller.h" | 11 #include "chrome/browser/ui/panels/panel_drag_controller.h" |
12 #include "chrome/browser/ui/panels/panel_manager.h" | 12 #include "chrome/browser/ui/panels/panel_manager.h" |
13 #include "chrome/browser/ui/panels/test_panel_mouse_watcher.h" | |
13 | 14 |
14 class PanelDragBrowserTest : public BasePanelBrowserTest { | 15 class PanelDragBrowserTest : public BasePanelBrowserTest { |
15 public: | 16 public: |
16 PanelDragBrowserTest() : BasePanelBrowserTest() { | 17 PanelDragBrowserTest() : BasePanelBrowserTest() { |
17 } | 18 } |
18 | 19 |
19 virtual ~PanelDragBrowserTest() { | 20 virtual ~PanelDragBrowserTest() { |
20 } | 21 } |
21 | 22 |
22 virtual void SetUpOnMainThread() OVERRIDE { | 23 virtual void SetUpOnMainThread() OVERRIDE { |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 EXPECT_EQ(mouse_location, panel3->GetBounds().origin()); | 394 EXPECT_EQ(mouse_location, panel3->GetBounds().origin()); |
394 | 395 |
395 panel3_testing->CancelDragTitlebar(); | 396 panel3_testing->CancelDragTitlebar(); |
396 EXPECT_EQ(position2, panel1->GetBounds().origin()); | 397 EXPECT_EQ(position2, panel1->GetBounds().origin()); |
397 EXPECT_EQ(position3, panel2->GetBounds().origin()); | 398 EXPECT_EQ(position3, panel2->GetBounds().origin()); |
398 EXPECT_EQ(position1, panel3->GetBounds().origin()); | 399 EXPECT_EQ(position1, panel3->GetBounds().origin()); |
399 | 400 |
400 PanelManager::GetInstance()->CloseAll(); | 401 PanelManager::GetInstance()->CloseAll(); |
401 } | 402 } |
402 | 403 |
404 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragMinimizedPanel) { | |
405 // We'll simulate mouse movements for test. | |
406 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
407 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | |
408 | |
409 Panel* panel = CreatePanel("panel1"); | |
410 scoped_ptr<NativePanelTesting> panel_testing( | |
411 NativePanelTesting::Create(panel->native_panel())); | |
412 | |
413 panel->Minimize(); | |
414 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | |
415 | |
416 // Hover over minimized panel to bring up titlebar. | |
417 gfx::Point hover_point(panel->GetBounds().origin()); | |
418 MoveMouseAndWaitForExpansionStateChange(panel, hover_point); | |
419 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | |
420 | |
421 // Verify we can drag a minimized panel. | |
422 gfx::Rect panel_old_bounds = panel->GetBounds(); | |
423 gfx::Point mouse_location = panel_old_bounds.origin(); | |
424 panel_testing->PressLeftMouseButtonTitlebar(mouse_location); | |
425 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); | |
426 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | |
427 | |
428 mouse_location.Offset(-70, 0); | |
429 panel_testing->DragTitlebar(mouse_location); | |
430 gfx::Rect panel_new_bounds = panel_old_bounds; | |
431 panel_new_bounds.Offset(-70, 0); | |
432 EXPECT_EQ(panel_new_bounds, panel->GetBounds()); | |
jianli
2012/05/15 22:59:47
Can you also verify that panel is still in title-o
jennb
2012/05/16 00:47:09
Done.
| |
433 | |
434 // Verify panel returns to fully minimized state after dragging ends. | |
435 panel_testing->FinishDragTitlebar(); | |
436 MoveMouseAndWaitForExpansionStateChange(panel, mouse_location); | |
437 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | |
jianli
2012/05/15 22:59:47
Can we have a test that we're dragging a title-onl
jennb
2012/05/16 00:47:09
Added check after FinishDragTitlebar() to verify t
| |
438 | |
439 panel->Close(); | |
440 } | |
441 | |
442 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, DragMinimizedDrawAttentionPanel) { | |
jianli
2012/05/15 22:59:47
DragMinimizedDrawAttentionPanel => DragMinimizedDr
jennb
2012/05/16 00:47:09
DragMinimizedPanelWhileDrawingAttention
| |
443 // We'll simulate mouse movements for test. | |
444 PanelMouseWatcher* mouse_watcher = new TestPanelMouseWatcher(); | |
445 PanelManager::GetInstance()->SetMouseWatcherForTesting(mouse_watcher); | |
446 | |
447 Panel* panel = CreatePanel("panel1"); | |
448 scoped_ptr<NativePanelTesting> panel_testing( | |
449 NativePanelTesting::Create(panel->native_panel())); | |
450 | |
451 panel->Minimize(); | |
452 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | |
453 | |
454 panel->FlashFrame(true); | |
455 EXPECT_TRUE(panel->IsDrawingAttention()); | |
456 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | |
457 | |
458 // Drag the panel. Verify panel stays in title-only state after attention is | |
459 // cleared because it is being dragged. | |
460 gfx::Rect panel_old_bounds = panel->GetBounds(); | |
461 gfx::Point mouse_location = panel_old_bounds.origin(); | |
462 panel_testing->PressLeftMouseButtonTitlebar(mouse_location); | |
463 EXPECT_EQ(panel_old_bounds, panel->GetBounds()); | |
464 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | |
465 | |
466 mouse_location.Offset(-70, 0); | |
467 panel_testing->DragTitlebar(mouse_location); | |
468 gfx::Rect panel_new_bounds = panel_old_bounds; | |
469 panel_new_bounds.Offset(-70, 0); | |
470 EXPECT_EQ(panel_new_bounds, panel->GetBounds()); | |
471 | |
472 panel->FlashFrame(false); | |
473 EXPECT_FALSE(panel->IsDrawingAttention()); | |
474 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | |
475 | |
476 // Verify panel returns to fully minimized state after dragging ends. | |
477 panel_testing->FinishDragTitlebar(); | |
478 MoveMouseAndWaitForExpansionStateChange(panel, mouse_location); | |
479 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | |
480 | |
481 panel->Close(); | |
482 } | |
483 | |
403 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, CloseDockedPanelOnDrag) { | 484 IN_PROC_BROWSER_TEST_F(PanelDragBrowserTest, CloseDockedPanelOnDrag) { |
404 PanelManager* panel_manager = PanelManager::GetInstance(); | 485 PanelManager* panel_manager = PanelManager::GetInstance(); |
405 PanelDragController* drag_controller = panel_manager->drag_controller(); | 486 PanelDragController* drag_controller = panel_manager->drag_controller(); |
406 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); | 487 DockedPanelStrip* docked_strip = panel_manager->docked_strip(); |
407 | 488 |
408 // Create 4 docked panels. | 489 // Create 4 docked panels. |
409 // We have: P4 P3 P2 P1 | 490 // We have: P4 P3 P2 P1 |
410 Panel* panel1 = CreatePanelWithBounds("Panel1", gfx::Rect(0, 0, 100, 100)); | 491 Panel* panel1 = CreatePanelWithBounds("Panel1", gfx::Rect(0, 0, 100, 100)); |
411 Panel* panel2 = CreatePanelWithBounds("Panel2", gfx::Rect(0, 0, 100, 100)); | 492 Panel* panel2 = CreatePanelWithBounds("Panel2", gfx::Rect(0, 0, 100, 100)); |
412 Panel* panel3 = CreatePanelWithBounds("Panel3", gfx::Rect(0, 0, 100, 100)); | 493 Panel* panel3 = CreatePanelWithBounds("Panel3", gfx::Rect(0, 0, 100, 100)); |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1215 EXPECT_EQ(PanelStrip::DOCKED, panel1->panel_strip()->type()); | 1296 EXPECT_EQ(PanelStrip::DOCKED, panel1->panel_strip()->type()); |
1216 EXPECT_EQ(PanelStrip::DOCKED, panel2->panel_strip()->type()); | 1297 EXPECT_EQ(PanelStrip::DOCKED, panel2->panel_strip()->type()); |
1217 EXPECT_EQ(PanelStrip::DOCKED, panel3->panel_strip()->type()); | 1298 EXPECT_EQ(PanelStrip::DOCKED, panel3->panel_strip()->type()); |
1218 EXPECT_EQ(PanelStrip::DOCKED, panel4->panel_strip()->type()); | 1299 EXPECT_EQ(PanelStrip::DOCKED, panel4->panel_strip()->type()); |
1219 EXPECT_EQ(PanelStrip::DOCKED, panel5->panel_strip()->type()); | 1300 EXPECT_EQ(PanelStrip::DOCKED, panel5->panel_strip()->type()); |
1220 EXPECT_EQ(PanelStrip::DOCKED, panel6->panel_strip()->type()); | 1301 EXPECT_EQ(PanelStrip::DOCKED, panel6->panel_strip()->type()); |
1221 EXPECT_EQ(PanelStrip::DOCKED, panel7->panel_strip()->type()); | 1302 EXPECT_EQ(PanelStrip::DOCKED, panel7->panel_strip()->type()); |
1222 | 1303 |
1223 panel_manager->CloseAll(); | 1304 panel_manager->CloseAll(); |
1224 } | 1305 } |
OLD | NEW |