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

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

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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
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"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 widget.SetContentsView(content); 181 widget.SetContentsView(content);
182 content->AddChildView(child); 182 content->AddChildView(child);
183 child->AddChildView(grandchild); 183 child->AddChildView(grandchild);
184 184
185 internal::RootView* root_view = 185 internal::RootView* root_view =
186 static_cast<internal::RootView*>(widget.GetRootView()); 186 static_cast<internal::RootView*>(widget.GetRootView());
187 ui::EventTargeter* targeter = root_view->targeter(); 187 ui::EventTargeter* targeter = root_view->targeter();
188 188
189 // The event falls within the bounds of |child| and |content| but not 189 // The event falls within the bounds of |child| and |content| but not
190 // |grandchild|, so |child| should be the initial target for the event. 190 // |grandchild|, so |child| should be the initial target for the event.
191 ui::ScrollEvent scroll(ui::ET_SCROLL, 191 ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::PointF(60.f, 60.f),
192 gfx::Point(60, 60), 192 ui::EventTimeForNow(), 0, 0, 3, 0, 3, 2);
193 ui::EventTimeForNow(),
194 0,
195 0, 3,
196 0, 3,
197 2);
198 ui::EventTarget* current_target = targeter->FindTargetForEvent(root_view, 193 ui::EventTarget* current_target = targeter->FindTargetForEvent(root_view,
199 &scroll); 194 &scroll);
200 EXPECT_EQ(child, static_cast<View*>(current_target)); 195 EXPECT_EQ(child, static_cast<View*>(current_target));
201 196
202 // Verify that FindNextBestTarget() will return the parent view of the 197 // Verify that FindNextBestTarget() will return the parent view of the
203 // argument (and NULL if the argument has no parent view). 198 // argument (and NULL if the argument has no parent view).
204 current_target = targeter->FindNextBestTarget(child, &scroll); 199 current_target = targeter->FindNextBestTarget(child, &scroll);
205 EXPECT_EQ(content, static_cast<View*>(current_target)); 200 EXPECT_EQ(content, static_cast<View*>(current_target));
206 current_target = targeter->FindNextBestTarget(content, &scroll); 201 current_target = targeter->FindNextBestTarget(content, &scroll);
207 EXPECT_EQ(widget.GetRootView(), static_cast<View*>(current_target)); 202 EXPECT_EQ(widget.GetRootView(), static_cast<View*>(current_target));
208 current_target = targeter->FindNextBestTarget(widget.GetRootView(), 203 current_target = targeter->FindNextBestTarget(widget.GetRootView(),
209 &scroll); 204 &scroll);
210 EXPECT_EQ(NULL, static_cast<View*>(current_target)); 205 EXPECT_EQ(NULL, static_cast<View*>(current_target));
211 206
212 // The event falls outside of the original specified bounds of |content|, 207 // The event falls outside of the original specified bounds of |content|,
213 // |child|, and |grandchild|. But since |content| is the contents view, 208 // |child|, and |grandchild|. But since |content| is the contents view,
214 // and contents views are resized to fill the entire area of the root 209 // and contents views are resized to fill the entire area of the root
215 // view, the event's initial target should still be |content|. 210 // view, the event's initial target should still be |content|.
216 scroll = ui::ScrollEvent(ui::ET_SCROLL, 211 scroll = ui::ScrollEvent(ui::ET_SCROLL, gfx::PointF(150.f, 150.f),
217 gfx::Point(150, 150), 212 ui::EventTimeForNow(), 0, 0, 3, 0, 3, 2);
218 ui::EventTimeForNow(),
219 0,
220 0, 3,
221 0, 3,
222 2);
223 current_target = targeter->FindTargetForEvent(root_view, &scroll); 213 current_target = targeter->FindTargetForEvent(root_view, &scroll);
224 EXPECT_EQ(content, static_cast<View*>(current_target)); 214 EXPECT_EQ(content, static_cast<View*>(current_target));
225 } 215 }
226 216
227 // Convenience to make constructing a GestureEvent simpler. 217 // Convenience to make constructing a GestureEvent simpler.
228 class GestureEventForTest : public ui::GestureEvent { 218 class GestureEventForTest : public ui::GestureEvent {
229 public: 219 public:
230 GestureEventForTest(ui::EventType type, int x, int y) 220 GestureEventForTest(ui::EventType type, int x, int y)
231 : GestureEvent(x, 221 : GestureEvent(x,
232 y, 222 y,
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin)); 653 EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin));
664 EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin)); 654 EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin));
665 655
666 EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin)); 656 EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin));
667 657
668 widget->CloseNow(); 658 widget->CloseNow();
669 } 659 }
670 660
671 } // namespace test 661 } // namespace test
672 } // namespace views 662 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698