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

Unified Diff: ui/views/cocoa/cocoa_mouse_capture_unittest.mm

Issue 2096993002: MacViews: Fix failing mouse capture unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mouse_capture_lifetime
Patch Set: Enable tests. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/cocoa/cocoa_mouse_capture_delegate.h ('k') | ui/views/controls/menu/menu_runner_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/cocoa_mouse_capture_unittest.mm
diff --git a/ui/views/cocoa/cocoa_mouse_capture_unittest.mm b/ui/views/cocoa/cocoa_mouse_capture_unittest.mm
index 5b4e2bdf9954b3f9d5b18feb598068110f81b2f1..a3edec35d96885862c9b5e3943146790b5c16e7b 100644
--- a/ui/views/cocoa/cocoa_mouse_capture_unittest.mm
+++ b/ui/views/cocoa/cocoa_mouse_capture_unittest.mm
@@ -36,7 +36,8 @@ namespace {
// Simple capture delegate that just counts events forwarded.
class TestCaptureDelegate : public CocoaMouseCaptureDelegate {
public:
- TestCaptureDelegate() : event_count_(0), capture_lost_count_(0) {}
+ explicit TestCaptureDelegate(NSWindow* window)
+ : event_count_(0), capture_lost_count_(0), window_(window) {}
void Acquire() { mouse_capture_.reset(new CocoaMouseCapture(this)); }
bool IsActive() { return mouse_capture_ && mouse_capture_->IsActive(); }
@@ -48,11 +49,13 @@ class TestCaptureDelegate : public CocoaMouseCaptureDelegate {
// CocoaMouseCaptureDelegate:
void PostCapturedEvent(NSEvent* event) override { ++event_count_; }
void OnMouseCaptureLost() override { ++capture_lost_count_; }
+ NSWindow* GetWindow() const override { return window_; }
private:
std::unique_ptr<CocoaMouseCapture> mouse_capture_;
int event_count_;
int capture_lost_count_;
+ NSWindow* window_;
DISALLOW_COPY_AND_ASSIGN(TestCaptureDelegate);
};
@@ -63,12 +66,12 @@ typedef ui::CocoaTest CocoaMouseCaptureTest;
// Test that a new capture properly "steals" capture from an existing one.
TEST_F(CocoaMouseCaptureTest, OnCaptureLost) {
- TestCaptureDelegate capture;
+ TestCaptureDelegate capture(nil);
capture.Acquire();
EXPECT_TRUE(capture.IsActive());
{
- TestCaptureDelegate capture2;
+ TestCaptureDelegate capture2(nil);
EXPECT_EQ(0, capture.capture_lost_count());
// A second capture steals from the first.
@@ -110,7 +113,7 @@ TEST_F(CocoaMouseCaptureTest, CaptureEvents) {
EXPECT_EQ(1, [view mouseDownCount]);
{
- TestCaptureDelegate capture;
+ TestCaptureDelegate capture(test_window());
capture.Acquire();
// Now check that the capture captures events.
« no previous file with comments | « ui/views/cocoa/cocoa_mouse_capture_delegate.h ('k') | ui/views/controls/menu/menu_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698