tests: Add test of sound multi-theme internal API 82/296982/1
authorYunhee Seo <yuni.seo@samsung.com>
Tue, 8 Aug 2023 01:43:03 +0000 (10:43 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Tue, 8 Aug 2023 07:56:51 +0000 (16:56 +0900)
As support multi theme usage, new internal API test codes are added.

These are added to test-feedback-internal.h
- bool TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL(void);
    -> This function performs a test to get count of theme from the sound.conf.
- bool TEST_FEEDBACK_GET_SOUND_THEME_INDEX_INTERNAL(void);
    -> This function performs a test to get index of sound theme selected.
- bool TEST_FEEDBACK_SET_SOUND_THEME_INDEX_INTERNAL(void);
    -> This function performs a test to set index of sound theme, and then plays sound files from selected conf file.
       It is possible to check sound file path from FEEDBACK_TEST dlog.

Change-Id: Ia2025141db8901676d5402f7ad0e836a9944fc3e
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
tests/main.c
tests/test-feedback-internal.c
tests/test-feedback-internal.h

index b3313be..42ea7b6 100644 (file)
@@ -27,6 +27,9 @@ void test_all()
        LOG_RESULT(TEST_FEEDBACK_PLAY_SOUNDPATH_INTERNAL(), "TEST_FEEDBACK_PLAY_SOUNDPATH_INTERNAL");
        LOG_RESULT(TEST_FEEDBACK_PLAY_TYPE_INTERNAL(), "TEST_FEEDBACK_PLAY_TYPE_INTERNAL");
        LOG_RESULT(TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL(), "TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL");
+       LOG_RESULT(TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL(), "TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL");
+       LOG_RESULT(TEST_FEEDBACK_GET_SOUND_THEME_INDEX_INTERNAL(), "TEST_FEEDBACK_GET_SOUND_THEME_INDEX_INTERNAL");
+       LOG_RESULT(TEST_FEEDBACK_SET_SOUND_THEME_INDEX_INTERNAL(), "TEST_FEEDBACK_SET_SOUND_THEME_INDEX_INTERNAL");
 }
 
 void show_usage()
index 841a5ca..8968c14 100644 (file)
@@ -340,6 +340,89 @@ static void init_supported_pattern_i(feedback_type_e type, int *pattern_i)
        feedback_deinitialize();
 }
 
+static void test_get_count_of_sound_theme_internal(void)
+{
+       unsigned int count_of_theme = 0;
+
+       RESULT(feedback_get_count_of_theme_internal(FEEDBACK_TYPE_SOUND, &count_of_theme),
+               FEEDBACK_ERROR_NOT_INITIALIZED, "not initialized");
+
+       feedback_initialize();
+       RESULT(feedback_get_count_of_theme_internal(FEEDBACK_TYPE_SOUND, NULL),
+               FEEDBACK_ERROR_INVALID_PARAMETER, "invalid parameter");
+       RESULT(feedback_get_count_of_theme_internal(FEEDBACK_TYPE_VIBRATION, &count_of_theme),
+               FEEDBACK_ERROR_NOT_SUPPORTED, "not supported");
+       RESULT(feedback_get_count_of_theme_internal(FEEDBACK_TYPE_SOUND, &count_of_theme),
+               FEEDBACK_ERROR_NONE, "error none");
+       _D("Feedback type=%d count of theme=%d is get", FEEDBACK_TYPE_SOUND, count_of_theme);
+       feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL(void)
+{
+       INIT();
+       test_get_count_of_sound_theme_internal();
+       REPORT_AND_RETURN();
+}
+
+static void test_get_sound_theme_index_internal(void)
+{
+       unsigned int index_of_theme = 0;
+
+       feedback_initialize();
+       RESULT(feedback_get_theme_index_internal(FEEDBACK_TYPE_SOUND, NULL),
+               FEEDBACK_ERROR_INVALID_PARAMETER, "invalid parameter");
+       RESULT(feedback_get_theme_index_internal(FEEDBACK_TYPE_VIBRATION, &index_of_theme),
+               FEEDBACK_ERROR_NOT_SUPPORTED, "not supported");
+       RESULT(feedback_get_theme_index_internal(FEEDBACK_TYPE_SOUND, &index_of_theme),
+               FEEDBACK_ERROR_NONE, "error none");
+       _D("Feedback type=%d sound theme index=%d is get", FEEDBACK_TYPE_SOUND, index_of_theme);
+       feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_GET_SOUND_THEME_INDEX_INTERNAL(void)
+{
+       INIT();
+       test_get_sound_theme_index_internal();
+       REPORT_AND_RETURN();
+}
+
+static void test_set_sound_theme_index_internal(void)
+{
+       unsigned int count_of_theme = 0;
+       unsigned int index = 0;
+
+       feedback_initialize();
+       feedback_get_count_of_theme_internal(FEEDBACK_TYPE_SOUND, &count_of_theme);
+
+       RESULT(feedback_set_theme_index_internal(FEEDBACK_TYPE_SOUND, count_of_theme + 1),
+               FEEDBACK_ERROR_OPERATION_FAILED, "operation failed");
+
+       RESULT(feedback_set_theme_index_internal(FEEDBACK_TYPE_VIBRATION, index),
+               FEEDBACK_ERROR_NOT_SUPPORTED, "not supported");
+       if (count_of_theme > index) {
+               for (int index = 1; index <= count_of_theme; index++) {
+                       RESULT(feedback_set_theme_index_internal(FEEDBACK_TYPE_SOUND, index),
+                               FEEDBACK_ERROR_NONE, "error none");
+                       test_play_type_by_name_p();
+                       _D("Feedback type=%d sound theme index=%d is set", FEEDBACK_TYPE_SOUND, index);
+               }
+       } else if (count_of_theme == 0) {
+               RESULT(feedback_set_theme_index_internal(FEEDBACK_TYPE_SOUND, index),
+                       FEEDBACK_ERROR_NONE, "error none");
+               test_play_type_by_name_p();
+               _D("Feedback type=%d sound theme index=%d is set", FEEDBACK_TYPE_SOUND, index);
+       }
+       feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_SET_SOUND_THEME_INDEX_INTERNAL(void)
+{
+       INIT();
+       test_set_sound_theme_index_internal();
+       REPORT_AND_RETURN();
+}
+
 void TEST_INTERNAL_INIT()
 {
        init_supported_pattern(FEEDBACK_TYPE_SOUND, pattern_s);
index 1a47124..1946c9a 100644 (file)
@@ -120,6 +120,9 @@ bool TEST_FEEDBACK_PLAY_INTERNAL(void);
 bool TEST_FEEDBACK_PLAY_SOUNDPATH_INTERNAL(void);
 bool TEST_FEEDBACK_PLAY_TYPE_INTERNAL(void);
 bool TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL(void);
+bool TEST_FEEDBACK_GET_COUNT_OF_SOUND_THEME_INTERNAL(void);
+bool TEST_FEEDBACK_GET_SOUND_THEME_INDEX_INTERNAL(void);
+bool TEST_FEEDBACK_SET_SOUND_THEME_INDEX_INTERNAL(void);
 
 void TEST_INTERNAL_INIT(void);