From 1aba775cfc5cfac5e5ff145f7206bc74e86b276f Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 12 May 2022 11:23:49 +0900 Subject: [PATCH] Add new tests to aul_test tool Adds: - aul_listen_app_dead_signal_test - aul_listen_app_launch_signal_test - aul_listen_app_launch_signal_v2_test - aul_listen_app_status_signal_test Change-Id: Ida54b8822160fbf34940be5fcb7cc84c525088e1 Signed-off-by: Hwankyu Jhun --- .../tests/aul_listen_app_dead_signal_test.cc | 48 ++++++++++++++ .../tests/aul_listen_app_launch_signal_test.cc | 48 ++++++++++++++ .../tests/aul_listen_app_launch_signal_v2_test.cc | 50 +++++++++++++++ .../tests/aul_listen_app_status_signal_test.cc | 74 ++++++++++++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 tool/aul_test/tests/aul_listen_app_dead_signal_test.cc create mode 100644 tool/aul_test/tests/aul_listen_app_launch_signal_test.cc create mode 100644 tool/aul_test/tests/aul_listen_app_launch_signal_v2_test.cc create mode 100644 tool/aul_test/tests/aul_listen_app_status_signal_test.cc diff --git a/tool/aul_test/tests/aul_listen_app_dead_signal_test.cc b/tool/aul_test/tests/aul_listen_app_dead_signal_test.cc new file mode 100644 index 0000000..b22b5d2 --- /dev/null +++ b/tool/aul_test/tests/aul_listen_app_dead_signal_test.cc @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "include/aul.h" + +#include "aul_test.hh" +#include "log_private.hh" + +namespace aul_test { + +class AulListenAppDeadSignalTest : public AulTest { + public: + AulListenAppDeadSignalTest() + : AulTest("listen_app_dead_signal", "aul_listen_app_dead_signal", + "listen_app_dead_signal", false) {} + + void SetUp() override {} + + void TearDown() override {} + + int Test(int argc, char** argv) override { + _D("[aul_listen_app_dead_signal test]"); + return aul_listen_app_dead_signal(AppDeadEventCb, this); + } + + private: + static int AppDeadEventCb(int pid, void* user_data) { + _D("pid(%d) is dead", pid); + return 0; + } +}; + +AUL_TEST_REGISTER(AulListenAppDeadSignalTest, listen_app_dead_signal_test); + +} // namespace aul_test diff --git a/tool/aul_test/tests/aul_listen_app_launch_signal_test.cc b/tool/aul_test/tests/aul_listen_app_launch_signal_test.cc new file mode 100644 index 0000000..0179cb5 --- /dev/null +++ b/tool/aul_test/tests/aul_listen_app_launch_signal_test.cc @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "include/aul.h" + +#include "aul_test.hh" +#include "log_private.hh" + +namespace aul_test { + +class AulListenAppLaunchSignalTest : public AulTest { + public: + AulListenAppLaunchSignalTest() + : AulTest("listen_app_launch_signal", "aul_listen_app_launch_signal", + "listen_app_launch_signal", false) {} + + void SetUp() override {} + + void TearDown() override {} + + int Test(int argc, char** argv) override { + _D("[aul_listen_app_launch_signal test]"); + return aul_listen_app_launch_signal(AppLaunchEventCb, this); + } + + private: + static int AppLaunchEventCb(int pid, void* user_data) { + _D("pid(%d) is launched", pid); + return 0; + } +}; + +AUL_TEST_REGISTER(AulListenAppLaunchSignalTest, listen_app_launch_signal_test); + +} // namespace aul_test diff --git a/tool/aul_test/tests/aul_listen_app_launch_signal_v2_test.cc b/tool/aul_test/tests/aul_listen_app_launch_signal_v2_test.cc new file mode 100644 index 0000000..e9d1620 --- /dev/null +++ b/tool/aul_test/tests/aul_listen_app_launch_signal_v2_test.cc @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "include/aul.h" + +#include "aul_test.hh" +#include "log_private.hh" + +namespace aul_test { + +class AulListenAppLaunchSignalV2Test : public AulTest { + public: + AulListenAppLaunchSignalV2Test() + : AulTest("listen_app_launch_signal_v2", + "aul_listen_app_launch_signal_v2", + "listen_app_launch_signal_v2", false) {} + + void SetUp() override {} + + void TearDown() override {} + + int Test(int argc, char** argv) override { + _D("[aul_listen_app_launch_signal_v2 test]"); + return aul_listen_app_launch_signal_v2(AppLaunchEventCb, this); + } + + private: + static int AppLaunchEventCb(int pid, const char* appid, void* user_data) { + _D("pid(%d) is launched. appid(%s)", pid, appid); + return 0; + } +}; + +AUL_TEST_REGISTER(AulListenAppLaunchSignalV2Test, + listen_app_launch_signal_v2_test); + +} // namespace aul_test diff --git a/tool/aul_test/tests/aul_listen_app_status_signal_test.cc b/tool/aul_test/tests/aul_listen_app_status_signal_test.cc new file mode 100644 index 0000000..5e53268 --- /dev/null +++ b/tool/aul_test/tests/aul_listen_app_status_signal_test.cc @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "include/aul.h" + +#include "aul_test.hh" +#include "log_private.hh" + +namespace aul_test { + +class AulListenAppStatusSignalTest : public AulTest { + public: + AulListenAppStatusSignalTest() + : AulTest("listen_app_status_signal", "aul_listen_app_status_signal", + "listen_app_status_signal", false) {} + + void SetUp() override {} + + void TearDown() override {} + + int Test(int argc, char** argv) override { + _D("[aul_listen_app_status_signal test]"); + return aul_listen_app_status_signal(AppStatusEventCb, this); + } + + private: + static const char* GetStatusString(int status) { + const char* status_str; + switch (status) { + case AUL_PROC_STATUS_LAUNCH: + status_str = "LAUNCH"; + break; + case AUL_PROC_STATUS_FG: + status_str = "FG"; + break; + case AUL_PROC_STATUS_BG: + status_str = "BG"; + break; + case AUL_PROC_STATUS_FOCUS: + status_str = "FOCUS"; + break; + case AUL_PROC_STATUS_HIDE: + status_str = "HIDE"; + break; + default: + status_str = "UNKNOWN"; + break; + } + + return status_str; + } + + static int AppStatusEventCb(int pid, int status, void* user_data) { + _D("pid: %d, status: %d(%s)", pid, status, GetStatusString(status)); + return 0; + } +}; + +AUL_TEST_REGISTER(AulListenAppStatusSignalTest, listen_app_status_signal_test); + +} // namespace aul_test -- 2.7.4