OLD | NEW |
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 Loading... |
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 |
OLD | NEW |