Fix to check SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE feature
[platform/core/api/system-settings.git] / tests / sst_gtest_normal_interface.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <string.h>
18 #include <glib.h>
19 #include <gtest/gtest.h>
20 #include <vconf.h>
21
22 #include "system_settings.h"
23 #include "mocks/sstt_mock.h"
24
25 extern "C" {
26 #include "sst_interface.h"
27 #include "sst.h"
28 }
29
30 #define SST_DEPRECATED_KEY ((int)SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED + 1)
31
32 TEST(SstInterfaceTest, getInterfaceOk)
33 {
34         sst_interface *iface;
35         int key = (int)SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE;
36
37         sstm_system_info_get_platform_string_setup(true);
38         sstm_system_info_get_platform_bool_setup(true);
39
40         for ( ; key < (int)SYSTEM_SETTINGS_KEY_MAX; key++) {
41                 if (key == SST_DEPRECATED_KEY) {
42                         continue;
43                 }
44                 int ret = sst_get_interface((system_settings_key_e)key, &iface);
45                 EXPECT_TRUE((SYSTEM_SETTINGS_ERROR_NONE == ret) || (SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED == ret));
46         }
47 }
48
49 TEST(SstInterfaceTest, getInterfaceERRInput)
50 {
51         sst_interface *iface;
52         int ret = sst_get_interface(SYSTEM_SETTINGS_KEY_MAX, &iface);
53         EXPECT_EQ(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER, ret);
54
55         ret = sst_get_interface((system_settings_key_e)SST_DEPRECATED_KEY, &iface);
56         EXPECT_EQ(SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER, ret);
57 }