OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 7 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
8 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" | 8 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/geometry/point.h" |
11 | 11 |
12 class TestMouseObserver : public PanelMouseWatcherObserver { | 12 class TestMouseObserver : public PanelMouseWatcherObserver { |
13 public: | 13 public: |
14 TestMouseObserver() : mouse_movements_(0) {} | 14 TestMouseObserver() : mouse_movements_(0) {} |
15 // Overridden from PanelMouseWatcherObserver: | 15 // Overridden from PanelMouseWatcherObserver: |
16 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE { | 16 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE { |
17 ++mouse_movements_; | 17 ++mouse_movements_; |
18 } | 18 } |
19 int mouse_movements_; | 19 int mouse_movements_; |
20 }; | 20 }; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 // Back to one observer. | 56 // Back to one observer. |
57 watcher->RemoveObserver(user1.get()); | 57 watcher->RemoveObserver(user1.get()); |
58 EXPECT_TRUE(watcher->IsActive()); | 58 EXPECT_TRUE(watcher->IsActive()); |
59 int saved_count = user1->mouse_movements_; | 59 int saved_count = user1->mouse_movements_; |
60 watcher->NotifyMouseMovement(gfx::Point(1, 2)); | 60 watcher->NotifyMouseMovement(gfx::Point(1, 2)); |
61 EXPECT_EQ(saved_count, user1->mouse_movements_); | 61 EXPECT_EQ(saved_count, user1->mouse_movements_); |
62 EXPECT_GE(user2->mouse_movements_, 2); | 62 EXPECT_GE(user2->mouse_movements_, 2); |
63 watcher->RemoveObserver(user2.get()); | 63 watcher->RemoveObserver(user2.get()); |
64 EXPECT_FALSE(watcher->IsActive()); | 64 EXPECT_FALSE(watcher->IsActive()); |
65 } | 65 } |
OLD | NEW |