Fix build and runtime failures of utc 32/305232/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 30 Jan 2024 07:17:07 +0000 (16:17 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 30 Jan 2024 08:08:17 +0000 (17:08 +0900)
Change-Id: I2aae00bcf0ec2bb6535fc4353bc220a75a1b00fd

31 files changed:
inc/application_manager.h
inc/application_manager_aul.h
src/application_manager_aul.cpp
src/package_update_monitor.cpp
src/service_config.cpp
src/service_plugin.cpp
tests/utc/application-manager/CMakeLists.txt
tests/utc/application-manager/test_main.cpp
tests/utc/application-manager/ttpo.xml
tests/utc/audio-manager/CMakeLists.txt
tests/utc/client-manager/CMakeLists.txt
tests/utc/client-manager/test_client_manager.cpp
tests/utc/config/CMakeLists.txt
tests/utc/config/test_config.cpp
tests/utc/package-update-monitor/CMakeLists.txt
tests/utc/package-update-monitor/pkgmgrinfo_mock.cpp [new file with mode: 0644]
tests/utc/package-update-monitor/pkgmgrinfo_mock.h [new file with mode: 0644]
tests/utc/package-update-monitor/test_package_update_monitor.cpp
tests/utc/preference-manager-vconf/CMakeLists.txt
tests/utc/service-main/CMakeLists.txt
tests/utc/service-main/test_service_main.cpp
tests/utc/wakeup-manager/CMakeLists.txt
tests/utc/wakeup-manager/test_main.cpp
tests/utc/wakeup-manager/ttpo.xml
tests/utc/wakeup-policy-default/CMakeLists.txt
tests/utc/wakeup-policy-default/test_main.cpp
wakeup-manager/CMakeLists.txt
wakeup-manager/inc/assistant_config_manager.h
wakeup-manager/inc/wakeup_manager_main.h
wakeup-manager/src/wakeup_audio_manager.cpp
wakeup-manager/src/wakeup_manager.cpp

index 07802b3..a05ea33 100644 (file)
@@ -29,6 +29,7 @@ public:
        virtual bool launch_app_async(const std::string& appid, bool background) = 0;
        virtual boost::optional<std::string> get_appid_by_pid(pid_t pid) = 0;
        virtual boost::optional<pid_t> get_pid_by_appid(const std::string& appid) = 0;
+       virtual void clear_cache() = 0;
 };
 
 #endif /* __APPLICATION_MANAGER_H__ */
index c07836c..5ff2232 100644 (file)
 
 #include "application_manager.h"
 
+#include <chrono>
+#include <map>
+#include <string>
+
 class CApplicationManagerAul : public IApplicationManager {
 public:
        CApplicationManagerAul();
@@ -31,6 +35,20 @@ public:
        bool launch_app_async(const std::string& appid, bool background) override;
        boost::optional<std::string> get_appid_by_pid(pid_t pid) override;
        boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override;
+       void clear_cache() override;
+
+private:
+       typedef struct {
+               std::string appid;
+               std::chrono::time_point<std::chrono::steady_clock> updated;
+       } AppIDCache;
+       typedef struct {
+               pid_t pid;
+               std::chrono::time_point<std::chrono::steady_clock> updated;
+       } PIDCache;
+
+       std::map<pid_t, AppIDCache> mAppIDCache;
+       std::map<std::string, PIDCache> mPIDCache;
 };
 
 #endif /* __APPLICATION_MANAGER_AUL_H__ */
index ea0d759..3061c2c 100644 (file)
@@ -129,14 +129,8 @@ boost::optional<std::string> CApplicationManagerAul::get_appid_by_pid(pid_t pid)
        int retry_num = 0;
        char appid[MAX_APPID_LEN] = {'\0', };
 
