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

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

Issue 9403035: Refactor intra-strip panel drags by introducing PanelDragController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final patch for commit Created 8 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/ui/panels/detached_panel_strip.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/panels/base_panel_browser_test.h"
6 #include "chrome/browser/ui/panels/detached_panel_strip.h"
7 #include "chrome/browser/ui/panels/native_panel.h"
8 #include "chrome/browser/ui/panels/panel.h"
9 #include "chrome/browser/ui/panels/panel_manager.h"
10
11 class DetachedPanelBrowserTest : public BasePanelBrowserTest {
12 };
13
14 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, CheckDetachedPanelProperties) {
15 PanelManager* panel_manager = PanelManager::GetInstance();
16 DetachedPanelStrip* detached_strip = panel_manager->detached_strip();
17
18 // Create 2 panels.
19 Panel* panel1 = CreatePanelWithBounds("Panel1", gfx::Rect(0, 0, 250, 200));
20 Panel* panel2 = CreatePanelWithBounds("Panel2", gfx::Rect(0, 0, 300, 200));
21
22 EXPECT_TRUE(panel1->draggable());
23 EXPECT_TRUE(panel2->draggable());
24
25 // Move panels to detached strip.
26 EXPECT_EQ(2, panel_manager->num_panels());
27 EXPECT_EQ(0, detached_strip->num_panels());
28 panel1->MoveToStrip(detached_strip);
29 panel2->MoveToStrip(detached_strip);
30 EXPECT_EQ(2, panel_manager->num_panels());
31 EXPECT_EQ(2, detached_strip->num_panels());
32
33 std::vector<Panel*> panels = panel_manager->panels();
34 EXPECT_EQ(panel1, panels[0]);
35 EXPECT_EQ(panel2, panels[1]);
36
37 EXPECT_TRUE(panel1->draggable());
38 EXPECT_TRUE(panel2->draggable());
39
40 panel_manager->CloseAll();
41 }
42
43 IN_PROC_BROWSER_TEST_F(DetachedPanelBrowserTest, DragDetachedPanel) {
44 PanelManager* panel_manager = PanelManager::GetInstance();
45 DetachedPanelStrip* detached_strip = panel_manager->detached_strip();
46
47 // Create one detached panel.
48 Panel* panel = CreatePanelWithBounds("Panel1", gfx::Rect(0, 0, 250, 200));
49 panel->MoveToStrip(detached_strip);
50
51 // Test that the detached panel can be dragged anywhere.
52 scoped_ptr<NativePanelTesting> panel_testing(
53 NativePanelTesting::Create(panel->native_panel()));
54 gfx::Point origin = panel->GetBounds().origin();
55
56 panel_testing->PressLeftMouseButtonTitlebar(origin);
57 EXPECT_EQ(origin, panel->GetBounds().origin());
58
59 panel_testing->DragTitlebar(-51, 102);
60 origin.Offset(-51, 102);
61 EXPECT_EQ(origin, panel->GetBounds().origin());
62
63 panel_testing->DragTitlebar(37, -42);
64 origin.Offset(37, -42);
65 EXPECT_EQ(origin, panel->GetBounds().origin());
66
67 panel_testing->FinishDragTitlebar();
68 EXPECT_EQ(origin, panel->GetBounds().origin());
69
70 // Test that cancelling the drag will return the panel the the original
71 // position.
72 gfx::Point original_position = panel->GetBounds().origin();
73 origin = original_position;
74
75 panel_testing->PressLeftMouseButtonTitlebar(origin);
76 EXPECT_EQ(origin, panel->GetBounds().origin());
77
78 panel_testing->DragTitlebar(-51, 102);
79 origin.Offset(-51, 102);
80 EXPECT_EQ(origin, panel->GetBounds().origin());
81
82 panel_testing->DragTitlebar(37, -42);
83 origin.Offset(37, -42);
84 EXPECT_EQ(origin, panel->GetBounds().origin());
85
86 panel_testing->CancelDragTitlebar();
87 EXPECT_EQ(original_position, panel->GetBounds().origin());
88
89 panel_manager->CloseAll();
90 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/panels/detached_panel_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698