2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <gmock/gmock.h>
19 #include <gtest/gtest.h>
21 #include <system_info.h>
24 using ::testing::InitGoogleTest;
25 using ::testing::Test;
26 using ::testing::TestCase;
28 void __activated(bool activated, void *user_data) {
29 std::cout<< (activated ? "activated" : "deactivated") << std::endl;
32 static bool __check_feature_supported(char *key)
35 int ret = system_info_get_platform_bool(key, &value);
37 EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed";
38 EXPECT_EQ(true, value) << key << " feature is not supported";
46 @author SRID(abhishek.s94)
47 @reviewer HQ(jh8801.jung)
49 @description Positive, Initialize NFC manager
50 @apicovered nfc_manager_initialize
51 @passcase when nfc_manager_initialize returns NFC_ERROR_NONE
52 @failcase when nfc_manager_initialize does not return NFC_ERROR_NONE
53 @precondition __check_feature_supported must return true for nfc feature
58 g_bFeatureNfc = __check_feature_supported((char*)FEATURE_NFC);
59 ASSERT_EQ(true, g_bFeatureNfc) << FEATURE_NFC << " feature is not supported";
61 nfc_manager_set_activation_changed_cb(__activated, NULL);
62 int rv = nfc_manager_initialize();
63 EXPECT_EQ(NFC_ERROR_NONE, rv) << "Initialization failure";
68 @testcase Set_Activation_true_p
70 @author SRID(abhishek.s94)
71 @reviewer HQ(jh8801.jung)
73 @description Positive, Activate NFC manager
74 @apicovered nfc_manager_set_activation
75 @passcase when nfc_manager_set_activation returns NFC_ERROR_NONE or NFC_ERROR_ALREADY_ACTIVATED
76 @failcase when nfc_manager_set_activation does not return NFC_ERROR_NONE or NFC_ERROR_ALREADY_ACTIVATED
77 @precondition __check_feature_supported must return true for nfc feature
80 TEST(Hal_nfc, Set_Activation_true_p)
82 g_bFeatureNfc = __check_feature_supported((char*)FEATURE_NFC);
83 ASSERT_EQ(true, g_bFeatureNfc) << FEATURE_NFC << " feature is not supported";
85 int rv = nfc_manager_set_activation(true, NULL, NULL);
87 EXPECT_EQ(rv == NFC_ERROR_NONE || rv == NFC_ERROR_ALREADY_ACTIVATED, true)
88 << "Activation failure";
92 @testcase Set_Activation_false_p
94 @author SRID(abhishek.s94)
95 @reviewer HQ(jh8801.jung)
97 @description Positive, Deactivate NFC manager
98 @apicovered nfc_manager_set_activation
99 @passcase when nfc_manager_set_activation returns NFC_ERROR_NONE
100 @failcase when nfc_manager_set_activation does not return NFC_ERROR_NONE
101 @precondition __check_feature_supported must return true for nfc feature
104 TEST(Hal_nfc, Set_Activation_false_p)
106 g_bFeatureNfc = __check_feature_supported((char*)FEATURE_NFC);
107 ASSERT_EQ(true, g_bFeatureNfc) << FEATURE_NFC << " feature is not supported";
109 int rv = nfc_manager_set_activation(false, NULL, NULL);
110 EXPECT_EQ(NFC_ERROR_NONE, rv) << "Deactivation failure";
116 @author SRID(abhishek.s94)
117 @reviewer HQ(jh8801.jung)
119 @description Positive, Deinitialize NFC manager
120 @apicovered nfc_manager_deinitialize
121 @passcase when nfc_manager_deinitialize returns NFC_ERROR_NONE
122 @failcase when nfc_manager_deinitialize does not return NFC_ERROR_NONE
123 @precondition __check_feature_supported must return true for nfc feature
126 TEST(Hal_nfc, Deinit_p)
128 g_bFeatureNfc = __check_feature_supported((char*)FEATURE_NFC);
129 ASSERT_EQ(true, g_bFeatureNfc) << FEATURE_NFC << " feature is not supported";
131 int rv = nfc_manager_deinitialize();
132 EXPECT_EQ(NFC_ERROR_NONE, rv) << "De-initialization failure";
135 int main(int argc, char **argv)
139 testing::InitGoogleTest(&argc, argv);
140 } catch (const ::testing::internal::GoogleTestFailureException& ex) {
141 std::cerr << "Caught: GoogleTestFailureException& " << ex.what() << std::endl;
143 std::cerr << "Caught: unknown exception" << std::endl;
147 ret = RUN_ALL_TESTS();
148 } catch (const ::testing::internal::GoogleTestFailureException& ex) {
149 std::cerr << "Caught: GoogleTestFailureException& " << ex.what() << std::endl;
151 std::cerr << "Caught: unknown exception" << std::endl;