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

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

Issue 679233002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl_unittest.cc ('k') | ui/views/view_unittest.cc » ('j') | 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_targeter_delegate.h" 10 #include "ui/views/masked_targeter_delegate.h"
11 #include "ui/views/test/views_test_base.h" 11 #include "ui/views/test/views_test_base.h"
12 #include "ui/views/view_targeter.h" 12 #include "ui/views/view_targeter.h"
13 #include "ui/views/view_targeter_delegate.h" 13 #include "ui/views/view_targeter_delegate.h"
14 #include "ui/views/widget/root_view.h" 14 #include "ui/views/widget/root_view.h"
15 15
16 namespace views { 16 namespace views {
17 17
18 // A derived class of View used for testing purposes. 18 // A derived class of View used for testing purposes.
19 class TestingView : public View, public ViewTargeterDelegate { 19 class TestingView : public View, public ViewTargeterDelegate {
20 public: 20 public:
21 TestingView() : can_process_events_within_subtree_(true) {} 21 TestingView() : can_process_events_within_subtree_(true) {}
22 virtual ~TestingView() {} 22 ~TestingView() override {}
23 23
24 // Reset all test state. 24 // Reset all test state.
25 void Reset() { can_process_events_within_subtree_ = true; } 25 void Reset() { can_process_events_within_subtree_ = true; }
26 26
27 void set_can_process_events_within_subtree(bool can_process) { 27 void set_can_process_events_within_subtree(bool can_process) {
28 can_process_events_within_subtree_ = can_process; 28 can_process_events_within_subtree_ = can_process;
29 } 29 }
30 30
31 // A call-through function to ViewTargeterDelegate::DoesIntersectRect(). 31 // A call-through function to ViewTargeterDelegate::DoesIntersectRect().
32 bool TestDoesIntersectRect(const View* target, const gfx::Rect& rect) const { 32 bool TestDoesIntersectRect(const View* target, const gfx::Rect& rect) const {
33 return DoesIntersectRect(target, rect); 33 return DoesIntersectRect(target, rect);
34 } 34 }
35 35
36 // View: 36 // View:
37 virtual bool CanProcessEventsWithinSubtree() const override { 37 bool CanProcessEventsWithinSubtree() const override {
38 return can_process_events_within_subtree_; 38 return can_process_events_within_subtree_;
39 } 39 }
40 40
41 private: 41 private:
42 // Value to return from CanProcessEventsWithinSubtree(). 42 // Value to return from CanProcessEventsWithinSubtree().
43 bool can_process_events_within_subtree_; 43 bool can_process_events_within_subtree_;
44 44
45 DISALLOW_COPY_AND_ASSIGN(TestingView); 45 DISALLOW_COPY_AND_ASSIGN(TestingView);
46 }; 46 };
47 47
48 // A derived class of View having a triangular-shaped hit test mask. 48 // A derived class of View having a triangular-shaped hit test mask.
49 class TestMaskedView : public View, public MaskedTargeterDelegate { 49 class TestMaskedView : public View, public MaskedTargeterDelegate {
50 public: 50 public:
51 TestMaskedView() {} 51 TestMaskedView() {}
52 virtual ~TestMaskedView() {} 52 ~TestMaskedView() override {}
53 53
54 // A call-through function to MaskedTargeterDelegate::DoesIntersectRect(). 54 // A call-through function to MaskedTargeterDelegate::DoesIntersectRect().
55 bool TestDoesIntersectRect(const View* target, const gfx::Rect& rect) const { 55 bool TestDoesIntersectRect(const View* target, const gfx::Rect& rect) const {
56 return DoesIntersectRect(target, rect); 56 return DoesIntersectRect(target, rect);
57 } 57 }
58 58
59 private: 59 private:
60 // MaskedTargeterDelegate: 60 // MaskedTargeterDelegate:
61 virtual bool GetHitTestMask(gfx::Path* mask) const override { 61 bool GetHitTestMask(gfx::Path* mask) const override {
62 DCHECK(mask); 62 DCHECK(mask);
63 SkScalar w = SkIntToScalar(width()); 63 SkScalar w = SkIntToScalar(width());
64 SkScalar h = SkIntToScalar(height()); 64 SkScalar h = SkIntToScalar(height());
65 65
66 // Create a triangular mask within the bounds of this View. 66 // Create a triangular mask within the bounds of this View.
67 mask->moveTo(w / 2, 0); 67 mask->moveTo(w / 2, 0);
68 mask->lineTo(w, h); 68 mask->lineTo(w, h);
69 mask->lineTo(0, h); 69 mask->lineTo(0, h);
70 mask->close(); 70 mask->close();
71 return true; 71 return true;
72 } 72 }
73 73
74 DISALLOW_COPY_AND_ASSIGN(TestMaskedView); 74 DISALLOW_COPY_AND_ASSIGN(TestMaskedView);
75 }; 75 };
76 76
77 namespace test { 77 namespace test {
78 78
79 // TODO(tdanderson): Clean up this test suite by moving common code/state into 79 // TODO(tdanderson): Clean up this test suite by moving common code/state into
80 // ViewTargeterTest and overriding SetUp(), TearDown(), etc. 80 // ViewTargeterTest and overriding SetUp(), TearDown(), etc.
81 // See crbug.com/355680. 81 // See crbug.com/355680.
82 class ViewTargeterTest : public ViewsTestBase { 82 class ViewTargeterTest : public ViewsTestBase {
83 public: 83 public:
84 ViewTargeterTest() {} 84 ViewTargeterTest() {}
85 virtual ~ViewTargeterTest() {} 85 ~ViewTargeterTest() override {}
86 86
87 void SetGestureHandler(internal::RootView* root_view, View* handler) { 87 void SetGestureHandler(internal::RootView* root_view, View* handler) {
88 root_view->gesture_handler_ = handler; 88 root_view->gesture_handler_ = handler;
89 } 89 }
90 90
91 void SetGestureHandlerSetBeforeProcessing(internal::RootView* root_view, 91 void SetGestureHandlerSetBeforeProcessing(internal::RootView* root_view,
92 bool set) { 92 bool set) {
93 root_view->gesture_handler_set_before_processing_ = set; 93 root_view->gesture_handler_set_before_processing_ = set;
94 } 94 }
95 95
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin)); 664 EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin));
665 EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin)); 665 EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin));
666 666
667 EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin)); 667 EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin));
668 668
669 widget->CloseNow(); 669 widget->CloseNow();
670 } 670 }
671 671
672 } // namespace test 672 } // namespace test
673 } // namespace views 673 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl_unittest.cc ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698