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

Side by Side Diff: content/browser/device_sensors/sensor_manager_android_unittest.cc

Issue 292693004: [DeviceLight] Browser+java part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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 "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"
(...skipping 24 matching lines...) Expand all
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 motion_buffer_.reset(new DeviceMotionHardwareBuffer); 46 motion_buffer_.reset(new DeviceMotionHardwareBuffer);
46 orientation_buffer_.reset(new DeviceOrientationHardwareBuffer); 47 orientation_buffer_.reset(new DeviceOrientationHardwareBuffer);
47 } 48 }
48 49
50 scoped_ptr<DeviceLightHardwareBuffer> light_buffer_;
49 scoped_ptr<DeviceMotionHardwareBuffer> motion_buffer_; 51 scoped_ptr<DeviceMotionHardwareBuffer> motion_buffer_;
50 scoped_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_; 52 scoped_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_;
51 }; 53 };
52 54
53 TEST_F(AndroidSensorManagerTest, ThreeDeviceMotionSensorsActive) { 55 TEST_F(AndroidSensorManagerTest, ThreeDeviceMotionSensorsActive) {
54 FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread()); 56 FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread());
55 FakeSensorManagerAndroid sensorManager; 57 FakeSensorManagerAndroid sensorManager;
56 sensorManager.SetNumberActiveDeviceMotionSensors(3); 58 sensorManager.SetNumberActiveDeviceMotionSensors(3);
57 59
58 sensorManager.StartFetchingDeviceMotionData(motion_buffer_.get()); 60 sensorManager.StartFetchingDeviceMotionData(motion_buffer_.get());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 ASSERT_TRUE(orientation_buffer_->data.hasAlpha); 137 ASSERT_TRUE(orientation_buffer_->data.hasAlpha);
136 ASSERT_EQ(2, orientation_buffer_->data.beta); 138 ASSERT_EQ(2, orientation_buffer_->data.beta);
137 ASSERT_TRUE(orientation_buffer_->data.hasBeta); 139 ASSERT_TRUE(orientation_buffer_->data.hasBeta);
138 ASSERT_EQ(3, orientation_buffer_->data.gamma); 140 ASSERT_EQ(3, orientation_buffer_->data.gamma);
139 ASSERT_TRUE(orientation_buffer_->data.hasGamma); 141 ASSERT_TRUE(orientation_buffer_->data.hasGamma);
140 142
141 sensorManager.StopFetchingDeviceOrientationData(); 143 sensorManager.StopFetchingDeviceOrientationData();
142 ASSERT_FALSE(orientation_buffer_->data.allAvailableSensorsAreActive); 144 ASSERT_FALSE(orientation_buffer_->data.allAvailableSensorsAreActive);
143 } 145 }
144 146
147 // DeviceLight
148 TEST_F(AndroidSensorManagerTest, DeviceLightSensorsActive) {
149 FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread());
150 FakeSensorManagerAndroid sensorManager;
151
152 sensorManager.StartFetchingDeviceLightData(light_buffer_.get());
153
154 sensorManager.GotLight(0, 0, 100);
155 ASSERT_EQ(100, light_buffer_->data.value);
156
157 sensorManager.StopFetchingDeviceLightData();
158 ASSERT_EQ(-1, light_buffer_->data.value);
159 }
145 160
146 } // namespace 161 } // namespace
147 162
148 } // namespace content 163 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/device_sensors/sensor_manager_android.cc ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698