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

Side by Side Diff: device/sensors/sensor_manager_android_unittest.cc

Issue 2845763002: Remove DeviceLightEvent implementation (Closed)
Patch Set: same as previous patch Created 3 years, 7 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
« no previous file with comments | « device/sensors/sensor_manager_android.cc ('k') | services/device/device_service.h » ('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 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 "device/sensors/sensor_manager_android.h" 5 #include "device/sensors/sensor_manager_android.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 26 matching lines...) Expand all
37 bool Start(ConsumerType event_type) override { return true; } 37 bool Start(ConsumerType event_type) override { return true; }
38 void Stop(ConsumerType event_type) override {} 38 void Stop(ConsumerType event_type) override {}
39 39
40 private: 40 private:
41 int number_active_sensors_; 41 int number_active_sensors_;
42 }; 42 };
43 43
44 class AndroidSensorManagerTest : public testing::Test { 44 class AndroidSensorManagerTest : public testing::Test {
45 protected: 45 protected:
46 AndroidSensorManagerTest() { 46 AndroidSensorManagerTest() {
47 light_buffer_.reset(new DeviceLightHardwareBuffer);
48 motion_buffer_.reset(new DeviceMotionHardwareBuffer); 47 motion_buffer_.reset(new DeviceMotionHardwareBuffer);
49 orientation_buffer_.reset(new DeviceOrientationHardwareBuffer); 48 orientation_buffer_.reset(new DeviceOrientationHardwareBuffer);
50 orientation_absolute_buffer_.reset(new DeviceOrientationHardwareBuffer); 49 orientation_absolute_buffer_.reset(new DeviceOrientationHardwareBuffer);
51 } 50 }
52 51
53 void VerifyOrientationBufferValues( 52 void VerifyOrientationBufferValues(
54 const DeviceOrientationHardwareBuffer* buffer, 53 const DeviceOrientationHardwareBuffer* buffer,
55 double alpha, 54 double alpha,
56 double beta, 55 double beta,
57 double gamma) { 56 double gamma) {
58 ASSERT_TRUE(buffer->data.all_available_sensors_are_active); 57 ASSERT_TRUE(buffer->data.all_available_sensors_are_active);
59 ASSERT_EQ(alpha, buffer->data.alpha); 58 ASSERT_EQ(alpha, buffer->data.alpha);
60 ASSERT_TRUE(buffer->data.has_alpha); 59 ASSERT_TRUE(buffer->data.has_alpha);
61 ASSERT_EQ(beta, buffer->data.beta); 60 ASSERT_EQ(beta, buffer->data.beta);
62 ASSERT_TRUE(buffer->data.has_beta); 61 ASSERT_TRUE(buffer->data.has_beta);
63 ASSERT_EQ(gamma, buffer->data.gamma); 62 ASSERT_EQ(gamma, buffer->data.gamma);
64 ASSERT_TRUE(buffer->data.has_gamma); 63 ASSERT_TRUE(buffer->data.has_gamma);
65 } 64 }
66 65
67 std::unique_ptr<DeviceLightHardwareBuffer> light_buffer_;
68 std::unique_ptr<DeviceMotionHardwareBuffer> motion_buffer_; 66 std::unique_ptr<DeviceMotionHardwareBuffer> motion_buffer_;
69 std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_; 67 std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_;
70 std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_absolute_buffer_; 68 std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_absolute_buffer_;
71 base::MessageLoop message_loop_; 69 base::MessageLoop message_loop_;
72 }; 70 };
73 71
74 TEST_F(AndroidSensorManagerTest, ThreeDeviceMotionSensorsActive) { 72 TEST_F(AndroidSensorManagerTest, ThreeDeviceMotionSensorsActive) {
75 FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread()); 73 FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread());
76 FakeSensorManagerAndroid sensorManager; 74 FakeSensorManagerAndroid sensorManager;
77 sensorManager.SetNumberActiveDeviceMotionSensors(3); 75 sensorManager.SetNumberActiveDeviceMotionSensors(3);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 orientation_absolute_buffer_.get()); 166 orientation_absolute_buffer_.get());
169 ASSERT_FALSE(orientation_buffer_->data.all_available_sensors_are_active); 167 ASSERT_FALSE(orientation_buffer_->data.all_available_sensors_are_active);
170 168
171 sensorManager.GotOrientationAbsolute(nullptr, nullptr, 4, 5, 6); 169 sensorManager.GotOrientationAbsolute(nullptr, nullptr, 4, 5, 6);
172 VerifyOrientationBufferValues(orientation_absolute_buffer_.get(), 4, 5, 6); 170 VerifyOrientationBufferValues(orientation_absolute_buffer_.get(), 4, 5, 6);
173 171
174 sensorManager.StopFetchingDeviceOrientationData(); 172 sensorManager.StopFetchingDeviceOrientationData();
175 ASSERT_FALSE(orientation_buffer_->data.all_available_sensors_are_active); 173 ASSERT_FALSE(orientation_buffer_->data.all_available_sensors_are_active);
176 } 174 }
177 175
178 // DeviceLight
179 TEST_F(AndroidSensorManagerTest, DeviceLightSensorsActive) {
180 FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread());
181 FakeSensorManagerAndroid sensorManager;
182
183 sensorManager.StartFetchingDeviceLightData(light_buffer_.get());
184
185 sensorManager.GotLight(nullptr, nullptr, 100);
186 ASSERT_EQ(100, light_buffer_->data.value);
187
188 sensorManager.StopFetchingDeviceLightData();
189 ASSERT_EQ(-1, light_buffer_->data.value);
190 }
191
192 } // namespace 176 } // namespace
193 177
194 } // namespace device 178 } // namespace device
OLDNEW
« no previous file with comments | « device/sensors/sensor_manager_android.cc ('k') | services/device/device_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698