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

Side by Side Diff: ui/aura/window_unittest.cc

Issue 10928066: Add GestureTapCancel gesture type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sky cr feedback Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | ui/base/events/event_constants.h » ('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 (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 "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( 920 scoped_ptr<Window> w2(CreateTestWindowWithDelegate(
921 &d2, 0, gfx::Rect(40, 0, 40, 20), NULL)); 921 &d2, 0, gfx::Rect(40, 0, 40, 20), NULL));
922 ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(41, 10), 1, getTime()); 922 ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(41, 10), 1, getTime());
923 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&p2); 923 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&p2);
924 EXPECT_EQ(0, d1.gesture_event_count()); 924 EXPECT_EQ(0, d1.gesture_event_count());
925 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN for new target window. 925 // We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN for new target window.
926 EXPECT_EQ(2, d2.gesture_event_count()); 926 EXPECT_EQ(2, d2.gesture_event_count());
927 d1.ResetCounts(); 927 d1.ResetCounts();
928 d2.ResetCounts(); 928 d2.ResetCounts();
929 929
930 // Set capture on |w2|, this should send a cancel to |w1| but not |w2|. 930 // Set capture on |w2|, this should send a cancel (TAP_CANCEL, END) to |w1|
931 // but not |w2|.
931 w2->SetCapture(); 932 w2->SetCapture();
932 EXPECT_EQ(1, d1.gesture_event_count()); 933 EXPECT_EQ(2, d1.gesture_event_count());
933 EXPECT_EQ(0, d2.gesture_event_count()); 934 EXPECT_EQ(0, d2.gesture_event_count());
934 d1.ResetCounts(); 935 d1.ResetCounts();
935 d2.ResetCounts(); 936 d2.ResetCounts();
936 937
937 CaptureWindowDelegateImpl d3; 938 CaptureWindowDelegateImpl d3;
938 scoped_ptr<Window> w3(CreateTestWindowWithDelegate( 939 scoped_ptr<Window> w3(CreateTestWindowWithDelegate(
939 &d3, 0, gfx::Rect(0, 0, 100, 101), NULL)); 940 &d3, 0, gfx::Rect(0, 0, 100, 101), NULL));
940 // Set capture on w3. No new events should be received. 941 // Set capture on w3. No new events should be received.
941 w3->SetCapture(); 942 w3->SetCapture();
942 EXPECT_EQ(0, d1.gesture_event_count()); 943 EXPECT_EQ(0, d1.gesture_event_count());
943 EXPECT_EQ(0, d2.gesture_event_count()); 944 EXPECT_EQ(0, d2.gesture_event_count());
944 EXPECT_EQ(0, d3.gesture_event_count()); 945 EXPECT_EQ(0, d3.gesture_event_count());
945 946
946 // Move touch id originally associated with |w2|. Since capture was transfered 947 // Move touch id originally associated with |w2|. Since capture was transfered
947 // from 2 to 3 only |w3| should get the event. 948 // from 2 to 3 only |w3| should get the event.
948 ui::TouchEvent m3(ui::ET_TOUCH_MOVED, gfx::Point(110, 105), 1, getTime()); 949 ui::TouchEvent m3(ui::ET_TOUCH_MOVED, gfx::Point(110, 105), 1, getTime());
949 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&m3); 950 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&m3);
950 EXPECT_EQ(0, d1.gesture_event_count()); 951 EXPECT_EQ(0, d1.gesture_event_count());
951 EXPECT_EQ(0, d2.gesture_event_count()); 952 EXPECT_EQ(0, d2.gesture_event_count());
952 // |w3| gets two events, both scroll related. 953 // |w3| gets a TAP_CANCEL and two scroll related events.
953 EXPECT_EQ(2, d3.gesture_event_count()); 954 EXPECT_EQ(3, d3.gesture_event_count());
954 } 955 }
955 956
956 // Changes capture while capture is already ongoing. 957 // Changes capture while capture is already ongoing.
957 TEST_F(WindowTest, ChangeCaptureWhileMouseDown) { 958 TEST_F(WindowTest, ChangeCaptureWhileMouseDown) {
958 CaptureWindowDelegateImpl delegate; 959 CaptureWindowDelegateImpl delegate;
959 scoped_ptr<Window> window(CreateTestWindowWithDelegate( 960 scoped_ptr<Window> window(CreateTestWindowWithDelegate(
960 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); 961 &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL));
961 CaptureWindowDelegateImpl delegate2; 962 CaptureWindowDelegateImpl delegate2;
962 scoped_ptr<Window> w2(CreateTestWindowWithDelegate( 963 scoped_ptr<Window> w2(CreateTestWindowWithDelegate(
963 &delegate2, 0, gfx::Rect(20, 20, 20, 20), NULL)); 964 &delegate2, 0, gfx::Rect(20, 20, 20, 20), NULL));
(...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after
2537 // Move |w2| to be a child of |w1|. 2538 // Move |w2| to be a child of |w1|.
2538 w1->AddChild(w2.get()); 2539 w1->AddChild(w2.get());
2539 // Sine we moved in the same root, observer shouldn't be notified. 2540 // Sine we moved in the same root, observer shouldn't be notified.
2540 EXPECT_EQ("0 0", observer.CountStringAndReset()); 2541 EXPECT_EQ("0 0", observer.CountStringAndReset());
2541 // |w2| should still have focus after moving. 2542 // |w2| should still have focus after moving.
2542 EXPECT_TRUE(w2->HasFocus()); 2543 EXPECT_TRUE(w2->HasFocus());
2543 } 2544 }
2544 2545
2545 } // namespace test 2546 } // namespace test
2546 } // namespace aura 2547 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | ui/base/events/event_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698