--- /dev/null
+/*
+ * test
+ *
+ * Copyright (c) 2013 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"
+
+#define METHOD_IR_ISAVAILABLE "IRIsAvailable"
+#define METHOD_IR_TRANSMIT "TransmitIR"
+#define METHOD_IR_SETIRCOMMAND "SetIrCommand"
+
+struct dbus_int {
+ int *list;
+ int size;
+};
+
+static bool request_ir_method(const char *method, char *sig, char *param[])
+{
+ DBusMessage *msg;
+ int val;
+ bool ret = FALSE;
+
+ msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
+ DEVICED_PATH_IR,
+ DEVICED_INTERFACE_IR,
+ method, sig, param);
+ if (!msg) {
+ _E("fail (%s): no reply", method);
+ return ret;
+ }
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0)
+ _E("fail (%s): no message", method);
+ else {
+ if ((val == -ENOTSUP) || (val == -ENOSYS)) {
+ _I("Not supported feature! (%s): %d", method, val);
+ ret = TRUE;
+ } else if (val == -ENODEV) {
+ _E("fail (%s): device open fail (%d)", method, val);
+ } else if (val < 0) {
+ _E("fail (%s): returned fail (%d)", method, val);
+ } else {
+ _I("success (%s): %d", method, val);
+ ret = TRUE;
+ }
+ }
+
+ dbus_message_unref(msg);
+ return ret;
+}
+
+static bool get_ir_isavailable()
+{
+ return request_ir_method(METHOD_IR_ISAVAILABLE, NULL, NULL);
+}
+
+static bool set_ir_transmit(int carrier_frequency, int *pattern, int size)
+{
+ char *param[1];
+ int freq_pattern[size + 1];
+ struct dbus_int pattern_list;
+
+ freq_pattern[0] = carrier_frequency;
+ for (int i = 1; i <= size; i++)
+ freq_pattern[i] = pattern[i-1];
+
+ pattern_list.list = freq_pattern;
+ pattern_list.size = size + 1;
+
+ param[0] = (char *)&pattern_list;
+ return request_ir_method(METHOD_IR_TRANSMIT, "ai", param);
+}
+
+/*legacy command*/
+static bool set_ir_command(char *command)
+{
+ DBusMessage *msg;
+ int val;
+ char *param[1];
+ bool ret = FALSE;
+
+ param[0] = command;
+ msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
+ DEVICED_PATH_LED,
+ DEVICED_INTERFACE_LED,
+ METHOD_IR_SETIRCOMMAND, "s", param);
+ if (!msg) {
+ _E("fail : no reply");
+ return ret;
+ }
+
+ if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0)
+ _E("fail : no message");
+ else {
+ if ((val == -ENOTSUP) || (val == -ENOSYS)) {
+ _I("Not supported feature! : %d", val);
+ ret = TRUE;
+ } else if (val < 0) {
+ _E("fail : returned fail (%d)", val);
+ } else {
+ _I("success : %d", val);
+ ret = TRUE;
+ }
+ }
+
+ dbus_message_unref(msg);
+ return ret;
+}
+
+void ir_test_all(int *success, int *fail)
+{
+ int s = 0;
+ int f = 0;
+
+ int pattern[5] = {100, 200, 300, 400, 500};
+
+ (get_ir_isavailable()) ? s++ : f++;
+ (set_ir_transmit(38000, pattern, 5)) ? s++ : f++;
+ (set_ir_command("N/A")) ? s++ : f++;
+
+
+ if (NULL != success) *success = s;
+ if (NULL != fail) *fail = f;
+}
+
+static void ir_init(void *data)
+{
+ int success = 0;
+ int fail = 0;
+
+ _I("start test");
+
+ ir_test_all(&success, &fail);
+
+ _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
+}
+
+static void ir_exit(void *data)
+{
+ _I("end test");
+}
+
+static int ir_unit(int argc, char **argv)
+{
+ if (argc < 4) {
+ int success = 0;
+ int fail = 0;
+
+ _I("start test");
+ ir_test_all(&success, &fail);
+ _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
+ } else if (0 == strcasecmp(argv[3], METHOD_IR_ISAVAILABLE)) {
+ get_ir_isavailable();
+ //} else if (0 == strcasecmp(argv[3], METHOD_IR_TRANSMIT)) {
+ // set_ir_transmit();
+ } else if (0 == strcasecmp(argv[3], METHOD_IR_SETIRCOMMAND)) {
+ set_ir_command(argv[4]);
+ } else {
+ _E("Unknown test case!!!");
+ }
+
+ return 0;
+}
+
+static const struct test_ops ir_test_ops = {
+ .priority = TEST_PRIORITY_NORMAL,
+ .name = "ir",
+ .init = ir_init,
+ .exit = ir_exit,
+ .unit = ir_unit,
+};
+
+TEST_OPS_REGISTER(&ir_test_ops)
#include "test.h"
#include <stdio.h>
-#define METHOD_LED_SETIRCOMMAND "SetIrCommand"
#define METHOD_LED_PLAYCUSTOM "playcustom"
#define METHOD_LED_STOPCUSTOM "stopcustom"
//#define METHOD_LED_GETBRIGHTNESS_FORCAMERA "GetBrightnessForCamera"
return set_led_method(METHOD_LED_STOPCUSTOM, NULL, NULL);
}
-static bool set_led_ircommand(char *command)
-{
- char *param[1];
-
- param[0] = command;
-
- return set_led_method(METHOD_LED_SETIRCOMMAND, "s", param);
-}
-
void led_test_all(int *success, int *fail)
{
int s = 0;
(get_led_brightness()) ? s++ : f++;
(set_led_playcustom(1, 0, RED, DEFAULT_FLAG)) ? s++ : f++;
(set_led_stopcustom()) ? s++ : f++;
- (set_led_ircommand("N/A")) ? s++ : f++;
if (NULL != success) *success = s;
if (NULL != fail) *fail = f;
set_led_playcustom(atoi(argv[4]), atoi(argv[5]), strtoul(argv[6], NULL, 16), DEFAULT_FLAG);
} else if (0 == strcasecmp(argv[3], METHOD_LED_STOPCUSTOM)) {
set_led_stopcustom();
- } else if (0 == strcasecmp(argv[3], METHOD_LED_SETIRCOMMAND)) {
- set_led_ircommand(argv[3]);
} else {
_E("Unknown test case!!!");
}