2 * Copyright (c) 2014-2015 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.
17 #include <cynara_test_commons.h>
18 #include <cynara_test_cynara_mask.h>
19 #include <cynara_test_file_operations.h>
20 #include <tests_common.h>
22 #include <cynara_test_env.h>
24 using namespace FileOperations;
26 CynaraTestEnv::CynaraTestEnv(const char *dirName)
29 m_saveDir = TMP_DIR + "/" + dirName;
30 m_dbSaveDir = m_saveDir + "/db";
31 m_pluginsSaveDir = m_saveDir + "/plugins";
34 CynaraTestEnv::~CynaraTestEnv()
38 void CynaraTestEnv::save()
42 removeDirFiles(m_dbSaveDir);
43 removeDirIfExists(m_dbSaveDir);
44 removeDirFiles(m_pluginsSaveDir);
45 removeDirIfExists(m_pluginsSaveDir);
46 removeDirIfExists(m_saveDir);
49 m_dbPresent = dirExists(CynaraTestConsts::DB_DIR);
52 copyCynaraFiles(CynaraTestConsts::DB_DIR, m_dbSaveDir);
54 makeDir(m_pluginsSaveDir);
55 copyCynaraFiles(CynaraTestConsts::SERVICE_PLUGINS_DIR, m_pluginsSaveDir);
58 void CynaraTestEnv::restore()
62 removeDirFiles(CynaraTestConsts::DB_DIR);
64 copyCynaraFiles(m_dbSaveDir, CynaraTestConsts::DB_DIR);
66 removeDirIfExists(CynaraTestConsts::DB_DIR);
68 removeDirFiles(CynaraTestConsts::SERVICE_PLUGINS_DIR);
69 copyCynaraFiles(m_pluginsSaveDir, CynaraTestConsts::SERVICE_PLUGINS_DIR);
71 removeDirFiles(m_dbSaveDir);
72 removeDirIfExists(m_dbSaveDir);
73 removeDirFiles(m_pluginsSaveDir);
74 removeDirIfExists(m_pluginsSaveDir);
75 removeDirIfExists(m_saveDir);