2 * Copyright (c) 2012 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 * @file libprivilege-control_test_db.h
19 * @author Lukasz Wojciechowski (l.wojciechow@partner.samsung.com)
21 * @brief libprivilege-control tests database record check functions
24 #ifndef LIBPRIVILEGE_CONTROL_TEST_DB_H_
25 #define LIBPRIVILEGE_CONTROL_TEST_DB_H_
27 #include <privilege-control.h>
29 #include "db_sqlite.h"
32 * @class TestLibPrivilegeControlDatabase
33 * @brief Class containing methods for testing libprivlege database.
35 class TestLibPrivilegeControlDatabase
39 * @brief A constructor
41 TestLibPrivilegeControlDatabase();
46 ~TestLibPrivilegeControlDatabase() = default;
49 * @brief Method for testing database after "perm_app_install" was run.
51 * It checks existence of proper: label, app records and permission for ALL_APPS for installed app.
53 * @param tracker make assertion comments if error more useful
54 * @param name name of installed app
56 void test_db_after__perm_app_install(const Tracker& tracker, const char* name);
59 * @brief Method for testing database after "perm_app_install" was run.
61 * It checks existence of proper: label, app records and permission for ALL_APPS for installed app.
63 * @param tracker make assertion comments if error more useful
64 * @param name name of installed app
66 void test_db_after__perm_app_uninstall(const Tracker& tracker, const char* name);
69 * @brief Method for testing database after "perm_app_enable_permissions" was run.
71 * It checks existence of proper permissions from perm_list and main permission for whole app_type.
73 * @param tracker make assertion comments if error more useful
74 * @param name name of application
75 * @param app_type type of application (EFL, WRT, etc. )
76 * @param perm_list list of permission to enable
77 * @param persistent persistence or volatileness of permissions
79 void test_db_after__perm_app_enable_permissions(const Tracker& tracker, const char* name,
80 app_type_t app_type, const char** perm_list, bool persistent);
85 * @brief Sqlite3DBase object giving simple access to database
87 * Connection to database is open first time it is needed
88 * and closed in destructor of TestLibPrivilegeControlDatabase.
93 * @brief Check existence of label related records for given app.
95 * @param tracker make assertion comments if error more useful
96 * @param app_name name of application
98 void app_label(const Tracker& tracker, const std::string& app_name);
101 * @brief Check absence of label record for given app.
103 * @param tracker make assertion comments if error more useful
104 * @param app_name name of application
106 void app_not_label(const Tracker& tracker, const std::string& app_name);
109 * @brief It checks existence of single permission.
110 * @param tracker make assertion comments if error more useful
111 * @param app_name name of application
112 * @param permission_name name of permission
113 * @param permission_type_name name of permission type
114 * @param is_volatile persistence or volatileness of permissions
115 * @param is_enabled permission enable flag
117 void app_permission(const Tracker& tracker, const std::string& app_name,
118 const std::string& permission_name, const std::string& permission_type_name,
119 int is_volatile, int is_enabled);
122 #endif /* LIBPRIVILEGE_CONTROL_TEST_DB_H_ */