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

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

Issue 1843433002: mash: Fix DCHECK when clicking on window close box (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 8 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
« ui/events/event.cc ('K') | « 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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 EXPECT_EQ(21.0f, touch_event.pointer_details().force); 718 EXPECT_EQ(21.0f, touch_event.pointer_details().force);
719 EXPECT_EQ(45.0f, touch_event.pointer_details().tilt_x); 719 EXPECT_EQ(45.0f, touch_event.pointer_details().tilt_x);
720 EXPECT_EQ(-45.0f, touch_event.pointer_details().tilt_y); 720 EXPECT_EQ(-45.0f, touch_event.pointer_details().tilt_y);
721 EXPECT_EQ(5.0f, touch_event.pointer_details().radius_x); 721 EXPECT_EQ(5.0f, touch_event.pointer_details().radius_x);
722 EXPECT_EQ(6.0f, touch_event.pointer_details().radius_y); 722 EXPECT_EQ(6.0f, touch_event.pointer_details().radius_y);
723 723
724 ui::TouchEvent touch_event_copy(touch_event); 724 ui::TouchEvent touch_event_copy(touch_event);
725 EXPECT_EQ(touch_event.pointer_details(), touch_event_copy.pointer_details()); 725 EXPECT_EQ(touch_event.pointer_details(), touch_event_copy.pointer_details());
726 } 726 }
727 727
728 TEST(EventTest, PointerEventCanConvertFrom) {
729 const gfx::Point origin(0, 0);
msw 2016/03/29 17:50:27 nit: use Point default ctor
James Cook 2016/03/29 18:23:27 Done and renamed to 'point' because the location i
730 const base::TimeDelta time;
731
732 // Common mouse events can be converted.
733 const EventType mouse_allowed[] = {
734 ET_MOUSE_PRESSED,
735 ET_MOUSE_DRAGGED,
736 ET_MOUSE_MOVED,
737 ET_MOUSE_ENTERED,
738 ET_MOUSE_EXITED,
739 ET_MOUSE_RELEASED
740 };
741 for (size_t i = 0; i < arraysize(mouse_allowed); i++) {
742 MouseEvent event(mouse_allowed[i], origin, origin, time, 0, 0);
743 EXPECT_TRUE(PointerEvent::CanConvertFrom(event));
744 }
745
746 // Common touch events can be converted.
747 const EventType touch_allowed[] = {
748 ET_TOUCH_PRESSED,
749 ET_TOUCH_MOVED,
750 ET_TOUCH_RELEASED,
751 ET_TOUCH_CANCELLED
752 };
753 for (size_t i = 0; i < arraysize(touch_allowed); i++) {
754 TouchEvent event(touch_allowed[i], origin, 0, time);
755 EXPECT_TRUE(PointerEvent::CanConvertFrom(event));
756 }
757
758 // Capture changes cannot be converted.
759 EXPECT_FALSE(
760 PointerEvent::CanConvertFrom(
761 MouseEvent(ET_MOUSE_CAPTURE_CHANGED, origin, origin, time, 0, 0)));
762
763 // Wheel events cannot be converted.
764 EXPECT_FALSE(
765 PointerEvent::CanConvertFrom(
766 MouseWheelEvent(gfx::Vector2d(0, 0), origin, origin, time, 0, 0)));
msw 2016/03/29 17:50:27 nit: use Vector2d default ctor
James Cook 2016/03/29 18:23:27 Done.
767
768 // Non-mouse non-touch events cannot be converted.
769 EXPECT_FALSE(
770 PointerEvent::CanConvertFrom(
771 KeyEvent(ET_KEY_PRESSED, VKEY_SPACE, EF_NONE)));
772 }
773
728 TEST(EventTest, PointerEventType) { 774 TEST(EventTest, PointerEventType) {
729 const ui::EventType kMouseTypeMap[][2] = { 775 const ui::EventType kMouseTypeMap[][2] = {
730 {ui::ET_MOUSE_PRESSED, ui::ET_POINTER_DOWN}, 776 {ui::ET_MOUSE_PRESSED, ui::ET_POINTER_DOWN},
731 {ui::ET_MOUSE_DRAGGED, ui::ET_POINTER_MOVED}, 777 {ui::ET_MOUSE_DRAGGED, ui::ET_POINTER_MOVED},
732 {ui::ET_MOUSE_MOVED, ui::ET_POINTER_MOVED}, 778 {ui::ET_MOUSE_MOVED, ui::ET_POINTER_MOVED},
733 {ui::ET_MOUSE_ENTERED, ui::ET_POINTER_ENTERED}, 779 {ui::ET_MOUSE_ENTERED, ui::ET_POINTER_ENTERED},
734 {ui::ET_MOUSE_EXITED, ui::ET_POINTER_EXITED}, 780 {ui::ET_MOUSE_EXITED, ui::ET_POINTER_EXITED},
735 {ui::ET_MOUSE_RELEASED, ui::ET_POINTER_UP}, 781 {ui::ET_MOUSE_RELEASED, ui::ET_POINTER_UP},
736 }; 782 };
737 const ui::EventType kTouchTypeMap[][2] = { 783 const ui::EventType kTouchTypeMap[][2] = {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 874
829 EXPECT_EQ(ptr_event.type(), clone_as_ptr->type()); 875 EXPECT_EQ(ptr_event.type(), clone_as_ptr->type());
830 EXPECT_EQ(ptr_event.pointer_id(), clone_as_ptr->pointer_id()); 876 EXPECT_EQ(ptr_event.pointer_id(), clone_as_ptr->pointer_id());
831 EXPECT_EQ(ptr_event.pointer_details(), clone_as_ptr->pointer_details()); 877 EXPECT_EQ(ptr_event.pointer_details(), clone_as_ptr->pointer_details());
832 EXPECT_EQ(ptr_event.location(), clone_as_ptr->location()); 878 EXPECT_EQ(ptr_event.location(), clone_as_ptr->location());
833 EXPECT_EQ(ptr_event.root_location(), clone_as_ptr->root_location()); 879 EXPECT_EQ(ptr_event.root_location(), clone_as_ptr->root_location());
834 } 880 }
835 } 881 }
836 882
837 } // namespace ui 883 } // namespace ui
OLDNEW
« ui/events/event.cc ('K') | « ui/events/event.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698