summaryrefslogtreecommitdiff
path: root/src/auto-test/internal-api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/auto-test/internal-api.c')
-rw-r--r--src/auto-test/internal-api.c210
1 files changed, 210 insertions, 0 deletions
diff --git a/src/auto-test/internal-api.c b/src/auto-test/internal-api.c
new file mode 100644
index 00000000..1c8a502e
--- /dev/null
+++ b/src/auto-test/internal-api.c
@@ -0,0 +1,210 @@
+/*
+ * test
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "test.h"
+#include <device/touchscreen-internal.h>
+#include <device/display-internal.h>
+#include <device/led-internal.h>
+#include <device/battery-internal.h>
+
+#define PALM_STR "palm"
+
+static unsigned int blue[] = {0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF,0x0000FF};
+
+static void __cb(void *data, GVariant *result, GError *err)
+{
+ int temp = 0;
+
+ if (!result)
+ {
+ _E("Can't get result of touchscreen request.:%s", err->message);
+ return;
+ }
+
+ if (!dh_get_param_from_var(result, "(i)", &temp)) {
+ _E("Failed to get variant(%s): no call back message", g_variant_get_type_string(result));
+ goto out;
+ }
+ _I("replay message(%d)", temp);
+
+out:
+ g_variant_unref(result);
+}
+
+static bool check_result(int val)
+{
+ if (val == DEVICE_ERROR_NONE || val == DEVICE_ERROR_NOT_SUPPORTED)
+ return true;
+ else
+ return false;
+}
+
+static bool touchscreen_disable(void)
+{
+ int ret;
+
+ ret = device_touchscreen_disable(__cb);
+
+ return check_result(ret);
+}
+
+static bool touchscreen_enable(void)
+{
+ int ret;
+
+ ret = device_touchscreen_enable(__cb);
+
+ return check_result(ret);
+}
+
+static bool display_get_brightness_state(display_state_e state, int *brightness)
+{
+ int ret;
+
+ ret = device_display_get_brightness_state(0, state, brightness);
+
+ return check_result(ret);
+}
+
+static bool display_get_max_brightness_state(display_state_e state, int *brightness)
+{
+ int ret;
+
+ ret = device_display_get_max_brightness_state(0, state, brightness);
+
+ return check_result(ret);
+}
+
+static bool display_set_brightness_state(display_state_e state, int brightness)
+{
+ int ret;
+
+ ret = device_display_set_brightness_state(0, state, brightness);
+
+ return check_result(ret);
+}
+
+static bool display_change_state_by_reason(display_state_e type, const char *reason, int timeout, device_dbus_pending_cb cb)
+{
+ int ret;
+
+ ret = device_display_change_state_by_reason(type, reason, timeout, cb);
+
+ return check_result(ret);
+}
+
+static bool multi_led_get_number(void)
+{
+ int ret;
+ int number_of_led;
+
+ ret = device_multi_led_get_number(&number_of_led);
+
+ return check_result(ret);
+}
+
+static bool multi_led_control(unsigned int color[])
+{
+ int ret;
+
+ ret = device_multi_led_control(color);
+
+ return check_result(ret);
+}
+
+static bool battery_get_info_direct(struct device_battery_info *info)
+{
+ int ret;
+
+ ret = device_battery_get_info_direct(info);
+
+ return check_result(ret);
+}
+
+static void internal_api_test_all(int *success, int *fail)
+{
+ struct device_battery_info info;
+ int brightness;
+ int s = 0;
+ int f = 0;
+
+ //touchscreen
+ (touchscreen_disable()) ? s++ : f++;
+ (touchscreen_enable()) ? s++ : f++;
+
+ //display
+ (display_get_brightness_state(DISPLAY_STATE_NORMAL, &brightness)) ? s++ : f++;
+ (display_get_brightness_state(DISPLAY_STATE_SCREEN_DIM, &brightness)) ? s++ : f++;
+ (display_get_max_brightness_state(DISPLAY_STATE_NORMAL, &brightness)) ? s++ : f++;
+ (display_get_max_brightness_state(DISPLAY_STATE_SCREEN_DIM, &brightness)) ? s++ : f++;
+ (display_set_brightness_state(DISPLAY_STATE_NORMAL, 100)) ? s++ : f++;
+ (display_set_brightness_state(DISPLAY_STATE_SCREEN_DIM, 1)) ? s++ : f++;
+ (display_change_state_by_reason(DISPLAY_STATE_SCREEN_OFF, PALM_STR, 0, __cb)) ? s++ : f++;
+
+ //led
+ (multi_led_get_number()) ? s++ : f++;
+ (multi_led_control(blue)) ? s++ : f++;
+
+ //battery
+ (battery_get_info_direct(&info)) ? s++ : f++;
+
+ if (NULL != success) *success = s;
+ if (NULL != fail) *fail = f;
+}
+
+static void internal_api_init(void *data)
+{
+ int success = 0;
+ int fail = 0;
+
+ _I("start test");
+
+ internal_api_test_all(&success, &fail);
+
+ _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
+}
+
+static void internal_api_exit(void *data)
+{
+ _I("end test");
+}
+
+static int internal_api_unit(int argc, char **argv)
+{
+ if (argc < 4) {
+ int success = 0;
+ int fail = 0;
+
+ _I("start test");
+ internal_api_test_all(&success, &fail);
+ _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
+ } else {
+ _E("Unknown test case!!!");
+ }
+
+ return 0;
+}
+
+static const struct test_ops internal_api_test_ops = {
+ .priority = TEST_PRIORITY_NORMAL,
+ .name = "internal-api",
+ .init = internal_api_init,
+ .exit = internal_api_exit,
+ .unit = internal_api_unit,
+};
+
+TEST_OPS_REGISTER(&internal_api_test_ops)