--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ */
+
+#pragma once
+
+#include <ftw.h>
+#include <string>
+#include <sys/capability.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <vector>
+
+#include <security-manager-types.h>
+
+#include <app_install_helper.h>
+#include <memory.h>
+#include <sm_db.h>
+#include <sm_request.h>
+#include <sm_api.h>
+#include <temp_test_user.h>
+#include <synchronization_pipe.h>
+
+class ScopedInstaller {
+public:
+ ScopedInstaller(const AppInstallHelper &appInstallHelper)
+ : m_appInstallHelper(appInstallHelper)
+ {
+ SecurityManagerTest::InstallRequest instReq;
+ instReq.setAppId(m_appInstallHelper.getAppId());
+ instReq.setPkgId(m_appInstallHelper.getPkgId());
+ instReq.setUid(m_appInstallHelper.getUID());
+ instReq.setAppTizenVersion(m_appInstallHelper.getVersion());
+
+ for (const auto& typePaths : m_appInstallHelper.getDirsMap())
+ for (const auto& path : typePaths.second)
+ instReq.addPath(path, typePaths.first);
+ for (const auto& typePaths : m_appInstallHelper.getFilesMap())
+ for (const auto& path : typePaths.second)
+ instReq.addPath(path, typePaths.first);
+
+ SecurityManagerTest::Api::install(instReq);
+ }
+
+ virtual ~ScopedInstaller() {
+ uninstallApp();
+ }
+
+ void uninstallApp() {
+ SecurityManagerTest::InstallRequest uninstReq;
+ uninstReq.setAppId(m_appInstallHelper.getAppId());
+ uninstReq.setUid(m_appInstallHelper.getUID());
+
+ SecurityManagerTest::Api::uninstall(uninstReq);
+ }
+
+ AppInstallHelper& getAIH() {
+ return m_appInstallHelper;
+ }
+
+protected:
+ AppInstallHelper m_appInstallHelper;
+};
--- /dev/null
+/*
+ * Copyright (c) 2014-2016 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.
+ */
+#pragma once
+
+#include <vector>
+#include <utility>
+
+class ScopedPathRemover {
+public:
+ ScopedPathRemover(std::initializer_list<std::string> &&vec)
+ : m_dirVec(std::move(vec))
+ {}
+
+ ~ScopedPathRemover() {
+ // FIXME : Properly remove files and not empty directories
+ for (const auto &dir : m_dirVec)
+ rmdir(dir.c_str());
+ }
+
+protected:
+ std::vector<std::string> m_dirVec;
+};