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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/notifications/balloon.h" | 7 #include "chrome/browser/notifications/balloon.h" |
8 #include "chrome/browser/notifications/balloon_collection_impl.h" | 8 #include "chrome/browser/notifications/balloon_collection_impl.h" |
9 #include "chrome/browser/notifications/desktop_notification_service.h" | 9 #include "chrome/browser/notifications/desktop_notification_service.h" |
10 #include "chrome/browser/notifications/notification.h" | 10 #include "chrome/browser/notifications/notification.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 static void DragPanelToMouseLocation(Panel* panel, | 94 static void DragPanelToMouseLocation(Panel* panel, |
95 const gfx::Point& new_mouse_location) { | 95 const gfx::Point& new_mouse_location) { |
96 PanelManager* panel_manager = PanelManager::GetInstance(); | 96 PanelManager* panel_manager = PanelManager::GetInstance(); |
97 panel_manager->StartDragging(panel, panel->GetBounds().origin()); | 97 panel_manager->StartDragging(panel, panel->GetBounds().origin()); |
98 panel_manager->Drag(new_mouse_location); | 98 panel_manager->Drag(new_mouse_location); |
99 panel_manager->EndDragging(false); | 99 panel_manager->EndDragging(false); |
100 } | 100 } |
101 | 101 |
102 static void ResizePanelByMouseWithDelta(Panel* panel, | 102 static void ResizePanelByMouseWithDelta(Panel* panel, |
103 panel::ResizingSides side, | 103 panel::ResizingSides side, |
104 const gfx::Point& delta) { | 104 const gfx::Vector2d& delta) { |
105 PanelManager* panel_manager = PanelManager::GetInstance(); | 105 PanelManager* panel_manager = PanelManager::GetInstance(); |
106 gfx::Point mouse_location = panel->GetBounds().origin(); | 106 gfx::Point mouse_location = panel->GetBounds().origin(); |
107 panel_manager->StartResizingByMouse(panel, mouse_location, side); | 107 panel_manager->StartResizingByMouse(panel, mouse_location, side); |
108 panel_manager->ResizeByMouse(mouse_location.Add(delta)); | 108 panel_manager->ResizeByMouse(mouse_location.Add(delta)); |
109 panel_manager->EndResizingByMouse(false); | 109 panel_manager->EndResizingByMouse(false); |
110 } | 110 } |
111 | 111 |
112 DesktopNotificationService* service() const { return service_.get(); } | 112 DesktopNotificationService* service() const { return service_.get(); } |
113 const BalloonCollection::Balloons& balloons() const { | 113 const BalloonCollection::Balloons& balloons() const { |
114 return balloons_->GetActiveBalloons(); | 114 return balloons_->GetActiveBalloons(); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 301 |
302 // Create a docked panel. Expect that the notification balloon moves up to be | 302 // Create a docked panel. Expect that the notification balloon moves up to be |
303 // above the panel. | 303 // above the panel. |
304 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 200)); | 304 Panel* panel = CreateDockedPanel("1", gfx::Rect(0, 0, 200, 200)); |
305 MessageLoopForUI::current()->RunAllPending(); | 305 MessageLoopForUI::current()->RunAllPending(); |
306 int balloon_bottom = GetBalloonBottomPosition(balloon); | 306 int balloon_bottom = GetBalloonBottomPosition(balloon); |
307 EXPECT_LT(balloon_bottom, panel->GetBounds().y()); | 307 EXPECT_LT(balloon_bottom, panel->GetBounds().y()); |
308 | 308 |
309 // Resize the panel to make it taller. Expect that the notification balloon | 309 // Resize the panel to make it taller. Expect that the notification balloon |
310 // moves further up by the amount of enlarge offset. | 310 // moves further up by the amount of enlarge offset. |
311 gfx::Point drag_delta(-50, -100); | 311 gfx::Vector2d drag_delta(-50, -100); |
312 ResizePanelByMouseWithDelta(panel, panel::RESIZE_TOP_LEFT, drag_delta); | 312 ResizePanelByMouseWithDelta(panel, panel::RESIZE_TOP_LEFT, drag_delta); |
313 MessageLoopForUI::current()->RunAllPending(); | 313 MessageLoopForUI::current()->RunAllPending(); |
314 int balloon_bottom2 = GetBalloonBottomPosition(balloon); | 314 int balloon_bottom2 = GetBalloonBottomPosition(balloon); |
315 EXPECT_EQ(balloon_bottom + drag_delta.y(), balloon_bottom2); | 315 EXPECT_EQ(balloon_bottom + drag_delta.y(), balloon_bottom2); |
316 | 316 |
317 // Resize the panel to make it shorter. Expect that the notification balloon | 317 // Resize the panel to make it shorter. Expect that the notification balloon |
318 // moves down by the amount of shrink offset. | 318 // moves down by the amount of shrink offset. |
319 drag_delta = gfx::Point(0, 60); | 319 drag_delta = gfx::Vector2d(0, 60); |
320 ResizePanelByMouseWithDelta(panel, panel::RESIZE_TOP, drag_delta); | 320 ResizePanelByMouseWithDelta(panel, panel::RESIZE_TOP, drag_delta); |
321 MessageLoopForUI::current()->RunAllPending(); | 321 MessageLoopForUI::current()->RunAllPending(); |
322 int balloon_bottom3 = GetBalloonBottomPosition(balloon); | 322 int balloon_bottom3 = GetBalloonBottomPosition(balloon); |
323 EXPECT_EQ(balloon_bottom2 + drag_delta.y(), balloon_bottom3); | 323 EXPECT_EQ(balloon_bottom2 + drag_delta.y(), balloon_bottom3); |
324 | 324 |
325 PanelManager::GetInstance()->CloseAll(); | 325 PanelManager::GetInstance()->CloseAll(); |
326 } | 326 } |
327 | 327 |
328 IN_PROC_BROWSER_TEST_F(PanelAndDesktopNotificationTest, InteractWithTwoPanels) { | 328 IN_PROC_BROWSER_TEST_F(PanelAndDesktopNotificationTest, InteractWithTwoPanels) { |
329 Balloon* balloon = CreateBalloon(); | 329 Balloon* balloon = CreateBalloon(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 MessageLoopForUI::current()->RunAllPending(); | 393 MessageLoopForUI::current()->RunAllPending(); |
394 EXPECT_EQ(balloon_bottom_after_short_panel_created, | 394 EXPECT_EQ(balloon_bottom_after_short_panel_created, |
395 GetBalloonBottomPosition(balloon)); | 395 GetBalloonBottomPosition(balloon)); |
396 | 396 |
397 // Close short panel. Expect that the notification balloo moves back to its | 397 // Close short panel. Expect that the notification balloo moves back to its |
398 // original position. | 398 // original position. |
399 short_panel->Close(); | 399 short_panel->Close(); |
400 MessageLoopForUI::current()->RunAllPending(); | 400 MessageLoopForUI::current()->RunAllPending(); |
401 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); | 401 EXPECT_EQ(original_balloon_bottom, GetBalloonBottomPosition(balloon)); |
402 } | 402 } |
OLD | NEW |