#include <glib-object.h>
#include <dpl/test/test_runner.h>
-TemporaryTestUser::TemporaryTestUser(std::string userName, GumUserType userType, bool offline)
- : m_uid(0)
- , m_gid(0)
- , m_userName(userName)
- , m_userType(userType)
+void TemporaryTestUser::create(void)
{
- m_guser = gum_user_create_sync (offline);
+ if (m_guser) {
+ remove();
+ };
+
+ m_guser = gum_user_create_sync (m_offline);
RUNNER_ASSERT_MSG(m_guser != nullptr, "Failed to create gumd user object");
- g_object_set(G_OBJECT(m_guser), "usertype", userType, NULL);
- g_object_set(G_OBJECT(m_guser), "username", userName.c_str(), NULL);
+ g_object_set(G_OBJECT(m_guser), "usertype", m_userType, NULL);
+ g_object_set(G_OBJECT(m_guser), "username", m_userName.c_str(), NULL);
gboolean added = gum_user_add_sync(m_guser);
RUNNER_ASSERT_MSG(added, "Failed to add user");
g_object_get(G_OBJECT(m_guser), "uid", &m_uid, NULL);
class TemporaryTestUser {
public:
- TemporaryTestUser(std::string userName, GumUserType userType, bool offline);
+ TemporaryTestUser() = delete;
+ TemporaryTestUser(std::string userName, GumUserType userType, bool offline) :
+ m_uid(0),
+ m_gid(0),
+ m_userName(userName),
+ m_userType(userType),
+ m_guser(nullptr),
+ m_offline(offline)
+ {};
~TemporaryTestUser();
void remove(void);
uid_t getUid() const {return m_uid;}
uid_t getGid() const {return m_gid;}
+ void create(void);
const std::string& getUserName() const {return m_userName;}
GumUserType getUserType() const {return m_userType;}
private:
std::string m_userName;
GumUserType m_userType;
GumUser *m_guser;
-
+ bool m_offline;
};
#endif
const std::string new_user_name = "sm_test_04a_user_name";
TemporaryTestUser testUser(new_user_name, GUM_USERTYPE_NORMAL, false);
+ testUser.create();
removeTestDirs(testUser);
createTestDirs(testUser);
const std::string new_user_name = "sm_test_04b_user_name";
TemporaryTestUser testUser(new_user_name, GUM_USERTYPE_NORMAL, false);
+ testUser.create();
removeTestDirs(testUser);
createTestDirs(testUser);
const std::string new_user_name = "sm_test_07_user_name";
std::string uid_string;
TemporaryTestUser test_user(new_user_name, GUM_USERTYPE_NORMAL, false);
+ test_user.create();
uid_string = std::to_string(static_cast<unsigned int>(test_user.getUid()));
install_app(sm_app_id, sm_pkg_id, test_user.getUid());
// gumd user add
TemporaryTestUser test_user(new_user_name, GUM_USERTYPE_NORMAL, false);
+ test_user.create();
uid_string = std::to_string(static_cast<unsigned int>(test_user.getUid()));
addUserRequest.setUid(test_user.getUid());
serviceManager.stopService();
TemporaryTestUser user(username, GUM_USERTYPE_NORMAL, true);
+ user.create();
install_app(app_id, pkg_id, user.getUid());