OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_orientation/data_fetcher_impl_android.h" | 5 #include "content/browser/device_orientation/data_fetcher_impl_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_orientation/inertial_sensor_consts.h" | 10 #include "content/browser/device_orientation/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 FakeDataFetcherImplAndroid : public DataFetcherImplAndroid { | 17 class FakeDataFetcherImplAndroid : public DataFetcherImplAndroid { |
18 public: | 18 public: |
19 FakeDataFetcherImplAndroid() { } | 19 FakeDataFetcherImplAndroid() { } |
20 virtual ~FakeDataFetcherImplAndroid() { } | 20 virtual ~FakeDataFetcherImplAndroid() { } |
21 | 21 |
22 virtual bool Start(DeviceData::Type event_type) OVERRIDE { | |
23 return true; | |
24 } | |
25 | |
26 virtual void Stop(DeviceData::Type event_type) OVERRIDE { | |
27 } | |
28 | |
29 virtual int GetNumberActiveDeviceMotionSensors() OVERRIDE { | 22 virtual int GetNumberActiveDeviceMotionSensors() OVERRIDE { |
30 return number_active_sensors_; | 23 return number_active_sensors_; |
31 } | 24 } |
32 | 25 |
33 void SetNumberActiveDeviceMotionSensors(int number_active_sensors) { | 26 void SetNumberActiveDeviceMotionSensors(int number_active_sensors) { |
34 number_active_sensors_ = number_active_sensors; | 27 number_active_sensors_ = number_active_sensors; |
35 } | 28 } |
36 | 29 |
| 30 protected: |
| 31 virtual bool Start(EventType event_type) OVERRIDE { |
| 32 return true; |
| 33 } |
| 34 |
| 35 virtual void Stop(EventType event_type) OVERRIDE { |
| 36 } |
| 37 |
37 private: | 38 private: |
38 int number_active_sensors_; | 39 int number_active_sensors_; |
39 }; | 40 }; |
40 | 41 |
41 class AndroidDataFetcherTest : public testing::Test { | 42 class AndroidDataFetcherTest : public testing::Test { |
42 protected: | 43 protected: |
43 AndroidDataFetcherTest() { | 44 AndroidDataFetcherTest() { |
44 motion_buffer_.reset(new DeviceMotionHardwareBuffer); | 45 motion_buffer_.reset(new DeviceMotionHardwareBuffer); |
45 orientation_buffer_.reset(new DeviceOrientationHardwareBuffer); | 46 orientation_buffer_.reset(new DeviceOrientationHardwareBuffer); |
46 } | 47 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 ASSERT_TRUE(orientation_buffer_->data.hasGamma); | 139 ASSERT_TRUE(orientation_buffer_->data.hasGamma); |
139 | 140 |
140 fetcher.StopFetchingDeviceOrientationData(); | 141 fetcher.StopFetchingDeviceOrientationData(); |
141 ASSERT_FALSE(orientation_buffer_->data.allAvailableSensorsAreActive); | 142 ASSERT_FALSE(orientation_buffer_->data.allAvailableSensorsAreActive); |
142 } | 143 } |
143 | 144 |
144 | 145 |
145 } // namespace | 146 } // namespace |
146 | 147 |
147 } // namespace content | 148 } // namespace content |
OLD | NEW |