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

Side by Side Diff: ui/events/event_unittest.cc

Issue 1728603002: Fix ui::Event::Clone() for ui::PointerEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « ui/events/event.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH, 795 EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
796 pointer_event_from_touch.pointer_details().pointer_type); 796 pointer_event_from_touch.pointer_details().pointer_type);
797 797
798 ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::Point(0, 0), 798 ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::Point(0, 0),
799 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0); 799 gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0);
800 ui::PointerEvent pointer_event_from_mouse(mouse_event); 800 ui::PointerEvent pointer_event_from_mouse(mouse_event);
801 EXPECT_EQ(mouse_event.pointer_details(), 801 EXPECT_EQ(mouse_event.pointer_details(),
802 pointer_event_from_mouse.pointer_details()); 802 pointer_event_from_mouse.pointer_details());
803 } 803 }
804 804
805 TEST(EventTest, PointerEventClone) {
806 {
807 ui::PointerEvent ptr_event(
808 ui::TouchEvent(ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, 0,
809 ui::EventTimeForNow(), 10.0f, 5.0f, 0.0f, 15.0f));
810 scoped_ptr<ui::Event> clone(ui::Event::Clone(ptr_event));
811 EXPECT_TRUE(clone->IsPointerEvent());
812 ui::PointerEvent* clone_as_ptr = clone->AsPointerEvent();
813
814 EXPECT_EQ(ptr_event.type(), clone_as_ptr->type());
815 EXPECT_EQ(ptr_event.pointer_id(), clone_as_ptr->pointer_id());
816 EXPECT_EQ(ptr_event.pointer_details(), clone_as_ptr->pointer_details());
817 EXPECT_EQ(ptr_event.location(), clone_as_ptr->location());
818 EXPECT_EQ(ptr_event.root_location(), clone_as_ptr->root_location());
819 }
820
821 {
822 ui::PointerEvent ptr_event(
823 ui::MouseEvent(ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0),
824 ui::EventTimeForNow(), 0, 0));
825 scoped_ptr<ui::Event> clone(ui::Event::Clone(ptr_event));
826 EXPECT_TRUE(clone->IsPointerEvent());
827 ui::PointerEvent* clone_as_ptr = clone->AsPointerEvent();
828
829 EXPECT_EQ(ptr_event.type(), clone_as_ptr->type());
830 EXPECT_EQ(ptr_event.pointer_id(), clone_as_ptr->pointer_id());
831 EXPECT_EQ(ptr_event.pointer_details(), clone_as_ptr->pointer_details());
832 EXPECT_EQ(ptr_event.location(), clone_as_ptr->location());
833 EXPECT_EQ(ptr_event.root_location(), clone_as_ptr->root_location());
834 }
835 }
836
805 } // namespace ui 837 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698