1 // Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #ifndef UNIT_TESTS_WGT_SMOKE_UTILS_H_
6 #define UNIT_TESTS_WGT_SMOKE_UTILS_H_
8 #include <common/app_installer.h>
9 #include <common/pkgmgr_interface.h>
10 #include <common/step/configuration/step_fail.h>
11 #include <unit_tests/common/smoke_utils.h>
17 #include "hybrid/hybrid_installer.h"
18 #include "wgt/wgt_installer.h"
19 #include "wgt/utils/wgt_app_query_interface.h"
21 namespace smoke_test {
23 bool ValidatePackage(const std::string& pkgid,
24 const std::vector<std::string>& appids,
25 const TestParameters& params);
27 bool ValidateExternalPackage(const std::string& pkgid,
28 const std::vector<std::string>& appids,
29 const TestParameters& params);
31 bool ValidateExtendedPackage(const std::string& pkgid,
32 const std::vector<std::string>& appids,
33 const TestParameters& params);
35 extern const bf::path kSmokePackagesDirectory;
37 class WgtBackendInterface: public BackendInterface {
39 using BackendInterface::BackendInterface;
42 AppQueryInterfacePtr CreateQueryInterface() const override;
43 AppInstallerPtr CreateInstaller(
44 common_installer::PkgMgrPtr pkgmgr) const override;
45 AppInstallerPtr CreateFailExpectedInstaller(
46 common_installer::PkgMgrPtr pkgmgr, int fail_at) const override;
49 class HybridBackendInterface: public BackendInterface {
51 using BackendInterface::BackendInterface;
53 AppQueryInterfacePtr CreateQueryInterface() const override;
54 AppInstallerPtr CreateInstaller(
55 common_installer::PkgMgrPtr pkgmgr) const override;
56 AppInstallerPtr CreateFailExpectedInstaller(
57 common_installer::PkgMgrPtr pkgmgr, int fail_at) const override;
60 #ifdef OVERRIDE_STEPS_BLOCK
61 #undef OVERRIDE_STEPS_BLOCK
63 #define OVERRIDE_STEPS_BLOCK(TYPE, STEPS) \
64 void STEPS() override { \
67 AddStepAtIndex<common_installer::configuration::StepFail>(fail_at_); \
69 AddStep<common_installer::configuration::StepFail>(); \
72 class FailExpectedWgtInstaller : public wgt::WgtInstaller {
74 explicit FailExpectedWgtInstaller(
75 common_installer::PkgMgrPtr pkgmgr, int fail_at)
76 : wgt::WgtInstaller(pkgmgr), fail_at_(fail_at) { }
79 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, InstallSteps)
80 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, UpdateSteps)
81 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, UninstallSteps)
82 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ReinstallSteps)
83 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, DeltaSteps)
84 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MoveSteps)
85 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, RecoverySteps)
86 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MountInstallSteps)
87 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MountUpdateSteps)
88 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestDirectInstallSteps)
89 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestDirectUpdateSteps)
90 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestPartialInstallSteps)
91 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestPartialUpdateSteps)
92 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, PartialUninstallSteps)
93 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ReadonlyUpdateInstallSteps)
94 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ReadonlyUpdateUninstallSteps)
95 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, DisablePkgSteps)
96 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, EnablePkgSteps)
97 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MigrateExtImgSteps)
98 OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, RecoverDBSteps)
103 class FailExpectedHybridInstaller : public hybrid::HybridInstaller {
105 explicit FailExpectedHybridInstaller(
106 common_installer::PkgMgrPtr pkgmgr, int fail_at)
107 : hybrid::HybridInstaller(pkgmgr), fail_at_(fail_at) { }
110 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, InstallSteps)
111 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, UpdateSteps)
112 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, UninstallSteps)
113 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ReinstallSteps)
114 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, DeltaSteps)
115 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MoveSteps)
116 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, RecoverySteps)
117 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MountInstallSteps)
118 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MountUpdateSteps)
119 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestDirectInstallSteps)
120 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestDirectUpdateSteps)
121 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestPartialInstallSteps)
122 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestPartialUpdateSteps)
123 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, PartialUninstallSteps)
124 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ReadonlyUpdateInstallSteps)
125 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ReadonlyUpdateUninstallSteps)
126 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, DisablePkgSteps)
127 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, EnablePkgSteps)
128 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MigrateExtImgSteps)
129 OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, RecoverDBSteps)
134 #ifdef OVERRIDE_STEPS_BLOCK
135 #undef OVERRIDE_STEPS_BLOCK
137 #define OVERRIDE_STEPS_BLOCK(STEPS) \
138 void STEPS() override { \
139 wgt::WgtInstaller::STEPS(); \
140 if (crash_at_ > -1) \
141 AddStepAtIndex<StepCrash>(crash_at_, type_); \
142 else if (step_name_.size()) \
143 AddStepAfter<StepCrash>(step_name_, type_); \
145 AddStep<StepCrash>(type_); \
148 class CrashWgtInstaller : public wgt::WgtInstaller {
150 explicit CrashWgtInstaller(common_installer::PkgMgrPtr pkgmgr, int crash_at,
151 std::string step_name, CrashStepType type) :
152 wgt::WgtInstaller(pkgmgr), crash_at_(crash_at),
153 step_name_(step_name), type_(type) { }
156 OVERRIDE_STEPS_BLOCK(InstallSteps)
157 OVERRIDE_STEPS_BLOCK(UpdateSteps)
158 OVERRIDE_STEPS_BLOCK(UninstallSteps)
159 OVERRIDE_STEPS_BLOCK(ReinstallSteps)
160 OVERRIDE_STEPS_BLOCK(DeltaSteps)
161 OVERRIDE_STEPS_BLOCK(MoveSteps)
162 OVERRIDE_STEPS_BLOCK(RecoverySteps)
163 OVERRIDE_STEPS_BLOCK(MountInstallSteps)
164 OVERRIDE_STEPS_BLOCK(MountUpdateSteps)
165 OVERRIDE_STEPS_BLOCK(ManifestDirectInstallSteps)
166 OVERRIDE_STEPS_BLOCK(ManifestDirectUpdateSteps)
167 OVERRIDE_STEPS_BLOCK(ManifestPartialInstallSteps)
168 OVERRIDE_STEPS_BLOCK(ManifestPartialUpdateSteps)
169 OVERRIDE_STEPS_BLOCK(PartialUninstallSteps)
170 OVERRIDE_STEPS_BLOCK(ReadonlyUpdateInstallSteps)
171 OVERRIDE_STEPS_BLOCK(ReadonlyUpdateUninstallSteps)
172 OVERRIDE_STEPS_BLOCK(DisablePkgSteps)
173 OVERRIDE_STEPS_BLOCK(EnablePkgSteps)
174 OVERRIDE_STEPS_BLOCK(MigrateExtImgSteps)
175 OVERRIDE_STEPS_BLOCK(RecoverDBSteps)
178 std::string step_name_;
182 } // namespace smoke_test
185 #endif // UNIT_TESTS_WGT_SMOKE_UTILS_H_