2 * Copyright (c) 2011 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 * @file widget_installer.h
18 * @author Tomasz Swierczek (t.swierczek@samsung.com)
19 * @brief Class that manages widget installation for ACE tests
21 #ifndef _TESTS_ACE_WIDGET_INSTALLER_H_
22 #define _TESTS_ACE_WIDGET_INSTALLER_H_
24 #include <ace-dao-rw/AceDAO.h>
25 #include <ace-dao-ro/common_dao_types.h>
30 #define INVALID_WIDGET_HANDLE -1
32 using namespace AceDB;
34 namespace InstallerMockup {
36 class WacSecurityMock : public IWacSecurity
41 mDistributorSigned(false),
46 virtual const WidgetCertificateDataList& getCertificateList() const
51 virtual bool isRecognized() const { return mRecognized; }
52 virtual bool isDistributorSigned() const { return mDistributorSigned; }
53 virtual bool isWacSigned() const { return mWacSigned; }
54 virtual void getCertificateChainList(CertificateChainList& /*lst*/) const {}
55 virtual void getCertificateChainList(CertificateChainList& /*lst*/,
56 CertificateSource /* source */) const {}
58 WidgetCertificateDataList& getCertificateListRef()
63 void setRecognized(bool recognized) { mRecognized = recognized; }
64 void setDistributorSigned(bool distributorSigned)
66 mDistributorSigned = distributorSigned;
68 void setWacSigned(bool wacSigned) { mWacSigned = wacSigned; }
71 WidgetCertificateDataList mList;
72 // author signature verified
75 bool mDistributorSigned;
81 static WidgetHandle _registerWidget(const WidgetRegisterInfo& regInfo,
82 const IWacSecurity& sec,
85 //randomize widget handle
86 WidgetHandle handle = INVALID_WIDGET_HANDLE;
88 gettimeofday(&tv, NULL);
89 srand(time(NULL) + tv.tv_usec);
92 } while (AceDAOReadOnly::isWidgetInstalled(handle));
96 auto previous = AceDAOReadOnly::getHandleList();
99 AceDAO::registerWidgetInfo(handle, regInfo, sec.getCertificateList());
101 RUNNER_ASSERT_MSG(handle != INVALID_WIDGET_HANDLE,
102 "(called from line " << line << ")");
104 auto current = AceDAOReadOnly::getHandleList();
105 RUNNER_ASSERT_MSG(previous.size()+1 == current.size(),
106 "(called from line " << line << ")");
108 RUNNER_ASSERT_MSG(AceDAOReadOnly::isWidgetInstalled(handle),
109 "(called from line " << line << ")");
110 } catch (AceDAOReadOnly::Exception::DatabaseError) {
113 "Unexpected exception (called from line " << line << ")");
118 WidgetHandle registerWidget(AppTypes appType = AppTypes::WAC20)
121 WidgetRegisterInfo regInfo;
122 regInfo.type = appType;
123 return _registerWidget(regInfo, sec, __LINE__);
128 #endif // _TESTS_ACE_WIDGET_INSTALLER_H_