--- /dev/null
+/*
+ * Copyright (c) 2014 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 <sm_api.h>
+
+#include <dpl/test/test_runner.h>
+
+namespace SecurityManagerTest {
+
+namespace Api {
+
+void install(const InstallRequest &request, lib_retcode expectedResult)
+{
+ int result = security_manager_app_install(request.get());
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "installing app returned wrong value."
+ << " InstallRequest: [ " << request << "];"
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+}
+
+void uninstall(const InstallRequest &request, lib_retcode expectedResult)
+{
+ int result = security_manager_app_uninstall(request.get());
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "uninstalling app returned wrong value."
+ << " InstallRequest: [ " << request << "];"
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+}
+
+std::string getPkgId(const char *appId, lib_retcode expectedResult)
+{
+ char *pkgId = nullptr;
+ int result = security_manager_get_app_pkgid(&pkgId, appId);
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "getting pkg id from app id returned wrong value."
+ << " App id: " << appId << ";"
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+ if (expectedResult != SECURITY_MANAGER_SUCCESS)
+ return std::string();
+
+ RUNNER_ASSERT_MSG(pkgId != nullptr, "getting pkg id did not allocate memory");
+ std::string str(pkgId);
+ free(pkgId);
+ return str;
+}
+
+void setProcessLabel(const char *appId, lib_retcode expectedResult)
+{
+ int result = security_manager_set_process_label_from_appid(appId);
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "setting process label from app id returned wrong value."
+ << " App id: " << appId << ";"
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+}
+
+void setProcessGroups(const char *appId, lib_retcode expectedResult)
+{
+ int result = security_manager_set_process_groups_from_appid(appId);
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "setting process groups from app id returned wrong value."
+ << " App id: " << appId << ";"
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+}
+
+void dropProcessPrivileges(lib_retcode expectedResult)
+{
+ int result = security_manager_drop_process_privileges();
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "dropping process privileges returned wrong value."
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+}
+
+void prepareApp(const char *appId, lib_retcode expectedResult)
+{
+ int result = security_manager_prepare_app(appId);
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "preparing app returned wrong value."
+ << " App id: " << appId << ";"
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+}
+
+} // namespace Api
+
+} // namespace SecurityManagerTest
--- /dev/null
+/*
+ * Copyright (c) 2014 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.
+ */
+
+#ifndef SECURITY_MANAGER_TEST_API
+#define SECURITY_MANAGER_TEST_API
+
+#include <sm_request.h>
+
+#include <security-manager.h>
+
+namespace SecurityManagerTest {
+
+namespace Api {
+
+void install(const InstallRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void uninstall(const InstallRequest &request, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+std::string getPkgId(const char *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void setProcessLabel(const char *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void setProcessGroups(const char *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void dropProcessPrivileges(lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+void prepareApp(const char *appId, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
+
+} // namespace Api
+
+} // namespace SecurityManagerTest
+
+#endif // SECURITY_MANAGER_TEST_API