2 * Copyright (c) 2014-2016 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 <sm_sharing_request.h>
19 #include <dpl/test/test_runner.h>
21 namespace SecurityManagerTest {
23 SharingRequest::SharingRequest()
26 int result = security_manager_private_sharing_req_new(&m_req);
27 RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
28 "creation of new request failed. Result: " << result);
29 RUNNER_ASSERT_MSG(m_req != nullptr, "creation of new request did not allocate memory");
32 SharingRequest::~SharingRequest()
34 security_manager_private_sharing_req_free(m_req);
37 void SharingRequest::setOwnerAppId(const std::string &appId, lib_retcode expectedResult)
39 int result = security_manager_private_sharing_req_set_owner_appid(m_req, appId.c_str());
40 RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
41 "setting app id returned wrong value."
42 << " App id: " << appId << ";"
43 << " Result: " << result << ";"
44 << " Expected result: " << expectedResult);
48 void SharingRequest::setTargetAppId(const std::string &appId, lib_retcode expectedResult)
50 int result = security_manager_private_sharing_req_set_target_appid(m_req, appId.c_str());
51 RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
52 "setting app id returned wrong value."
53 << " App id: " << appId << ";"
54 << " Result: " << result << ";"
55 << " Expected result: " << expectedResult);
59 void SharingRequest::addPaths(const char **paths, size_t pathCount, lib_retcode expectedResult)
61 int result = security_manager_private_sharing_req_add_paths(m_req, paths, pathCount);
62 RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
63 "adding path returned wrong value."
64 << " Result: " << result << ";"
65 << " Expected result: " << expectedResult);
66 for (size_t i = 0; i < pathCount; i++) {
67 m_paths.push_back(paths[i]);
71 std::ostream& operator<<(std::ostream &os, const SharingRequest &request)
74 os << "app id: " << request.m_appId << "; ";
75 os << "pkg id: " << request.m_pkgId << "; ";
77 if (!request.m_paths.empty()) {
78 os << "paths: [ " << "< " << request.m_paths[0] << ">";
79 for (size_t i=1; i < request.m_paths.size(); ++i) {
80 os << "; < " << request.m_paths[i] << ">";
87 } // namespace SecurityManagerTest