OLD | NEW |
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 "content/browser/device_sensors/sensor_manager_android.h" | 5 #include "content/browser/device_sensors/sensor_manager_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "content/browser/device_sensors/inertial_sensor_consts.h" | 10 #include "content/browser/device_sensors/inertial_sensor_consts.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class FakeSensorManagerAndroid : public SensorManagerAndroid { | 17 class FakeSensorManagerAndroid : public SensorManagerAndroid { |
18 public: | 18 public: |
19 FakeSensorManagerAndroid() { } | 19 FakeSensorManagerAndroid() { } |
20 virtual ~FakeSensorManagerAndroid() { } | 20 virtual ~FakeSensorManagerAndroid() { } |
21 | 21 |
22 virtual int GetNumberActiveDeviceMotionSensors() OVERRIDE { | 22 virtual int GetNumberActiveDeviceMotionSensors() override { |
23 return number_active_sensors_; | 23 return number_active_sensors_; |
24 } | 24 } |
25 | 25 |
26 void SetNumberActiveDeviceMotionSensors(int number_active_sensors) { | 26 void SetNumberActiveDeviceMotionSensors(int number_active_sensors) { |
27 number_active_sensors_ = number_active_sensors; | 27 number_active_sensors_ = number_active_sensors; |
28 } | 28 } |
29 | 29 |
30 protected: | 30 protected: |
31 virtual bool Start(EventType event_type) OVERRIDE { | 31 virtual bool Start(EventType event_type) override { |
32 return true; | 32 return true; |
33 } | 33 } |
34 | 34 |
35 virtual void Stop(EventType event_type) OVERRIDE { | 35 virtual void Stop(EventType event_type) override { |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
39 int number_active_sensors_; | 39 int number_active_sensors_; |
40 }; | 40 }; |
41 | 41 |
42 class AndroidSensorManagerTest : public testing::Test { | 42 class AndroidSensorManagerTest : public testing::Test { |
43 protected: | 43 protected: |
44 AndroidSensorManagerTest() { | 44 AndroidSensorManagerTest() { |
45 light_buffer_.reset(new DeviceLightHardwareBuffer); | 45 light_buffer_.reset(new DeviceLightHardwareBuffer); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 sensorManager.GotLight(0, 0, 100); | 157 sensorManager.GotLight(0, 0, 100); |
158 ASSERT_EQ(100, light_buffer_->data.value); | 158 ASSERT_EQ(100, light_buffer_->data.value); |
159 | 159 |
160 sensorManager.StopFetchingDeviceLightData(); | 160 sensorManager.StopFetchingDeviceLightData(); |
161 ASSERT_EQ(-1, light_buffer_->data.value); | 161 ASSERT_EQ(-1, light_buffer_->data.value); |
162 } | 162 } |
163 | 163 |
164 } // namespace | 164 } // namespace |
165 | 165 |
166 } // namespace content | 166 } // namespace content |
OLD | NEW |