Index: device/generic_sensor/platform_sensor_provider_unittest_android.cc |
diff --git a/device/generic_sensor/platform_sensor_provider_unittest_android.cc b/device/generic_sensor/platform_sensor_provider_unittest_android.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..da9de3cc5c655533b508c6dcdd597c243da64f25 |
--- /dev/null |
+++ b/device/generic_sensor/platform_sensor_provider_unittest_android.cc |
@@ -0,0 +1,40 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "device/generic_sensor/platform_sensor_provider_android.h" |
+ |
+#include "base/macros.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace device { |
+ |
+class PlatformSensorProviderTestAndroid : public testing::Test { |
+ public: |
+ PlatformSensorProviderTestAndroid() = default; |
+ |
+ void SetUp() override { |
+ provider_ = PlatformSensorProviderAndroid::GetInstance(); |
+ ASSERT_TRUE(provider_); |
+ } |
+ |
+ void CreateSensorCallback(scoped_refptr<PlatformSensor> sensor) { |
+ EXPECT_FALSE(sensor); |
+ } |
+ |
+ protected: |
+ PlatformSensorProviderAndroid* provider_; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderTestAndroid); |
+}; |
+ |
+TEST_F(PlatformSensorProviderTestAndroid, SensorManagerIsNull) { |
+ provider_->SetSensorManagerToNullForTesting(); |
+ provider_->CreateSensor( |
+ device::mojom::SensorType::AMBIENT_LIGHT, |
+ base::Bind(&PlatformSensorProviderTestAndroid::CreateSensorCallback, |
+ base::Unretained(this))); |
+} |
+ |
+} // namespace device |