4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include <sensor_internal.h>
25 #include "test_bench.h"
26 #include "sensor_adapter.h"
28 static void basic_cb(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data)
30 EXPECT_GT(data->timestamp, 0);
31 //_N("[ DATA ] %f\n", data->values[0]);
35 TESTCASE(all_sensor_test, scenario_basic_p)
44 err = sensord_get_sensors(ALL_SENSOR, &sensors, &count);
47 for (int i = 0; i < count; ++i) {
48 sensord_get_type(sensors[i], &type);
50 _N("[ TYPE ] %s\n", "UNKNOWN_SENSOR");
52 sensor_info info(type, 0, 100, 1000, SENSOR_OPTION_ALWAYS_ON, basic_cb, NULL);
54 ret = sensor_adapter::start(info, handle);
59 ret = sensor_adapter::stop(info, handle);
68 typedef bool (*process_func_t)(const char *msg, int size, int count);
70 static pid_t run_process(process_func_t func, const char *msg, int size, int count)
77 if (!func(msg, size, count))
78 _E("Failed to run process\n");
85 static bool run_echo_command_test(const char *str, int size, int cout)
89 char buf[4096] = {'1', '1', '1', };
91 sensor_info info(ACCELEROMETER_SENSOR, 0,
92 100, 1000, SENSOR_OPTION_ALWAYS_ON, basic_cb, NULL);
93 sensor_adapter::get_handle(info, handle);
96 for (int i = 0; i < 1024; ++i)
97 ret &= sensor_adapter::set_attribute(handle, SENSOR_ATTR_ACCELEROMETER_INJECTION, buf, 4096);
103 TESTCASE(echo_command_test, echo_command_p)
109 for (int i = 0; i < 100; ++i) {
110 pid = run_process(run_echo_command_test, NULL, 0, 0);
114 pid = run_process(run_echo_command_test, NULL, 0, 0);
124 TESTCASE(gyroscope_value_p)
126 scenario_basic_p(GYROSCOPE_SENSOR);
129 TESTCASE(gravitye_value_p)
131 scenario_basic_p(GRAVITY_SENSOR);
134 TESTCASE(linear_accel_value_p)
136 scenario_basic_p(LINEAR_ACCEL_SENSOR);
139 TESTCASE(proximity_value_p)
141 scenario_basic_p(PROXIMITY_SENSOR);
144 TESTCASE(pressure_value_p)
146 scenario_basic_p(PRESSURE_SENSOR);
149 TESTCASE(hrm_value_p)
151 scenario_basic_p(HRM_SENSOR);
154 TESTCASE(hrm_raw_value_p)
156 scenario_basic_p(HRM_RAW_SENSOR);
159 TESTCASE(hrm_led_green_value_p)
161 scenario_basic_p(HRM_LED_GREEN_SENSOR);
164 TESTCASE(wrist_up_value_p)
166 scenario_basic_p(GESTURE_WRIST_UP_SENSOR);