-       typedef struct {
-               std::string appid;
-               std::chrono::time_point<std::chrono::steady_clock> updated;
-       } AppInfo;
-
-       static std::map<pid_t, AppInfo> appids;
-       if (appids.find(pid) != appids.end()) {
-               auto info = appids[pid];
+       if (mAppIDCache.find(pid) != mAppIDCache.end()) {
+               auto info = mAppIDCache[pid];
                auto now = std::chrono::steady_clock::now();
                if (now - info.updated < std::chrono::seconds(60)) {
                        ret = info.appid;
@@ -150,7 +144,7 @@ boost::optional<std::string> CApplicationManagerAul::get_appid_by_pid(pid_t pid)
                                ret = std::string{appid};
                                succeeded = true;
 
-                               appids[pid] = AppInfo{*ret, std::chrono::steady_clock::now()};
+                               mAppIDCache[pid] = AppIDCache{*ret, std::chrono::steady_clock::now()};
                        }
                        retry_num++;
                } while (!succeeded && retry_num < max_retry_num);
@@ -163,14 +157,8 @@ boost::optional<pid_t> CApplicationManagerAul::get_pid_by_appid(const std::strin
 {
        boost::optional<pid_t> ret;
 
-       typedef struct {
-               pid_t pid;
-               std::chrono::time_point<std::chrono::steady_clock> updated;
-       } AppInfo;
-
-       static std::map<std::string, AppInfo> pids;
-       if (pids.find(appid) != pids.end()) {
-               auto info = pids[appid];
+       if (mPIDCache.find(appid) != mPIDCache.end()) {
+               auto info = mPIDCache[appid];
                auto now = std::chrono::steady_clock::now();
                if (now - info.updated < std::chrono::seconds(10)) {
                        ret = info.pid;
@@ -181,9 +169,15 @@ boost::optional<pid_t> CApplicationManagerAul::get_pid_by_appid(const std::strin
                pid_t pid = aul_app_get_pid(appid.c_str());
                if (pid >= 0) {
                        ret = pid;
-                       pids[appid] = AppInfo{pid, std::chrono::steady_clock::now()};
+                       mPIDCache[appid] = PIDCache{pid, std::chrono::steady_clock::now()};
                }
        }
 
        return ret;
 }
+
+void CApplicationManagerAul::clear_cache()
+{
+       mAppIDCache.clear();
+       mPIDCache.clear();
+}
\ No newline at end of file
index b966321..ce8087b 100644 (file)
@@ -71,11 +71,14 @@ static bool is_wakeup_engine(const pkgmgrinfo_appinfo_h handle, CPackageUpdateMo
 
        int ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
        if (PMINFO_R_OK == ret && NULL != appid) {
-               for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM;loop++) {
-                       if (clientInfo.getItems()[loop].used) {
-                               for (int inner_loop = 0;inner_loop < MAX_WAKEUP_ENGINES_NUM;inner_loop++) {
-                                       LOGI("comparing appid : %s %s", clientInfo.getItems()[loop].wakeup_engine[inner_loop], appid);
-                                       if (0 == clientInfo.getItems()[loop].wakeup_engine[inner_loop].compare(appid)) {
+               std::vector<ClientInfoItems> &items = clientInfo.getItems();
+               for (int loop = 0; loop < std::min(MAX_MACLIENT_INFO_NUM, items.size());loop++) {
+                       if (items[loop].used) {
+                               for (int inner_loop = 0;
+                                       inner_loop < std::min(MAX_WAKEUP_ENGINES_NUM, items[loop].wakeup_engine.size());
+                                       inner_loop++) {
+                                       LOGI("comparing appid : %s %s", items[loop].wakeup_engine[inner_loop], appid);
+                                       if (0 == items[loop].wakeup_engine[inner_loop].compare(appid)) {
                                                is_wakeup_engine = true;
                                        }
                                }
index 98ee653..cda77e5 100644 (file)
@@ -154,7 +154,7 @@ int CServiceConfig::parse_assistant_info(service_config_assistant_info_cb callba
                                        }
                                        temp.cnt_wakeup_engine++;
                                        if (temp.cnt_wakeup_engine >= MAX_WAKEUP_ENGINES_NUM) {
-                                               MAS_LOGE("cnt_wakeup_engine exceeds : %d", MAX_WAKEUP_ENGINES_NUM);
+                                               MAS_LOGE("cnt_wakeup_engine exceeds : %zu", MAX_WAKEUP_ENGINES_NUM);
                                                temp.cnt_wakeup_engine = MAX_WAKEUP_ENGINES_NUM - 1;
                                        }
                                }
@@ -271,20 +271,19 @@ int CServiceConfig::add_custom_wake_word(const char* wake_word, const char* lang
 {
        if (nullptr == wake_word || nullptr == language) return -1;
 
-       bool found = false;
-       for (int loop = 0;false == found && loop < MAX_WAKEUP_WORDS_NUM;loop++) {
+       size_t max_size = get_custom_wake_word_num(wakeup_word_storage, wakeup_language_storage);
+
+       for (int loop = 0;loop < max_size;loop++) {
                if (0 == wakeup_word_storage[loop].compare(wake_word) &&
                        0 == wakeup_language_storage[loop].compare(language)) {
                        LOGE("The wakeup word already exists!");
                        return -1; /* Already exists */
                }
-               if (0 == wakeup_word_storage[loop].length()) {
-                       wakeup_word_storage[loop] = wake_word;
-                       wakeup_language_storage[loop] = language;
-                       found = true;
-               }
        }
-       if (!found) {
+       if (max_size < MAX_WAKEUP_WORDS_NUM) {
+               wakeup_word_storage.push_back(wake_word);
+               wakeup_language_storage.push_back(language);
+       } else {
                LOGE("No empty slot found while trying to add new wake word!");
                return -1;
        }
@@ -297,7 +296,7 @@ int CServiceConfig::remove_custom_wake_word(const char* wake_word, const char* l
 {
        if (nullptr == wake_word || nullptr == language) return -1;
 
-       bool found = false;
+       int found = 0;
 
        size_t max_size = get_custom_wake_word_num(wakeup_word_storage, wakeup_language_storage);
 
@@ -312,10 +311,14 @@ int CServiceConfig::remove_custom_wake_word(const char* wake_word, const char* l
                        wakeup_language_storage[max_size - 1].clear();
 
                        loop--; /* Just in case there are duplicated items */
-                       found = true;
+                       found++;
                }
        }
-       if (!found) return -1;
+       if (found == 0) return -1;
+
+       wakeup_word_storage.resize((max_size > found) ? max_size - found : 0);
+       wakeup_language_storage.resize((max_size > found) ? max_size - found : 0);
+
        return 0;
 }
 
index 93af57b..745fa82 100644 (file)
@@ -247,10 +247,8 @@ static void __wakeup_event_cb(mas_wakeup_event_info wakeup_info, void* user_data
        MAS_LOGI("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
        int ret = -1;
 
-       CServiceMain* service_main = nullptr;
        CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
        if (plugin) {
-               service_main = plugin->get_service_main();
                CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
                if (plugin->is_ui_panel_enabled() && service_ipc) {
                        int retry_cnt = 0;
index eb1fe31..1a3e5c3 100644 (file)
@@ -14,7 +14,6 @@ SET(TTPO_SRCS
 )
 
 SET(TTPO_PKGS
-    capi-appfw-application
     glib-2.0
     capi-appfw-service-application
 )
@@ -24,6 +23,7 @@ SET(TTPO_INCLUDES
 )
 
 SET(TTPO_CFLAGS
+    -DWRAP_APP_PATH_PREFIX=..
 )
 
 SET(TTPO_WRAPPERS
@@ -34,11 +34,13 @@ SET(TTPO_WRAPPERS
 SET(TTPO_LDFLAGS
 )
 
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++14")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -O0")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Og")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TTPO_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TTPO_CFLAGS}")
 SET(EXTRA_LDFLAGS "${TTPO_LDFLAGS}")
 
 # Find Packages
@@ -51,6 +53,7 @@ INCLUDE_DIRECTORIES(${TTPO_INCLUDES})
 
 FOREACH(flag ${pkgs_CFLAGS})
     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
 ENDFOREACH(flag)
 
 FIND_PACKAGE(GTest REQUIRED)
@@ -74,5 +77,4 @@ SET_TARGET_PROPERTIES(${TTPO_EXECUTABLE} PROPERTIES
        LINK_FLAGS "${TTPO_WRAPPERS}")
 ADD_TEST(NAME ${TTPO_EXECUTABLE} COMMAND ${TTPO_EXECUTABLE})
 
-# REPLACE THE TARGET INSTALL DESTINATION AS NEEDED (default : bin)
-INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
\ No newline at end of file
+INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
index 1fdcb87..2e8ac60 100644 (file)
@@ -52,6 +52,7 @@ public:
     void SetUp() override {
     }
     void TearDown() override {
+        mApplicationMgr.clear_cache();
     }
 
     CApplicationManagerAul mApplicationMgr;
@@ -97,12 +98,9 @@ TEST_F(DefaultFixture, RetriesNoMoreThanThreeTimes) {
     ASSERT_FALSE(found);
 }
 
-/* Uncomment the below piece of code if you need your own main() */
-/*
 int main(int argc, char** argv) {
     std::cout << "Starting tests" << std::endl;
     testing::InitGoogleTest(&argc, argv);
     int ret = RUN_ALL_TESTS();
     return ret;
 }
-*/
index 991e48a..667048d 100644 (file)
@@ -2,7 +2,6 @@
 <ttpo>
     <source_files>test_main.cpp ../../../src/application_manager_aul.cpp</source_files>
     <include_directories>../../../inc/</include_directories>
-    <required_packages>capi-appfw-application</required_packages>
     <required_packages>glib-2.0</required_packages>
     <required_packages>capi-appfw-service-application</required_packages>
     <wrapper_functions>aul_app_get_appid_bypid</wrapper_functions>
index 3b599b3..c1b77ca 100644 (file)
@@ -10,13 +10,13 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 
 SET(TTPO_SRCS
     test_audio_manager.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_audio_manager.cpp
-    ../../../plugins/wakeup-manager/src/heap_tracer.cpp
+    ../../../wakeup-manager/src/wakeup_audio_manager.cpp
+    ../../../wakeup-manager/src/heap_tracer.cpp
 )
 
 SET(TTPO_PKGS
     gmock
-    capi-appfw-application
+    capi-appfw-service-application
     glib-2.0
     dlog
     ecore
@@ -26,7 +26,7 @@ SET(TTPO_PKGS
 
 SET(TTPO_INCLUDES
     ../../../inc/
-    ../../../plugins/wakeup-manager/inc/
+    ../../../wakeup-manager/inc/
 )
 
 SET(TTPO_CFLAGS
@@ -81,4 +81,4 @@ SET_TARGET_PROPERTIES(${TTPO_EXECUTABLE} PROPERTIES
 ADD_TEST(NAME ${TTPO_EXECUTABLE} COMMAND ${TTPO_EXECUTABLE})
 
 # REPLACE THE TARGET INSTALL DESTINATION AS NEEDED (default : bin)
-INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
\ No newline at end of file
+INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
index ed114d9..9d93fa9 100644 (file)
@@ -19,7 +19,7 @@ SET(TEST_SOURCES
 # Find Packages
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED
-       capi-appfw-application
+       capi-appfw-service-application
        capi-appfw-preference
        multi-assistant
        dlog
index 1900dcc..a6745a7 100644 (file)
@@ -32,6 +32,7 @@ public:
        bool launch_app_async(const std::string& appid, bool background) override { return true; }
        boost::optional<std::string> get_appid_by_pid(pid_t pid) override { return boost::optional<std::string>{}; }
        boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override { return boost::optional<pid_t>{-1}; };
+       void clear_cache() {}
 };
 
 class StorageWithNoClient : public testing::Test
@@ -46,6 +47,7 @@ public:
        }
        void TearDown() override {
        }
+       const std::string sender{"Sender"};
        CClientManager client_manager;
        CDummyApplicationManager application_manager;
 };
@@ -54,7 +56,7 @@ TEST_F(StorageWithNoClient, HasOneClientAfterCreate) {
        const std::string arbitrary_client_appid{"Client1"};
        const pid_t arbitrary_client_pid{1};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
 
        int client_num = client_manager.get_client_num();
 
@@ -65,7 +67,7 @@ TEST_F(StorageWithNoClient, ValidityReturnsTrueForCreatedClient) {
        const std::string arbitrary_client_appid{"Client1"};
        const pid_t arbitrary_client_pid{1};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
 
        bool validity = client_manager.check_client_validity_by_appid(arbitrary_client_appid);
 
@@ -78,7 +80,7 @@ TEST_F(StorageWithNoClient, ValidityReturnsFalseForNotCreatedClient) {
 
        const std::string noexist_client_appid{"Client987654321"};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
 
        bool validity = client_manager.check_client_validity_by_appid(noexist_client_appid);
 
@@ -93,10 +95,11 @@ public:
        }
        void SetUp() override {
                client_manager.set_application_manager(&application_manager);
-               client_manager.create_client(preloaded_client_pid_1, preloaded_client_appid_1);
+               client_manager.create_client(preloaded_client_pid_1, preloaded_client_appid_1, sender);
        }
        void TearDown() override {
        }
+       const std::string sender{"Sender"};
        const std::string preloaded_client_appid_1{"Client1"};
        const pid_t preloaded_client_pid_1{1};
        CClientManager client_manager;
@@ -107,7 +110,7 @@ TEST_F(StorageWithOneClient, ReturnsExistingPIDByIndex) {
        const std::string arbitrary_client_appid{"Client2"};
        const pid_t arbitrary_client_pid{2};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
 
        pid_t pid = client_manager.find_client_pid_by_index(0);
 
@@ -118,7 +121,7 @@ TEST_F(StorageWithOneClient, ReturnsCreatedPIDByIndex) {
        const std::string arbitrary_client_appid{"Client2"};
        const pid_t arbitrary_client_pid{2};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
 
        pid_t pid = client_manager.find_client_pid_by_index(1);
 
@@ -129,7 +132,7 @@ TEST_F(StorageWithOneClient, PreservesExistingItemNotRequestedForRemoval) {
        const std::string arbitrary_client_appid{"Client2"};
        const pid_t arbitrary_client_pid{2};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
        client_manager.destroy_client_by_pid(arbitrary_client_pid);
 
        pid_t pid = client_manager.find_client_pid_by_index(0);
@@ -141,7 +144,7 @@ TEST_F(StorageWithOneClient, PreservesCreatedItemNotRequestedForRemoval) {
        const std::string arbitrary_client_appid{"Client2"};
        const pid_t arbitrary_client_pid{2};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
        client_manager.destroy_client_by_pid(preloaded_client_pid_1);
 
        pid_t pid = client_manager.find_client_pid_by_index(0);
@@ -153,7 +156,7 @@ TEST_F(StorageWithOneClient, ReturnsCorrectExistingPIDByAppID) {
        const std::string arbitrary_client_appid{"Client2"};
        const pid_t arbitrary_client_pid{2};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
 
        pid_t pid = client_manager.find_client_pid_by_appid(preloaded_client_appid_1);
 
@@ -164,7 +167,7 @@ TEST_F(StorageWithOneClient, ReturnsCorrectCreatedPIDByAppID) {
        const std::string arbitrary_client_appid{"Client2"};
        const pid_t arbitrary_client_pid{2};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
 
        pid_t pid = client_manager.find_client_pid_by_appid(arbitrary_client_appid);
 
@@ -175,7 +178,7 @@ TEST_F(StorageWithOneClient, ReturnsCorrectExistingAppIDByPID) {
        const std::string arbitrary_client_appid{"Client2"};
        const pid_t arbitrary_client_pid{2};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
 
        std::string appid = client_manager.find_client_appid_by_pid(preloaded_client_pid_1);
 
@@ -186,7 +189,7 @@ TEST_F(StorageWithOneClient, ReturnsCorrectCreatedPIDAppIDByPID) {
        const std::string arbitrary_client_appid{"Client2"};
        const int arbitrary_client_pid{2};
 
-       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+       client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
 
        std::string appid = client_manager.find_client_appid_by_pid(arbitrary_client_pid);
 
index f874261..c10970e 100644 (file)
@@ -19,11 +19,12 @@ SET(TEST_SOURCES
 # Find Packages
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED
-       capi-appfw-application
+       capi-appfw-service-application
        capi-appfw-preference
        multi-assistant
        dlog
        libxml-2.0
+       libtzplatform-config
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index 00b6805..453eb59 100644 (file)
@@ -27,14 +27,14 @@ public:
        virtual ~StorageWithEmptyWakeWord() {
        }
        void SetUp() override {
-               memset(wakeup_word_storage, 0x0, sizeof(wakeup_word_storage));
-               memset(wakeup_language_storage, 0x0, sizeof(wakeup_language_storage));
+               wakeup_word_storage.clear();
+               wakeup_language_storage.clear();
        }
        void TearDown() override {
        }
        CServiceConfig config;
-       char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
-       char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
+       std::vector<std::string> wakeup_word_storage;
+       std::vector<std::string> wakeup_language_storage;
 };
 
 class StorageWithAnArbitraryWakeWord : public testing::Test {
@@ -44,8 +44,8 @@ public:
        virtual ~StorageWithAnArbitraryWakeWord() {
        }
        void SetUp() override {
-               memset(wakeup_word_storage, 0x0, sizeof(wakeup_word_storage));
-               memset(wakeup_language_storage, 0x0, sizeof(wakeup_language_storage));
+               wakeup_word_storage.clear();
+               wakeup_language_storage.clear();
 
                config.add_custom_wake_word(
                        preloaded_wake_word.c_str(), preloaded_language.c_str(),
@@ -57,8 +57,8 @@ public:
        const std::string preloaded_wake_word{"Hi Preloaded"};
        const std::string preloaded_language{"pr_LD"};
        CServiceConfig config;
-       char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
-       char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
+       std::vector<std::string> wakeup_word_storage;
+       std::vector<std::string> wakeup_language_storage;
 };
 
 TEST_F(StorageWithEmptyWakeWord, HasOneWakeWordAfterAdd) {
index d0b7199..ecc21c0 100644 (file)
@@ -1,50 +1,86 @@
+# THIS FILE WAS GENERATED BY THE TIZEN TDD-PROJECT OUTLINER.
+# IT IS NOT RECOMMENDED TO MODIFY THIS FILE SINCE THE
+# MODIFICATION CAN BE OVERWRITTEN BY THE GENERATION TOOL.
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(ttpo-project CXX C)
+
 LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wno-unused-function -Wno-sign-compare")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++11")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(TTPO_SRCS
+    test_package_update_monitor.cpp
+    ../../../src/package_update_monitor.cpp
+    pkgmgrinfo_mock.cpp
+)
+
+SET(TTPO_PKGS
+    dlog
+    pkgmgr-info
+    capi-appfw-package-manager
+)
+
+SET(TTPO_INCLUDES
+    ../../../inc/
+)
 
-ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"")
+SET(TTPO_CFLAGS
+    -DWRAP_APP_PATH_PREFIX=..
+)
+
+SET(TTPO_WRAPPERS
+    "-Wl,\
+--wrap=pkgmgrinfo_pkginfo_get_pkginfo,\
+--wrap=pkgmgrinfo_pkginfo_destroy_pkginfo,\
+--wrap=pkgmgrinfo_appinfo_get_list,\
+--wrap=pkgmgrinfo_appinfo_get_metadata_value,\
+--wrap=pkgmgrinfo_appinfo_get_appid"
+)
 
-SET(TEST_SOURCES
-       test_package_update_monitor.cpp
-       ${CMAKE_SOURCE_DIR}/src/package_update_monitor.cpp
+SET(TTPO_LDFLAGS
 )
 
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Og")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TTPO_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TTPO_CFLAGS}")
+SET(EXTRA_LDFLAGS "${TTPO_LDFLAGS}")
+
 # Find Packages
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED
-       capi-appfw-application
-       capi-appfw-package-manager
-       multi-assistant
-       dlog
-       pkgmgr-info
+    ${TTPO_PKGS}
 )
 
+INCLUDE_DIRECTORIES(${TTPO_INCLUDES})
+
 FOREACH(flag ${pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
 ENDFOREACH(flag)
 
 FIND_PACKAGE(GTest REQUIRED)
 INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
 LINK_DIRECTORIES(${GTEST_LIBRARY_DIRS})
 
-SET(TEST_PACKAGE_MANAGER test-package-update-monitor)
-ADD_EXECUTABLE(${TEST_PACKAGE_MANAGER}
-       ${TEST_SOURCES}
-       )
-
-TARGET_LINK_LIBRARIES(${TEST_PACKAGE_MANAGER} -ldl ${GTEST_LIBRARIES} pthread
-       ${EXTRA_LDFLAGS} ${pkgs_LDFLAGS})
+SET(TTPO_EXECUTABLE test-package-update-monitor)
+ADD_EXECUTABLE(
+    ${TTPO_EXECUTABLE}
+    ${TTPO_SRCS}
+)
 
-SET_TARGET_PROPERTIES(${TEST_PACKAGE_MANAGER} PROPERTIES
-       COMPILE_FLAGS "-fPIE")
+TARGET_LINK_LIBRARIES(${TTPO_EXECUTABLE} ${pkgs_LDFLAGS})
+if(NOT "${EXTRA_LDFLAGS}" STREQUAL " ")
+    TARGET_LINK_LIBRARIES(${TTPO_EXECUTABLE} ${EXTRA_LDFLAGS})
+endif()
+TARGET_LINK_LIBRARIES(${TTPO_EXECUTABLE} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
 
-INSTALL(TARGETS ${TEST_PACKAGE_MANAGER} DESTINATION bin)
+SET_TARGET_PROPERTIES(${TTPO_EXECUTABLE} PROPERTIES
+       COMPILE_FLAGS "-fPIE"
+       LINK_FLAGS "${TTPO_WRAPPERS}")
+ADD_TEST(NAME ${TTPO_EXECUTABLE} COMMAND ${TTPO_EXECUTABLE})
 
-ADD_TEST(NAME ${TEST_PACKAGE_MANAGER} COMMAND ${TEST_PACKAGE_MANAGER})
+INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
diff --git a/tests/utc/package-update-monitor/pkgmgrinfo_mock.cpp b/tests/utc/package-update-monitor/pkgmgrinfo_mock.cpp
new file mode 100644 (file)
index 0000000..9ead2cb
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2020 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "pkgmgrinfo_mock.h"
+
+#include <string>
+
+static std::string g_voice_assistant_package;
+static std::string g_wakeup_engine_package;
+static std::string g_non_monitoring_app_package;
+
+int pkgmgrinfo_mock_set_voice_assistant_package(const char *package)
+{
+    if (package) g_voice_assistant_package = package;
+    return 0;
+}
+
+int pkgmgrinfo_mock_set_wakeup_engine_package(const char *package)
+{
+    if (package) g_wakeup_engine_package = package;
+    return 0;
+}
+
+int pkgmgrinfo_mock_set_non_monitoring_app_package(const char *package)
+{
+    if (package) g_non_monitoring_app_package = package;
+    return 0;
+}
+
+int __wrap_pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
+{
+    if (!pkgid) return -1;
+    if (g_voice_assistant_package.compare(pkgid) == 0) {
+        *handle = (pkgmgrinfo_pkginfo_h)(g_voice_assistant_package.c_str());
+        return 0;
+    }
+    if (g_wakeup_engine_package.compare(pkgid) == 0) {
+        *handle = (pkgmgrinfo_pkginfo_h)(g_wakeup_engine_package.c_str());
+        return 0;
+    }
+    if (g_non_monitoring_app_package.compare(pkgid) == 0) {
+        *handle = (pkgmgrinfo_pkginfo_h)(g_non_monitoring_app_package.c_str());
+        return 0;
+    }
+    return -1;
+}
+
+int __wrap_pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
+                                                      pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
+{
+    app_func((pkgmgrinfo_appinfo_h)handle, user_data);
+    return 0;
+}
+
+int __wrap_pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
+{
+    if (handle == g_voice_assistant_package.c_str()) {
+        *metadata_value = (char*)g_voice_assistant_package.c_str();
+        return 0;
+    }
+    return -1;
+}
+
+int __wrap_pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
+{
+    (*appid) = (char*)handle;
+    return 0;
+}
+
+int __wrap_pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_appinfo_h handle)
+{
+    return 0;
+}
\ No newline at end of file
diff --git a/tests/utc/package-update-monitor/pkgmgrinfo_mock.h b/tests/utc/package-update-monitor/pkgmgrinfo_mock.h
new file mode 100644 (file)
index 0000000..637ed79
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2020 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#ifndef PKGMGRINFO_MOCK_H
+#define PKGMGRINFO_MOCK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <pkgmgr-info.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+EXPORT_API int pkgmgrinfo_mock_set_voice_assistant_package(const char *package);
+EXPORT_API int pkgmgrinfo_mock_set_wakeup_engine_package(const char *package);
+EXPORT_API int pkgmgrinfo_mock_set_non_monitoring_app_package(const char *package);
+
+EXPORT_API int __wrap_pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle);
+EXPORT_API int __wrap_pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
+                                                  pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid);
+EXPORT_API int __wrap_pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value);
+EXPORT_API int __wrap_pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid);
+EXPORT_API int __wrap_pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_appinfo_h handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 6ded7dc..ca7e83f 100644 (file)
@@ -19,6 +19,7 @@
 #include <string>
 
 #include "package_update_monitor.h"
+#include "pkgmgrinfo_mock.h"
 
 enum class ObserverEvent {
        None,
@@ -27,6 +28,11 @@ enum class ObserverEvent {
        RestartRequired
 };
 
+const std::string VOICE_ASSISTANT_PACKAGE{"org.tizen.sample-assistant"};
+const std::string WAKEUP_ENGINE_PACKAGE{"wakeup-engine-default"};
+const std::string NON_EXISTING_APP_PACKAGE{"org.tizen.non-existing-app"};
+const std::string NON_MONITORING_APP_PACKAGE{"org.tizen.multi-assistant-service"};
+
 class CPackageUpdateMonitorFake : public CPackageUpdateMonitor
 {
 public:
@@ -79,6 +85,9 @@ public:
        virtual ~DefaultFixture() {
        }
        void SetUp() override {
+               pkgmgrinfo_mock_set_voice_assistant_package(VOICE_ASSISTANT_PACKAGE.c_str());
+               pkgmgrinfo_mock_set_wakeup_engine_package(WAKEUP_ENGINE_PACKAGE.c_str());
+               pkgmgrinfo_mock_set_non_monitoring_app_package(NON_MONITORING_APP_PACKAGE.c_str());
                monitor.initialize();
        }
        void TearDown() override {
@@ -130,8 +139,10 @@ TEST_F(DefaultFixture, UpdateStartsAndRestartsForWakeupEngineInstall) {
        observer.Reset();
        std::string wakeup_engine_appid{"wakeup-engine-default"};
 
-       clientInfo.getItems()[0].used = true;
-       strcpy(clientInfo.getItems()[0].wakeup_engine[0], wakeup_engine_appid.c_str());
+       ClientInfoItems info;
+       info.used = true;
+       info.wakeup_engine.push_back(wakeup_engine_appid);
+       clientInfo.getItems().push_back(info);
 
        monitor.GenerateFakeInstallPackageEvent(wakeup_engine_appid);
 
@@ -178,8 +189,10 @@ TEST_F(DefaultFixture, UpdateStartsAndRestartsForWakeupEngineUpdate) {
        observer.Reset();
        std::string wakeup_engine_appid{"wakeup-engine-default"};
 
-       clientInfo.getItems()[0].used = true;
-       strcpy(clientInfo.getItems()[0].wakeup_engine[0], wakeup_engine_appid.c_str());
+       ClientInfoItems info;
+       info.used = true;
+       info.wakeup_engine.push_back(wakeup_engine_appid);
+       clientInfo.getItems().push_back(info);
 
        monitor.GenerateFakeUpdatePackageEvent(wakeup_engine_appid);
 
index 96c7491..4abb722 100644 (file)
@@ -20,7 +20,7 @@ SET(TEST_SOURCES
 # Find Packages
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED
-       capi-appfw-application
+       capi-appfw-service-application
        capi-appfw-preference
        multi-assistant
        dlog
index 1bf4890..34ce029 100644 (file)
@@ -1,6 +1,7 @@
 LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}
        ${CMAKE_SOURCE_DIR}/inc/
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/inc/
        )
 
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror")
@@ -22,13 +23,25 @@ SET(TEST_SOURCES
        ${CMAKE_SOURCE_DIR}/src/service_plugin.cpp
        ${CMAKE_SOURCE_DIR}/src/service_config.cpp
        ${CMAKE_SOURCE_DIR}/src/client_manager.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_manager_wrapper.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/dependency_resolver.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/assistant_config_manager.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/heap_tracer.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_audio_manager.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_engine_manager.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_manager.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_manager_wrapper.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_policy.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_policy_default.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_policy_external.cpp
+       ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_settings.cpp
 )
 
 # Find Packages
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED
-       capi-appfw-application
        capi-appfw-preference
+       libtzplatform-config
        capi-appfw-package-manager
        capi-appfw-service-application
        capi-message-port
@@ -37,6 +50,9 @@ pkg_check_modules(pkgs REQUIRED
        libxml-2.0
        ecore
        pkgmgr-info
+       jsoncpp
+       capi-media-audio-io
+       capi-media-sound-manager
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index 807e52b..7f9262e 100644 (file)
@@ -43,6 +43,7 @@ public:
        }
        boost::optional<std::string> get_appid_by_pid(pid_t pid) override { return boost::optional<std::string>{}; }
        boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override { return boost::optional<pid_t>{-1}; };
+       void clear_cache() {}
 public:
        boost::optional<std::string> launched_appid;
        boost::optional<bool> launched_option_background;
index 4075250..10dfc1d 100644 (file)
@@ -10,17 +10,17 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 
 SET(TTPO_SRCS
     test_main.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_manager.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_audio_manager.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_engine_manager.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_settings.cpp
-    ../../../plugins/wakeup-manager/src/dependency_resolver.cpp
-    ../../../plugins/wakeup-manager/src/assistant_config_manager.cpp
-    ../../../plugins/wakeup-manager/src/heap_tracer.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_policy.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_policy_default.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_policy_external.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp
+    ../../../wakeup-manager/src/wakeup_manager.cpp
+    ../../../wakeup-manager/src/wakeup_audio_manager.cpp
+    ../../../wakeup-manager/src/wakeup_engine_manager.cpp
+    ../../../wakeup-manager/src/wakeup_settings.cpp
+    ../../../wakeup-manager/src/dependency_resolver.cpp
+    ../../../wakeup-manager/src/assistant_config_manager.cpp
+    ../../../wakeup-manager/src/heap_tracer.cpp
+    ../../../wakeup-manager/src/wakeup_policy.cpp
+    ../../../wakeup-manager/src/wakeup_policy_default.cpp
+    ../../../wakeup-manager/src/wakeup_policy_external.cpp
+    ../../../wakeup-manager/src/wakeup_manager_wrapper.cpp
 )
 
 SET(TTPO_PKGS
@@ -28,34 +28,41 @@ SET(TTPO_PKGS
     dlog
     ecore
     vconf
+    jsoncpp
     pkgmgr-info
     capi-media-audio-io
-    capi-appfw-application
+    capi-appfw-service-application
     capi-appfw-preference
+    libtzplatform-config
 )
 
 SET(TTPO_INCLUDES
     ../../../inc//
-    ../../../plugins/wakeup-manager/inc//
+    ../../../wakeup-manager/inc//
 )
 
 SET(TTPO_CFLAGS
-    -Wno-format-truncation
+    -DWRAP_APP_PATH_PREFIX=..
 )
 
 SET(TTPO_WRAPPERS
     "-Wl,\
---wrap=ecore_main_loop_thread_safe_call_async"
+--wrap=ecore_main_loop_thread_safe_call_async,\
+--wrap=sound_manager_add_focus_state_watch_cb,\
+--wrap=sound_manager_remove_focus_state_watch_cb,\
+--wrap=sound_manager_get_current_recording_focus"
 )
 
 SET(TTPO_LDFLAGS
 )
 
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++14")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -O0")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Og")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TTPO_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TTPO_CFLAGS}")
 SET(EXTRA_LDFLAGS "${TTPO_LDFLAGS}")
 
 # Find Packages
@@ -68,6 +75,7 @@ INCLUDE_DIRECTORIES(${TTPO_INCLUDES})
 
 FOREACH(flag ${pkgs_CFLAGS})
     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
 ENDFOREACH(flag)
 
 FIND_PACKAGE(GTest REQUIRED)
@@ -91,5 +99,4 @@ SET_TARGET_PROPERTIES(${TTPO_EXECUTABLE} PROPERTIES
        LINK_FLAGS "${TTPO_WRAPPERS}")
 ADD_TEST(NAME ${TTPO_EXECUTABLE} COMMAND ${TTPO_EXECUTABLE})
 
-# REPLACE THE TARGET INSTALL DESTINATION AS NEEDED (default : bin)
-INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
\ No newline at end of file
+INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
index 46b38f2..d0883a6 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "wakeup_manager.h"
 
+#include <sound_manager.h>
+
 using namespace multiassistant::wakeup;
 
 extern "C" {
@@ -20,6 +22,18 @@ int __wrap_vconf_get_int(const char *in_key, int *intval)
 }
 */
 void __wrap_ecore_main_loop_thread_safe_call_async(Ecore_Cb callback, void *data) {}
+int __wrap_sound_manager_add_focus_state_watch_cb(sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_watch_cb callback, void *user_data, int *id)
+{
+    return 0;
+}
+int __wrap_sound_manager_remove_focus_state_watch_cb(int id)
+{
+    return 0;
+}
+int __wrap_sound_manager_get_current_recording_focus(sound_stream_focus_change_reason_e *acquired_by, int *sound_behavior, char **extra_info)
+{
+    return -1;
+}
 
 }
 
@@ -50,14 +64,17 @@ class CMockSettingValueObserver : public ISettingValueObserver
 {
 public:
     MOCK_METHOD(void, on_value_changed, (), (override));
+    MOCK_METHOD(void, on_loaded_wakeup_engine_changed, (), (override));
 };
 
 class DefaultFixture : public testing::Test
 {
 public:
     DefaultFixture() {
+        ecore_init();
     }
     virtual ~DefaultFixture() {
+        ecore_shutdown();
     }
     void SetUp() override {
         mWakeupManager.initialize();
@@ -265,12 +282,9 @@ TEST_F(DefaultFixture, FinishAudioDataReceivedOnResultBeforeReleasingWithoutInte
     ASSERT_EQ(mWakeupEventObserver.mFinishedReceived.load(), 1);
 }
 
-/* Uncomment the below piece of code if you need your own main() */
-/*
 int main(int argc, char** argv) {
     std::cout << "Starting tests" << std::endl;
     testing::InitGoogleTest(&argc, argv);
     int ret = RUN_ALL_TESTS();
     return ret;
 }
-*/
index 85209a9..33327a5 100644 (file)
@@ -1,27 +1,32 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ttpo>
     <source_files>test_main.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/wakeup_manager.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/wakeup_audio_manager.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/wakeup_engine_manager.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/wakeup_settings.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/dependency_resolver.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/assistant_config_manager.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/heap_tracer.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/wakeup_policy.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/wakeup_policy_default.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/wakeup_policy_external.cpp</source_files>
-    <source_files>../../../plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/wakeup_manager.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/wakeup_audio_manager.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/wakeup_engine_manager.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/wakeup_settings.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/dependency_resolver.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/assistant_config_manager.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/heap_tracer.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/wakeup_policy.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/wakeup_policy_default.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/wakeup_policy_external.cpp</source_files>
+    <source_files>../../../wakeup-manager/src/wakeup_manager_wrapper.cpp</source_files>
     <include_directories>../../../inc/</include_directories>
-    <include_directories>../../../plugins/wakeup-manager/inc/</include_directories>
+    <include_directories>../../../wakeup-manager/inc/</include_directories>
     <required_packages>gmock</required_packages>
     <required_packages>dlog</required_packages>
     <required_packages>ecore</required_packages>
     <required_packages>vconf</required_packages>
+    <required_packages>jsoncpp</required_packages>
     <required_packages>pkgmgr-info</required_packages>
     <required_packages>capi-media-audio-io</required_packages>
-    <required_packages>capi-appfw-application</required_packages>
+    <required_packages>capi-appfw-service-application</required_packages>
     <required_packages>capi-appfw-preference</required_packages>
+    <required_packages>libtzplatform-config</required_packages>
     <wrapper_functions>ecore_main_loop_thread_safe_call_async</wrapper_functions>
+    <wrapper_functions>sound_manager_add_focus_state_watch_cb</wrapper_functions>
+    <wrapper_functions>sound_manager_remove_focus_state_watch_cb</wrapper_functions>
+    <wrapper_functions>sound_manager_get_current_recording_focus</wrapper_functions>
     <cflags>-Wno-format-truncation</cflags>
 </ttpo>
index e05d076..2b03835 100644 (file)
@@ -10,8 +10,8 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 
 SET(TTPO_SRCS
     test_main.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_policy.cpp
-    ../../../plugins/wakeup-manager/src/wakeup_policy_default.cpp
+    ../../../wakeup-manager/src/wakeup_policy.cpp
+    ../../../wakeup-manager/src/wakeup_policy_default.cpp
 )
 
 SET(TTPO_PKGS
@@ -20,7 +20,7 @@ SET(TTPO_PKGS
 )
 
 SET(TTPO_INCLUDES
-    ../../../plugins/wakeup-manager/inc/
+    ../../../wakeup-manager/inc/
 )
 
 SET(TTPO_CFLAGS
index c8892b5..8d572e9 100644 (file)
@@ -33,9 +33,13 @@ void __wrap_ecore_main_loop_thread_safe_call_async(Ecore_Cb callback, void *data
 
 using namespace multiassistant::wakeup;
 
+class DefaultFixture;
+
 class PolicyEventObserver : public IPolicyEventObserver
 {
+public:
        void on_wakeup(mas_wakeup_event_info wakeup_info);
+       DefaultFixture *fixture{nullptr};
 };
 
 class DefaultFixture : public testing::Test
@@ -48,6 +52,7 @@ public:
        void SetUp() override {
                eina_init();
                mWakeupAppID.clear();
+               mObserver.fixture = this;
        }
        void TearDown() override {
                eina_shutdown();
@@ -59,8 +64,7 @@ public:
 };
 
 void PolicyEventObserver::on_wakeup(mas_wakeup_event_info wakeup_info) {
-       if (wakeup_info.extra_data) {
-               DefaultFixture* fixture = (DefaultFixture*)(wakeup_info.extra_data);
+       if (fixture) {
                fixture->mWakeupAppID = wakeup_info.wakeup_appid;
                LOGD("wakeup_appid of wakeup_info : %p, %s", wakeup_info.wakeup_appid, wakeup_info.wakeup_appid);
        }
index 170bc35..03e7f1d 100644 (file)
@@ -65,6 +65,6 @@ ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} )
 # Install libraries
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${wmpkgs_LDFLAGS} -ldl ${EXTRA_LDFLAGS})
 MESSAGE("LDFLAG : ${wmpkgs_LDFLAGS}")
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/plugins/wakeup-manager/libma-wakeup-manager.so DESTINATION ${TZ_SYS_RO_SHARE}/multiassistant/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/wakeup-manager/libma-wakeup-manager.so DESTINATION ${TZ_SYS_RO_SHARE}/multiassistant/)
 
 ADD_SUBDIRECTORY(dependency-default)
index 0dd7dda..4b22438 100644 (file)
@@ -53,4 +53,4 @@ private:
 } // wakeup
 } // multiassistant
 
-#endif _ASSISTANT_CONFIG_MANAGER_H_
+#endif // _ASSISTANT_CONFIG_MANAGER_H_
index d0b8b30..57aebe3 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <dlog.h>
 #include <glib.h>
+#include <stdio.h>
 
 #ifdef  LOG_TAG
 #undef  LOG_TAG
index 1fd7761..0d6bb19 100644 (file)
@@ -1,4 +1,6 @@
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
 
 #include "wakeup_audio_manager.h"
 #include "wakeup_manager_main.h"
index 516669f..380075d 100644 (file)
@@ -806,6 +806,9 @@ static Eina_Bool streaming_duration_expired(void *data)
                        wakeup_manager->set_recording_by_voice_key(false);
                        audio_manager->clear_audio_data();
                break;
+               case STREAMING_MODE::NONE:
+                       MWR_LOGE("Streaming mode is NONE");
+               break;
        }
 
        wakeup_manager->set_streaming_mode(STREAMING_MODE::NONE);