OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/views/cocoa/cocoa_mouse_capture.h" | 5 #import "ui/views/cocoa/cocoa_mouse_capture.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 void SimulateDestroy() { mouse_capture_.reset(); } | 43 void SimulateDestroy() { mouse_capture_.reset(); } |
44 | 44 |
45 int event_count() { return event_count_; } | 45 int event_count() { return event_count_; } |
46 int capture_lost_count() { return capture_lost_count_; } | 46 int capture_lost_count() { return capture_lost_count_; } |
47 | 47 |
48 // CocoaMouseCaptureDelegate: | 48 // CocoaMouseCaptureDelegate: |
49 void PostCapturedEvent(NSEvent* event) override { ++event_count_; } | 49 void PostCapturedEvent(NSEvent* event) override { ++event_count_; } |
50 void OnMouseCaptureLost() override { ++capture_lost_count_; } | 50 void OnMouseCaptureLost() override { ++capture_lost_count_; } |
51 | 51 |
52 private: | 52 private: |
53 scoped_ptr<CocoaMouseCapture> mouse_capture_; | 53 std::unique_ptr<CocoaMouseCapture> mouse_capture_; |
54 int event_count_; | 54 int event_count_; |
55 int capture_lost_count_; | 55 int capture_lost_count_; |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(TestCaptureDelegate); | 57 DISALLOW_COPY_AND_ASSIGN(TestCaptureDelegate); |
58 }; | 58 }; |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 typedef ui::CocoaTest CocoaMouseCaptureTest; | 62 typedef ui::CocoaTest CocoaMouseCaptureTest; |
63 | 63 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 EXPECT_EQ(1, [view mouseDownCount]); | 119 EXPECT_EQ(1, [view mouseDownCount]); |
120 EXPECT_EQ(1, capture.event_count()); | 120 EXPECT_EQ(1, capture.event_count()); |
121 } | 121 } |
122 | 122 |
123 // After the capture goes away, events should be received again. | 123 // After the capture goes away, events should be received again. |
124 [NSApp sendEvent:click.first]; | 124 [NSApp sendEvent:click.first]; |
125 EXPECT_EQ(2, [view mouseDownCount]); | 125 EXPECT_EQ(2, [view mouseDownCount]); |
126 } | 126 } |
127 | 127 |
128 } // namespace views | 128 } // namespace views |
OLD | NEW |