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

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

Issue 2452083002: [Device Sensors] Remove BrowserThread knowledge (Closed)
Patch Set: Created 4 years, 1 month 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 <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"
11 #include "base/message_loop/message_loop.h"
11 #include "content/browser/device_sensors/device_sensors_consts.h" 12 #include "content/browser/device_sensors/device_sensors_consts.h"
12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 namespace { 17 namespace {
18 18
19 class FakeSensorManagerAndroid : public SensorManagerAndroid { 19 class FakeSensorManagerAndroid : public SensorManagerAndroid {
20 public: 20 public:
21 FakeSensorManagerAndroid() {} 21 FakeSensorManagerAndroid() {}
22 ~FakeSensorManagerAndroid() override {} 22 ~FakeSensorManagerAndroid() override {}
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 ASSERT_EQ(beta, buffer->data.beta); 59 ASSERT_EQ(beta, buffer->data.beta);
60 ASSERT_TRUE(buffer->data.hasBeta); 60 ASSERT_TRUE(buffer->data.hasBeta);
61 ASSERT_EQ(gamma, buffer->data.gamma); 61 ASSERT_EQ(gamma, buffer->data.gamma);
62 ASSERT_TRUE(buffer->data.hasGamma); 62 ASSERT_TRUE(buffer->data.hasGamma);
63 } 63 }
64 64
65 std::unique_ptr<DeviceLightHardwareBuffer> light_buffer_; 65 std::unique_ptr<DeviceLightHardwareBuffer> light_buffer_;
66 std::unique_ptr<DeviceMotionHardwareBuffer> motion_buffer_; 66 std::unique_ptr<DeviceMotionHardwareBuffer> motion_buffer_;
67 std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_; 67 std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_buffer_;
68 std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_absolute_buffer_; 68 std::unique_ptr<DeviceOrientationHardwareBuffer> orientation_absolute_buffer_;
69 content::TestBrowserThreadBundle thread_bundle_; 69 base::MessageLoop message_loop_;
timvolodine 2016/10/31 15:52:47 is this needed anywhere?
blundell 2016/11/09 16:00:46 It's implicitly needed by the fact that SensorMana
70 }; 70 };
71 71
72 TEST_F(AndroidSensorManagerTest, ThreeDeviceMotionSensorsActive) { 72 TEST_F(AndroidSensorManagerTest, ThreeDeviceMotionSensorsActive) {
73 FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread()); 73 FakeSensorManagerAndroid::Register(base::android::AttachCurrentThread());
74 FakeSensorManagerAndroid sensorManager; 74 FakeSensorManagerAndroid sensorManager;
75 sensorManager.SetNumberActiveDeviceMotionSensors(3); 75 sensorManager.SetNumberActiveDeviceMotionSensors(3);
76 76
77 sensorManager.StartFetchingDeviceMotionData(motion_buffer_.get()); 77 sensorManager.StartFetchingDeviceMotionData(motion_buffer_.get());
78 ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive); 78 ASSERT_FALSE(motion_buffer_->data.allAvailableSensorsAreActive);
79 79
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 sensorManager.GotLight(nullptr, nullptr, 100); 183 sensorManager.GotLight(nullptr, nullptr, 100);
184 ASSERT_EQ(100, light_buffer_->data.value); 184 ASSERT_EQ(100, light_buffer_->data.value);
185 185
186 sensorManager.StopFetchingDeviceLightData(); 186 sensorManager.StopFetchingDeviceLightData();
187 ASSERT_EQ(-1, light_buffer_->data.value); 187 ASSERT_EQ(-1, light_buffer_->data.value);
188 } 188 }
189 189
190 } // namespace 190 } // namespace
191 191
192 } // namespace content 192 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698