1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _GTS_NANOAPPS_GENERAL_TEST_BASIC_SENSOR_TESTS_H_
18 #define _GTS_NANOAPPS_GENERAL_TEST_BASIC_SENSOR_TESTS_H_
19 
20 #include <general_test/basic_sensor_test_base.h>
21 
22 #include <chre.h>
23 
24 namespace general_test {
25 
26 class BasicAccelerometerTest : public BasicSensorTestBase {
27  public:
BasicAccelerometerTest()28   BasicAccelerometerTest()
29       : BasicSensorTestBase() {}
30 
31  protected:
getSensorType()32   uint8_t getSensorType() const override {
33     return CHRE_SENSOR_TYPE_ACCELEROMETER;
34   }
isRequiredSensor()35   bool isRequiredSensor() const override { return true; }
isOnChangeSensor()36   bool isOnChangeSensor() const override { return false; }
isOneShotSensor()37   bool isOneShotSensor() const override { return false; }
38   void confirmDataIsSane(const void* eventData) override;
39 };
40 
41 class BasicInstantMotionDetectTest : public BasicSensorTestBase {
42  public:
BasicInstantMotionDetectTest()43   BasicInstantMotionDetectTest()
44       : BasicSensorTestBase() {}
45 
46  protected:
getSensorType()47   uint8_t getSensorType() const override {
48     return CHRE_SENSOR_TYPE_INSTANT_MOTION_DETECT;
49   }
isRequiredSensor()50   bool isRequiredSensor() const override { return true; }
isOnChangeSensor()51   bool isOnChangeSensor() const override { return false; }
isOneShotSensor()52   bool isOneShotSensor() const override { return true; }
53   void confirmDataIsSane(const void* eventData) override;
54 };
55 
56 class BasicStationaryDetectTest : public BasicSensorTestBase {
57  public:
BasicStationaryDetectTest()58   BasicStationaryDetectTest()
59       : BasicSensorTestBase() {}
60 
61  protected:
getSensorType()62   uint8_t getSensorType() const override {
63     return CHRE_SENSOR_TYPE_STATIONARY_DETECT;
64   }
isRequiredSensor()65   bool isRequiredSensor() const override { return true; }
isOnChangeSensor()66   bool isOnChangeSensor() const override { return false; }
isOneShotSensor()67   bool isOneShotSensor() const override { return true; }
68   void confirmDataIsSane(const void* eventData) override;
69 };
70 
71 class BasicGyroscopeTest : public BasicSensorTestBase {
72  public:
BasicGyroscopeTest()73   BasicGyroscopeTest()
74       : BasicSensorTestBase() {}
75 
76  protected:
getSensorType()77   uint8_t getSensorType() const override {
78     return CHRE_SENSOR_TYPE_GYROSCOPE;
79   }
isRequiredSensor()80   bool isRequiredSensor() const override { return true; }
isOnChangeSensor()81   bool isOnChangeSensor() const override { return false; }
isOneShotSensor()82   bool isOneShotSensor() const override { return false; }
83   void confirmDataIsSane(const void* eventData) override;
84 };
85 
86 class BasicMagnetometerTest : public BasicSensorTestBase {
87  public:
BasicMagnetometerTest()88   BasicMagnetometerTest()
89       : BasicSensorTestBase() {}
90 
91  protected:
getSensorType()92   uint8_t getSensorType() const override {
93     return CHRE_SENSOR_TYPE_GEOMAGNETIC_FIELD;
94   }
isRequiredSensor()95   bool isRequiredSensor() const override { return false; }
isOnChangeSensor()96   bool isOnChangeSensor() const override { return false; }
isOneShotSensor()97   bool isOneShotSensor() const override { return false; }
98   void confirmDataIsSane(const void* eventData) override;
99 };
100 
101 class BasicBarometerTest : public BasicSensorTestBase {
102  public:
BasicBarometerTest()103   BasicBarometerTest()
104       : BasicSensorTestBase() {}
105 
106  protected:
getSensorType()107   uint8_t getSensorType() const override {
108     return CHRE_SENSOR_TYPE_PRESSURE;
109   }
isRequiredSensor()110   bool isRequiredSensor() const override { return false; }
isOnChangeSensor()111   bool isOnChangeSensor() const override { return false; }
isOneShotSensor()112   bool isOneShotSensor() const override { return false; }
113   void confirmDataIsSane(const void* eventData) override;
114 };
115 
116 class BasicLightSensorTest : public BasicSensorTestBase {
117  public:
BasicLightSensorTest()118   BasicLightSensorTest()
119       : BasicSensorTestBase() {}
120 
121  protected:
getSensorType()122   uint8_t getSensorType() const override {
123     return CHRE_SENSOR_TYPE_LIGHT;
124   }
isRequiredSensor()125   bool isRequiredSensor() const override { return false; }
isOnChangeSensor()126   bool isOnChangeSensor() const override { return true; }
isOneShotSensor()127   bool isOneShotSensor() const override { return false; }
128   void confirmDataIsSane(const void* eventData) override;
129 };
130 
131 class BasicProximityTest : public BasicSensorTestBase {
132  public:
BasicProximityTest()133   BasicProximityTest()
134       : BasicSensorTestBase() {}
135 
136  protected:
getSensorType()137   uint8_t getSensorType() const override {
138     return CHRE_SENSOR_TYPE_PROXIMITY;
139   }
isRequiredSensor()140   bool isRequiredSensor() const override { return false; }
isOnChangeSensor()141   bool isOnChangeSensor() const override { return true; }
isOneShotSensor()142   bool isOneShotSensor() const override { return false; }
143   void confirmDataIsSane(const void* eventData) override;
144 };
145 
146 }  // namespace general_test
147 
148 
149 #endif  // _GTS_NANOAPPS_GENERAL_TEST_BASIC_SENSOR_TESTS_H_
150