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

Side by Side Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 2378773011: Only exclude workarea from touch-exploration with active shell-surface (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/touch_exploration_controller.h" 5 #include "ui/chromeos/touch_exploration_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 float GetSlopDistanceFromEdge() const { 175 float GetSlopDistanceFromEdge() const {
176 return touch_exploration_controller_->kSlopDistanceFromEdge; 176 return touch_exploration_controller_->kSlopDistanceFromEdge;
177 } 177 }
178 178
179 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) { 179 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) {
180 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location); 180 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location);
181 } 181 }
182 182
183 void SetExcludeBounds(const gfx::Rect& bounds) {
184 touch_exploration_controller_->SetExcludeBounds(bounds);
185 }
186
183 private: 187 private:
184 std::unique_ptr<TouchExplorationController> touch_exploration_controller_; 188 std::unique_ptr<TouchExplorationController> touch_exploration_controller_;
185 189
186 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi); 190 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi);
187 }; 191 };
188 192
189 class TouchExplorationTest : public aura::test::AuraTestBase { 193 class TouchExplorationTest : public aura::test::AuraTestBase {
190 public: 194 public:
191 TouchExplorationTest() : simulated_clock_(nullptr) {} 195 TouchExplorationTest() : simulated_clock_(nullptr) {}
192 ~TouchExplorationTest() override {} 196 ~TouchExplorationTest() override {}
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 float GetSlopDistanceFromEdge() const { 389 float GetSlopDistanceFromEdge() const {
386 return touch_exploration_controller_->GetSlopDistanceFromEdge(); 390 return touch_exploration_controller_->GetSlopDistanceFromEdge();
387 } 391 }
388 392
389 base::TimeTicks Now() { return ui::EventTimeForNow(); } 393 base::TimeTicks Now() { return ui::EventTimeForNow(); }
390 394
391 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) { 395 void SetTouchAccessibilityAnchorPoint(const gfx::Point& location) {
392 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location); 396 touch_exploration_controller_->SetTouchAccessibilityAnchorPoint(location);
393 } 397 }
394 398
399 void SetExcludeBounds(const gfx::Rect& bounds) {
400 touch_exploration_controller_->SetExcludeBounds(bounds);
401 }
402
395 std::unique_ptr<test::EventGenerator> generator_; 403 std::unique_ptr<test::EventGenerator> generator_;
396 ui::GestureDetector::Config gesture_detector_config_; 404 ui::GestureDetector::Config gesture_detector_config_;
397 // Owned by |ui|. 405 // Owned by |ui|.
398 base::SimpleTestTickClock* simulated_clock_; 406 base::SimpleTestTickClock* simulated_clock_;
399 MockTouchExplorationControllerDelegate delegate_; 407 MockTouchExplorationControllerDelegate delegate_;
400 408
401 private: 409 private:
402 EventCapturer event_capturer_; 410 EventCapturer event_capturer_;
403 std::unique_ptr<TouchExplorationControllerTestApi> 411 std::unique_ptr<TouchExplorationControllerTestApi>
404 touch_exploration_controller_; 412 touch_exploration_controller_;
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1812 ++point) { 1820 ++point) {
1813 generator_->PressTouch(); 1821 generator_->PressTouch();
1814 generator_->MoveTouch(initial_press); 1822 generator_->MoveTouch(initial_press);
1815 generator_->MoveTouch(*point); 1823 generator_->MoveTouch(*point);
1816 generator_->ReleaseTouch(); 1824 generator_->ReleaseTouch();
1817 ASSERT_EQ(1U, delegate_.NumExitScreenSounds()); 1825 ASSERT_EQ(1U, delegate_.NumExitScreenSounds());
1818 delegate_.ResetCountersToZero(); 1826 delegate_.ResetCountersToZero();
1819 } 1827 }
1820 } 1828 }
1821 1829
1830 TEST_F(TouchExplorationTest, ExclusionArea) {
1831 SwitchTouchExplorationMode(true);
1832
1833 gfx::Rect window = BoundsOfRootWindowInDIP();
1834 gfx::Rect exclude = window;
1835 exclude.Inset(0, 0, 0, 30);
1836 SetExcludeBounds(exclude);
1837
1838 gfx::Point in_pt = exclude.CenterPoint();
1839 gfx::Point in_mv_pt(in_pt.x(), (in_pt.y() + exclude.bottom()) / 2);
1840 gfx::Point out_pt(in_pt.x(), exclude.bottom() + 20);
1841 gfx::Point out_mv_pt(in_pt.x(), exclude.bottom() + 10);
1842
1843 // Complete motion in exclusion bounds is passed-through unchanged.
1844 {
1845 generator_->set_current_location(in_pt);
1846 generator_->PressTouchId(0);
1847 AdvanceSimulatedTimePastPotentialTapDelay();
1848 generator_->MoveTouchId(in_mv_pt, 0);
1849 generator_->ReleaseTouchId(0);
1850 EXPECT_TRUE(IsInNoFingersDownState());
1851 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1852 ASSERT_EQ(3U, captured_events.size());
1853 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1854 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[1]->type());
1855 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[2]->type());
1856 ClearCapturedEvents();
1857 }
1858
1859 // Motion starting in exclusion bounds is fully passed-through.
1860 {
1861 generator_->set_current_location(in_pt);
1862 generator_->PressTouchId(0);
1863 AdvanceSimulatedTimePastPotentialTapDelay();
1864 generator_->MoveTouchId(out_mv_pt, 0);
1865 generator_->ReleaseTouchId(0);
1866 EXPECT_TRUE(IsInNoFingersDownState());
1867 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1868 ASSERT_EQ(3U, captured_events.size());
1869 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1870 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[1]->type());
1871 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[2]->type());
1872 ClearCapturedEvents();
1873 }
1874
1875 // Complete motion outside exclusion is rewritten.
1876 {
1877 generator_->set_current_location(out_pt);
1878 generator_->PressTouchId(0);
1879 AdvanceSimulatedTimePastTapDelay();
1880 generator_->MoveTouchId(out_mv_pt, 0);
1881 generator_->ReleaseTouchId(0);
1882 AdvanceSimulatedTimePastTapDelay();
1883 EXPECT_TRUE(IsInNoFingersDownState());
1884 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents();
1885 ASSERT_EQ(3U, captured_events.size());
1886 for (ui::Event* e : captured_events) {
1887 EXPECT_EQ(ui::ET_MOUSE_MOVED, e->type());
1888 }
1889 ClearCapturedEvents();
1890 }
1891
1892 // For a motion starting outside: outside events are rewritten, inside
1893 // events are discarded unless they end the motion.
1894 {
1895 // finger 0 down outside, moves inside.
1896 generator_->set_current_location(out_pt);
1897 generator_->PressTouchId(0);
1898 AdvanceSimulatedTimePastTapDelay();
1899 generator_->MoveTouchId(out_mv_pt, 0);
1900 generator_->MoveTouchId(in_mv_pt, 0);
1901 ASSERT_EQ(2U, GetCapturedEvents().size());
1902 for (ui::Event* e : GetCapturedEvents()) {
1903 EXPECT_EQ(ui::ET_MOUSE_MOVED, e->type());
1904 }
1905 ClearCapturedEvents();
1906
1907 // finger 1 down inside, moves outside
1908 generator_->set_current_location(in_pt);
1909 generator_->PressTouchId(1);
1910 generator_->MoveTouchId(out_mv_pt, 1);
1911 generator_->ReleaseTouchId(1);
1912 ASSERT_EQ(0U, GetCapturedEvents().size());
1913 EXPECT_FALSE(IsInNoFingersDownState());
1914
1915 generator_->ReleaseTouchId(0);
1916 AdvanceSimulatedTimePastTapDelay();
1917 EXPECT_TRUE(IsInNoFingersDownState());
1918
1919 ASSERT_EQ(1U, GetCapturedEvents().size());
1920 EXPECT_EQ(ui::ET_MOUSE_MOVED, GetCapturedEvents()[0]->type());
1921 ClearCapturedEvents();
1922 }
1923 }
1924
1822 } // namespace ui 1925 } // namespace ui
OLDNEW
« ash/ash_touch_exploration_manager_chromeos.cc ('K') | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698