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

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

Issue 10916095: Fix leaks in aura_unittests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/event_filter_unittest.cc ('k') | ui/aura/root_window_unittest.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 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 1808
1809 ui::GestureConsumer* target; 1809 ui::GestureConsumer* target;
1810 const int kNumWindows = 4; 1810 const int kNumWindows = 4;
1811 1811
1812 scoped_array<GestureEventConsumeDelegate*> delegates( 1812 scoped_array<GestureEventConsumeDelegate*> delegates(
1813 new GestureEventConsumeDelegate*[kNumWindows]); 1813 new GestureEventConsumeDelegate*[kNumWindows]);
1814 1814
1815 ui::GestureConfiguration:: 1815 ui::GestureConfiguration::
1816 set_max_separation_for_gesture_touches_in_pixels(499); 1816 set_max_separation_for_gesture_touches_in_pixels(499);
1817 1817
1818 scoped_array<gfx::Rect*> window_bounds(new gfx::Rect*[kNumWindows]); 1818 scoped_array<gfx::Rect> window_bounds(new gfx::Rect[kNumWindows]);
1819 window_bounds[0] = new gfx::Rect(0, 0, 1, 1); 1819 window_bounds[0] = gfx::Rect(0, 0, 1, 1);
1820 window_bounds[1] = new gfx::Rect(500, 0, 1, 1); 1820 window_bounds[1] = gfx::Rect(500, 0, 1, 1);
1821 window_bounds[2] = new gfx::Rect(0, 500, 1, 1); 1821 window_bounds[2] = gfx::Rect(0, 500, 1, 1);
1822 window_bounds[3] = new gfx::Rect(500, 500, 1, 1); 1822 window_bounds[3] = gfx::Rect(500, 500, 1, 1);
1823 1823
1824 scoped_array<aura::Window*> windows(new aura::Window*[kNumWindows]); 1824 scoped_array<aura::Window*> windows(new aura::Window*[kNumWindows]);
1825 1825
1826 // Instantiate windows with |window_bounds| and touch each window at 1826 // Instantiate windows with |window_bounds| and touch each window at
1827 // its origin. 1827 // its origin.
1828 for (int i = 0; i < kNumWindows; ++i) { 1828 for (int i = 0; i < kNumWindows; ++i) {
1829 delegates[i] = new GestureEventConsumeDelegate(); 1829 delegates[i] = new GestureEventConsumeDelegate();
1830 windows[i] = CreateTestWindowWithDelegate( 1830 windows[i] = CreateTestWindowWithDelegate(
1831 delegates[i], i, *window_bounds[i], NULL); 1831 delegates[i], i, window_bounds[i], NULL);
1832 windows[i]->set_id(i); 1832 windows[i]->set_id(i);
1833 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i]->origin(), 1833 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(),
1834 i, GetTime()); 1834 i, GetTime());
1835 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); 1835 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&press);
1836 } 1836 }
1837 1837
1838 // Touches should now be associated with the closest touch within 1838 // Touches should now be associated with the closest touch within
1839 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels 1839 // ui::GestureConfiguration::max_separation_for_gesture_touches_in_pixels
1840 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11)); 1840 target = gesture_recognizer->GetTargetForLocation(gfx::Point(11, 11));
1841 EXPECT_EQ("0", WindowIDAsString(target)); 1841 EXPECT_EQ("0", WindowIDAsString(target));
1842 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11)); 1842 target = gesture_recognizer->GetTargetForLocation(gfx::Point(511, 11));
1843 EXPECT_EQ("1", WindowIDAsString(target)); 1843 EXPECT_EQ("1", WindowIDAsString(target));
(...skipping 26 matching lines...) Expand all
1870 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000)); 1870 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000));
1871 EXPECT_TRUE(target == NULL); 1871 EXPECT_TRUE(target == NULL);
1872 1872
1873 // Move a touch associated with windows[2] to 1000, 1000 1873 // Move a touch associated with windows[2] to 1000, 1000
1874 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000), 1874 ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000),
1875 kNumWindows, GetTime()); 1875 kNumWindows, GetTime());
1876 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 1876 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2);
1877 1877
1878 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000)); 1878 target = gesture_recognizer->GetTargetForLocation(gfx::Point(1000, 1000));
1879 EXPECT_EQ("2", WindowIDAsString(target)); 1879 EXPECT_EQ("2", WindowIDAsString(target));
1880
1881 for (int i = 0; i < kNumWindows; ++i) {
1882 // Delete windows before deleting delegates.
1883 delete windows[i];
1884 delete delegates[i];
1885 }
1880 } 1886 }
1881 1887
1882 // Check that touch events outside the root window are still handled 1888 // Check that touch events outside the root window are still handled
1883 // by the root window's gesture sequence. 1889 // by the root window's gesture sequence.
1884 TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) { 1890 TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) {
1885 TestGestureRecognizer* gesture_recognizer = 1891 TestGestureRecognizer* gesture_recognizer =
1886 new TestGestureRecognizer(root_window()); 1892 new TestGestureRecognizer(root_window());
1887 root_window()->SetGestureRecognizerForTesting(gesture_recognizer); 1893 root_window()->SetGestureRecognizerForTesting(gesture_recognizer);
1888 1894
1889 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds( 1895 scoped_ptr<aura::Window> window(CreateTestWindowWithBounds(
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
2825 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2); 2831 root_window()->AsRootWindowHostDelegate()->OnHostTouchEvent(&move2);
2826 EXPECT_FALSE(delegate->tap()); 2832 EXPECT_FALSE(delegate->tap());
2827 EXPECT_FALSE(delegate->scroll_update()); 2833 EXPECT_FALSE(delegate->scroll_update());
2828 EXPECT_FALSE(delegate->pinch_update()); 2834 EXPECT_FALSE(delegate->pinch_update());
2829 2835
2830 delegate->Reset(); 2836 delegate->Reset();
2831 } 2837 }
2832 2838
2833 } // namespace test 2839 } // namespace test
2834 } // namespace aura 2840 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/event_filter_unittest.cc ('k') | ui/aura/root_window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698