Jeff Brown | c64f0d4 | 2016-03-09 14:23:23 -0800 | [diff] [blame] | 1 | // Copyright 2016 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 "mojo/ui/associates/mock_hit_tester.h" |
| 6 | |
| 7 | #include "base/bind.h" |
| 8 | |
| 9 | namespace mojo { |
| 10 | namespace ui { |
| 11 | |
| 12 | MockHitTester::MockHitTester() {} |
| 13 | |
| 14 | MockHitTester::~MockHitTester() {} |
| 15 | |
| 16 | void MockHitTester::SetNextResult( |
Jeff Brown | 563af9f | 2016-03-10 08:24:46 -0800 | [diff] [blame] | 17 | mojo::PointFPtr point, |
Jeff Brown | c64f0d4 | 2016-03-09 14:23:23 -0800 | [diff] [blame] | 18 | mojo::gfx::composition::HitTestResultPtr result) { |
| 19 | DCHECK(point); |
| 20 | DCHECK(result); |
| 21 | |
| 22 | point_ = point.Pass(); |
| 23 | result_ = result.Pass(); |
| 24 | } |
| 25 | |
Jeff Brown | 563af9f | 2016-03-10 08:24:46 -0800 | [diff] [blame] | 26 | void MockHitTester::HitTest(mojo::PointFPtr point, |
Jeff Brown | c64f0d4 | 2016-03-09 14:23:23 -0800 | [diff] [blame] | 27 | const HitTestCallback& callback) { |
| 28 | DCHECK(point); |
| 29 | |
| 30 | if (point.Equals(point_)) { |
| 31 | point_.reset(); |
| 32 | callback.Run(result_.Pass()); |
| 33 | } else { |
| 34 | callback.Run(mojo::gfx::composition::HitTestResult::New()); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | } // namespace ui |
| 39 | } // namespace mojo |