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

Side by Side Diff: ui/views/view_targeter_unittest.cc

Issue 302653002: Introduce the MicButtonTargeter class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/views/view_targeter.h" 5 #include "ui/views/view_targeter.h"
6 6
7 #include "ui/events/event_targeter.h" 7 #include "ui/events/event_targeter.h"
8 #include "ui/events/event_utils.h" 8 #include "ui/events/event_utils.h"
9 #include "ui/gfx/path.h" 9 #include "ui/gfx/path.h"
10 #include "ui/views/masked_view_targeter.h" 10 #include "ui/views/masked_view_targeter.h"
11 #include "ui/views/test/views_test_base.h" 11 #include "ui/views/test/views_test_base.h"
12 #include "ui/views/widget/root_view.h" 12 #include "ui/views/widget/root_view.h"
13 13
14 namespace views { 14 namespace views {
15 15
16 // A class used to define a triangular-shaped hit test mask on a View. 16 // A class used to define a triangular-shaped hit test mask on a View.
17 class TestMaskedViewTargeter : public MaskedViewTargeter { 17 class TestMaskedViewTargeter : public MaskedViewTargeter {
18 public: 18 public:
19 explicit TestMaskedViewTargeter(View* masked_view) 19 explicit TestMaskedViewTargeter(View* masked_view)
20 : MaskedViewTargeter(masked_view) {} 20 : MaskedViewTargeter(masked_view) {}
21 virtual ~TestMaskedViewTargeter() {} 21 virtual ~TestMaskedViewTargeter() {}
22 22
23 private: 23 private:
24 virtual bool GetHitTestMask(View* view, gfx::Path* mask) const OVERRIDE { 24 virtual bool GetHitTestMask(const View* view,
25 gfx::Path* mask) const OVERRIDE {
25 SkScalar w = SkIntToScalar(view->width()); 26 SkScalar w = SkIntToScalar(view->width());
26 SkScalar h = SkIntToScalar(view->height()); 27 SkScalar h = SkIntToScalar(view->height());
27 28
28 // Create a triangular mask within the bounds of |view|. 29 // Create a triangular mask within the bounds of |view|.
29 mask->moveTo(w / 2, 0); 30 mask->moveTo(w / 2, 0);
30 mask->lineTo(w, h); 31 mask->lineTo(w, h);
31 mask->lineTo(0, h); 32 mask->lineTo(0, h);
32 mask->close(); 33 mask->close();
33 34
34 return true; 35 return true;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 scroll.set_location(gfx::Point(300, 12)); 280 scroll.set_location(gfx::Point(300, 12));
280 current_target = targeter->FindTargetForEvent(root_view, &scroll); 281 current_target = targeter->FindTargetForEvent(root_view, &scroll);
281 EXPECT_EQ(&unmasked_view, static_cast<View*>(current_target)); 282 EXPECT_EQ(&unmasked_view, static_cast<View*>(current_target));
282 283
283 // TODO(tdanderson): We should also test that targeting of masked views 284 // TODO(tdanderson): We should also test that targeting of masked views
284 // works correctly with gestures. See crbug.com/375822. 285 // works correctly with gestures. See crbug.com/375822.
285 } 286 }
286 287
287 } // namespace test 288 } // namespace test
288 } // namespace views 289 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698