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

Side by Side Diff: ui/aura/gestures/gesture_recognizer_unittest.cc

Issue 10834283: gesture recognizer: Some cleanup and workaround for a crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 | « no previous file | ui/base/gestures/gesture_recognizer_impl.cc » ('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 "base/memory/scoped_vector.h" 5 #include "base/memory/scoped_vector.h"
6 #include "base/string_number_conversions.h" 6 #include "base/string_number_conversions.h"
7 #include "base/timer.h" 7 #include "base/timer.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/aura/root_window.h" 9 #include "ui/aura/root_window.h"
10 #include "ui/aura/test/aura_test_base.h" 10 #include "ui/aura/test/aura_test_base.h"
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); 1871 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&release);
1872 1872
1873 delegate->Reset(); 1873 delegate->Reset();
1874 delegate->ReceivedAck(); 1874 delegate->ReceivedAck();
1875 EXPECT_TRUE(delegate->tap_down()); 1875 EXPECT_TRUE(delegate->tap_down());
1876 delegate->Reset(); 1876 delegate->Reset();
1877 delegate->ReceivedAckPreventDefaulted(); 1877 delegate->ReceivedAckPreventDefaulted();
1878 EXPECT_FALSE(delegate->tap()); 1878 EXPECT_FALSE(delegate->tap());
1879 } 1879 }
1880 1880
1881 TEST_F(GestureRecognizerTest, CaptureSendsTapUp) { 1881 TEST_F(GestureRecognizerTest, CaptureSendsGestureEnd) {
1882 scoped_ptr<GestureEventConsumeDelegate> delegate( 1882 scoped_ptr<GestureEventConsumeDelegate> delegate(
1883 new GestureEventConsumeDelegate()); 1883 new GestureEventConsumeDelegate());
1884 TestGestureRecognizer* gesture_recognizer = 1884 TestGestureRecognizer* gesture_recognizer =
1885 new TestGestureRecognizer(root_window()); 1885 new TestGestureRecognizer(root_window());
1886 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 1886 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
1887 1887
1888 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1888 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1889 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), NULL)); 1889 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), NULL));
1890 EventGenerator generator(root_window()); 1890 EventGenerator generator(root_window());
1891 1891
1892 generator.MoveMouseRelativeTo(window.get(), gfx::Point(10, 10)); 1892 generator.MoveMouseRelativeTo(window.get(), gfx::Point(10, 10));
1893 generator.PressTouch(); 1893 generator.PressTouch();
1894 RunAllPendingInMessageLoop(); 1894 RunAllPendingInMessageLoop();
1895 1895
1896 EXPECT_TRUE(delegate->tap_down()); 1896 EXPECT_TRUE(delegate->tap_down());
1897 1897
1898 scoped_ptr<aura::Window> capture(CreateTestWindowWithBounds( 1898 scoped_ptr<aura::Window> capture(CreateTestWindowWithBounds(
1899 gfx::Rect(10, 10, 200, 200), NULL)); 1899 gfx::Rect(10, 10, 200, 200), NULL));
1900 capture->SetCapture(); 1900 capture->SetCapture();
1901 RunAllPendingInMessageLoop(); 1901 RunAllPendingInMessageLoop();
1902 1902
1903 EXPECT_TRUE(delegate->end()); 1903 EXPECT_TRUE(delegate->end());
1904 } 1904 }
1905 1905
1906 TEST_F(GestureRecognizerTest, PressDoesNotCrash) {
1907 scoped_ptr<GestureEventConsumeDelegate> delegate(
1908 new GestureEventConsumeDelegate());
1909 TestGestureRecognizer* gesture_recognizer =
1910 new TestGestureRecognizer(root_window());
1911 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
1912
1913 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1914 delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), NULL));
1915
1916 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), 7, GetTime());
1917 press.set_radius_x(40);
1918 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1919 EXPECT_TRUE(delegate->tap_down());
1920 EXPECT_EQ(gfx::Rect(5, 5, 80, 80).ToString(),
1921 delegate->bounding_box().ToString());
1922 delegate->Reset();
1923
1924 ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), 7, GetTime());
1925 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press2);
1926
1927 // This new press should not generate a tap-down.
1928 EXPECT_FALSE(delegate->begin());
1929 EXPECT_FALSE(delegate->tap_down());
1930 EXPECT_FALSE(delegate->scroll_begin());
1931 }
1932
1906 TEST_F(GestureRecognizerTest, TwoFingerTap) { 1933 TEST_F(GestureRecognizerTest, TwoFingerTap) {
1907 scoped_ptr<GestureEventConsumeDelegate> delegate( 1934 scoped_ptr<GestureEventConsumeDelegate> delegate(
1908 new GestureEventConsumeDelegate()); 1935 new GestureEventConsumeDelegate());
1909 const int kWindowWidth = 123; 1936 const int kWindowWidth = 123;
1910 const int kWindowHeight = 45; 1937 const int kWindowHeight = 45;
1911 const int kTouchId1 = 2; 1938 const int kTouchId1 = 2;
1912 const int kTouchId2 = 3; 1939 const int kTouchId2 = 3;
1913 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); 1940 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
1914 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 1941 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
1915 delegate.get(), -1234, bounds, NULL)); 1942 delegate.get(), -1234, bounds, NULL));
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
2570 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 2597 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2);
2571 EXPECT_FALSE(delegate->tap()); 2598 EXPECT_FALSE(delegate->tap());
2572 EXPECT_FALSE(delegate->scroll_update()); 2599 EXPECT_FALSE(delegate->scroll_update());
2573 EXPECT_FALSE(delegate->pinch_update()); 2600 EXPECT_FALSE(delegate->pinch_update());
2574 2601
2575 delegate->Reset(); 2602 delegate->Reset();
2576 } 2603 }
2577 2604
2578 } // namespace test 2605 } // namespace test
2579 } // namespace aura 2606 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/base/gestures/gesture_recognizer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698