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

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

Issue 853073002: Update {virtual,override,final} to follow C++11 style in ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 "base/test/simple_test_tick_clock.h" 7 #include "base/test/simple_test_tick_clock.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "ui/aura/client/cursor_client.h" 9 #include "ui/aura/client/cursor_client.h"
10 #include "ui/aura/test/aura_test_base.h" 10 #include "ui/aura/test/aura_test_base.h"
11 #include "ui/aura/test/test_cursor_client.h" 11 #include "ui/aura/test/test_cursor_client.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/events/event.h" 13 #include "ui/events/event.h"
14 #include "ui/events/event_utils.h" 14 #include "ui/events/event_utils.h"
15 #include "ui/events/gestures/gesture_provider_aura.h" 15 #include "ui/events/gestures/gesture_provider_aura.h"
16 #include "ui/events/test/event_generator.h" 16 #include "ui/events/test/event_generator.h"
17 #include "ui/events/test/events_test_utils.h" 17 #include "ui/events/test/events_test_utils.h"
18 #include "ui/gfx/geometry/point.h" 18 #include "ui/gfx/geometry/point.h"
19 #include "ui/gl/gl_implementation.h" 19 #include "ui/gl/gl_implementation.h"
20 #include "ui/gl/gl_surface.h" 20 #include "ui/gl/gl_surface.h"
21 21
22 namespace ui { 22 namespace ui {
23 23
24 namespace { 24 namespace {
25 25
26 // Records all mouse, touch, gesture, and key events. 26 // Records all mouse, touch, gesture, and key events.
27 class EventCapturer : public ui::EventHandler { 27 class EventCapturer : public ui::EventHandler {
28 public: 28 public:
29 EventCapturer() {} 29 EventCapturer() {}
30 virtual ~EventCapturer() {} 30 ~EventCapturer() override {}
31 31
32 void Reset() { 32 void Reset() {
33 events_.clear(); 33 events_.clear();
34 } 34 }
35 35
36 virtual void OnEvent(ui::Event* event) override { 36 void OnEvent(ui::Event* event) override {
37 if (event->IsMouseEvent()) { 37 if (event->IsMouseEvent()) {
38 events_.push_back( 38 events_.push_back(
39 new ui::MouseEvent(static_cast<ui::MouseEvent&>(*event))); 39 new ui::MouseEvent(static_cast<ui::MouseEvent&>(*event)));
40 } else if (event->IsTouchEvent()) { 40 } else if (event->IsTouchEvent()) {
41 events_.push_back( 41 events_.push_back(
42 new ui::TouchEvent(static_cast<ui::TouchEvent&>(*event))); 42 new ui::TouchEvent(static_cast<ui::TouchEvent&>(*event)));
43 } else if (event->IsGestureEvent()) { 43 } else if (event->IsGestureEvent()) {
44 events_.push_back( 44 events_.push_back(
45 new ui::GestureEvent(static_cast<ui::GestureEvent&>(*event))); 45 new ui::GestureEvent(static_cast<ui::GestureEvent&>(*event)));
46 } else if (event->IsKeyEvent()) { 46 } else if (event->IsKeyEvent()) {
(...skipping 21 matching lines...) Expand all
68 if (n <= 0) 68 if (n <= 0)
69 return 0; 69 return 0;
70 if (n == 1) 70 if (n == 1)
71 return 1; 71 return 1;
72 return n * Factorial(n - 1); 72 return n * Factorial(n - 1);
73 } 73 }
74 74
75 class MockTouchExplorationControllerDelegate 75 class MockTouchExplorationControllerDelegate
76 : public ui::TouchExplorationControllerDelegate { 76 : public ui::TouchExplorationControllerDelegate {
77 public: 77 public:
78 virtual void SetOutputLevel(int volume) override { 78 void SetOutputLevel(int volume) override {
79 volume_changes_.push_back(volume); 79 volume_changes_.push_back(volume);
80 } 80 }
81 virtual void SilenceSpokenFeedback() override { 81 void SilenceSpokenFeedback() override {}
82 } 82 void PlayVolumeAdjustEarcon() override { ++num_times_adjust_sound_played_; }
83 virtual void PlayVolumeAdjustEarcon() override { 83 void PlayPassthroughEarcon() override { ++num_times_passthrough_played_; }
84 ++num_times_adjust_sound_played_; 84 void PlayExitScreenEarcon() override { ++num_times_exit_screen_played_; }
85 } 85 void PlayEnterScreenEarcon() override { ++num_times_enter_screen_played_; }
86 virtual void PlayPassthroughEarcon() override {
87 ++num_times_passthrough_played_;
88 }
89 virtual void PlayExitScreenEarcon() override {
90 ++num_times_exit_screen_played_;
91 }
92 virtual void PlayEnterScreenEarcon() override {
93 ++num_times_enter_screen_played_;
94 }
95 86
96 const std::vector<float> VolumeChanges() { return volume_changes_; } 87 const std::vector<float> VolumeChanges() { return volume_changes_; }
97 size_t NumAdjustSounds() { return num_times_adjust_sound_played_; } 88 size_t NumAdjustSounds() { return num_times_adjust_sound_played_; }
98 size_t NumPassthroughSounds() { return num_times_passthrough_played_; } 89 size_t NumPassthroughSounds() { return num_times_passthrough_played_; }
99 size_t NumExitScreenSounds() { return num_times_exit_screen_played_; } 90 size_t NumExitScreenSounds() { return num_times_exit_screen_played_; }
100 size_t NumEnterScreenSounds() { 91 size_t NumEnterScreenSounds() {
101 return num_times_enter_screen_played_; 92 return num_times_enter_screen_played_;
102 } 93 }
103 94
104 void ResetCountersToZero() { 95 void ResetCountersToZero() {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 186
196 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi); 187 DISALLOW_COPY_AND_ASSIGN(TouchExplorationControllerTestApi);
197 }; 188 };
198 189
199 class TouchExplorationTest : public aura::test::AuraTestBase { 190 class TouchExplorationTest : public aura::test::AuraTestBase {
200 public: 191 public:
201 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) { 192 TouchExplorationTest() : simulated_clock_(new base::SimpleTestTickClock()) {
202 // Tests fail if time is ever 0. 193 // Tests fail if time is ever 0.
203 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); 194 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10));
204 } 195 }
205 virtual ~TouchExplorationTest() {} 196 ~TouchExplorationTest() override {}
206 197
207 virtual void SetUp() override { 198 void SetUp() override {
208 if (gfx::GetGLImplementation() == gfx::kGLImplementationNone) 199 if (gfx::GetGLImplementation() == gfx::kGLImplementationNone)
209 gfx::GLSurface::InitializeOneOffForTests(); 200 gfx::GLSurface::InitializeOneOffForTests();
210 aura::test::AuraTestBase::SetUp(); 201 aura::test::AuraTestBase::SetUp();
211 cursor_client_.reset(new aura::test::TestCursorClient(root_window())); 202 cursor_client_.reset(new aura::test::TestCursorClient(root_window()));
212 root_window()->AddPreTargetHandler(&event_capturer_); 203 root_window()->AddPreTargetHandler(&event_capturer_);
213 generator_.reset(new test::EventGenerator(root_window())); 204 generator_.reset(new test::EventGenerator(root_window()));
214 // The generator takes ownership of the tick clock. 205 // The generator takes ownership of the tick clock.
215 generator_->SetTickClock(scoped_ptr<base::TickClock>(simulated_clock_)); 206 generator_->SetTickClock(scoped_ptr<base::TickClock>(simulated_clock_));
216 cursor_client()->ShowCursor(); 207 cursor_client()->ShowCursor();
217 cursor_client()->DisableMouseEvents(); 208 cursor_client()->DisableMouseEvents();
218 } 209 }
219 210
220 virtual void TearDown() override { 211 void TearDown() override {
221 root_window()->RemovePreTargetHandler(&event_capturer_); 212 root_window()->RemovePreTargetHandler(&event_capturer_);
222 SwitchTouchExplorationMode(false); 213 SwitchTouchExplorationMode(false);
223 cursor_client_.reset(); 214 cursor_client_.reset();
224 aura::test::AuraTestBase::TearDown(); 215 aura::test::AuraTestBase::TearDown();
225 } 216 }
226 217
227 protected: 218 protected:
228 aura::client::CursorClient* cursor_client() { return cursor_client_.get(); } 219 aura::client::CursorClient* cursor_client() { return cursor_client_.get(); }
229 220
230 const ScopedVector<ui::Event>& GetCapturedEvents() { 221 const ScopedVector<ui::Event>& GetCapturedEvents() {
(...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 generator_->PressTouch(); 1935 generator_->PressTouch();
1945 generator_->MoveTouch(initial_press); 1936 generator_->MoveTouch(initial_press);
1946 generator_->MoveTouch(*point); 1937 generator_->MoveTouch(*point);
1947 generator_->ReleaseTouch(); 1938 generator_->ReleaseTouch();
1948 ASSERT_EQ(1U, delegate_.NumExitScreenSounds()); 1939 ASSERT_EQ(1U, delegate_.NumExitScreenSounds());
1949 delegate_.ResetCountersToZero(); 1940 delegate_.ResetCountersToZero();
1950 } 1941 }
1951 } 1942 }
1952 1943
1953 } // namespace ui 1944 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/touch_exploration_controller.h ('k') | ui/chromeos/user_activity_power_manager_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698