• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SCRIPT_UNITTEST_H
17 #define SCRIPT_UNITTEST_H
18 
19 #include <string>
20 #include "pkg_manager.h"
21 
22 namespace Hpackage {
23 class TestScriptPkgManager : public PkgManager {
24 public:
CreatePackage(const std::string & path,const std::string & keyName,PkgInfoPtr header,std::vector<std::pair<std::string,ZipFileInfo>> & files)25     int32_t CreatePackage(const std::string &path, const std::string &keyName, PkgInfoPtr header,
26         std::vector<std::pair<std::string, ZipFileInfo>> &files) override
27     {
28         return PKG_SUCCESS;
29     }
CreatePackage(const std::string & path,const std::string & keyName,PkgInfoPtr header,std::vector<std::pair<std::string,ComponentInfo>> & files)30     int32_t CreatePackage(const std::string &path, const std::string &keyName, PkgInfoPtr header,
31         std::vector<std::pair<std::string, ComponentInfo>> &files) override
32     {
33         return PKG_SUCCESS;
34     }
CreatePackage(const std::string & path,const std::string & keyName,PkgInfoPtr header,std::vector<std::pair<std::string,Lz4FileInfo>> & files)35     int32_t CreatePackage(const std::string &path, const std::string &keyName, PkgInfoPtr header,
36         std::vector<std::pair<std::string, Lz4FileInfo>> &files) override
37     {
38         return PKG_SUCCESS;
39     }
VerifyPackage(const std::string & packagePath,const std::string & keyPath,const std::string & version,const PkgBuffer & digest,VerifyCallback cb)40     int32_t VerifyPackage(const std::string &packagePath, const std::string &keyPath,
41         const std::string &version, const PkgBuffer &digest, VerifyCallback cb) override
42     {
43         return PKG_SUCCESS;
44     }
LoadPackage(const std::string & packagePath,const std::string & keyPath,std::vector<std::string> & fileIds)45     int32_t LoadPackage(const std::string &packagePath, const std::string &keyPath,
46         std::vector<std::string> &fileIds) override
47     {
48         return PKG_SUCCESS;
49     }
VerifyOtaPackage(const std::string & packagePath)50     int32_t VerifyOtaPackage(const std::string &packagePath) override
51     {
52         return PKG_SUCCESS;
53     }
VerifyBinFile(const std::string & packagePath,const std::string & keyPath,const std::string & version,const PkgBuffer & digest)54     int32_t VerifyBinFile(const std::string &packagePath, const std::string &keyPath,
55         const std::string &version, const PkgBuffer &digest) override
56     {
57         return PKG_SUCCESS;
58     }
GetPackageInfo(const std::string & packagePath)59     const PkgInfo *GetPackageInfo(const std::string &packagePath) override
60     {
61         return nullptr;
62     }
ExtractFile(const std::string & fileId,StreamPtr output)63     int32_t ExtractFile(const std::string &fileId, StreamPtr output) override
64     {
65         return PKG_SUCCESS;
66     }
GetFileInfo(const std::string & fileId)67     const FileInfo *GetFileInfo(const std::string &fileId) override
68     {
69         return nullptr;
70     }
CreatePkgStream(StreamPtr & stream,const std::string & fileName,size_t size,int32_t type)71     int32_t CreatePkgStream(StreamPtr &stream, const std::string &fileName, size_t size,
72         int32_t type) override
73     {
74         return PKG_SUCCESS;
75     }
CreatePkgStream(StreamPtr & stream,const std::string & fileName,PkgStream::ExtractFileProcessor processor,const void * context)76     int32_t CreatePkgStream(StreamPtr &stream, const std::string &fileName,
77         PkgStream::ExtractFileProcessor processor, const void *context) override
78     {
79         return PKG_SUCCESS;
80     }
CreatePkgStream(StreamPtr & stream,const std::string & fileName,const PkgBuffer & buffer)81     int32_t CreatePkgStream(StreamPtr &stream, const std::string &fileName, const PkgBuffer &buffer) override
82     {
83         return PKG_SUCCESS;
84     }
ClosePkgStream(StreamPtr & stream)85     void ClosePkgStream(StreamPtr &stream) override { }
DecompressBuffer(FileInfoPtr info,const PkgBuffer & buffer,StreamPtr output)86     int32_t DecompressBuffer(FileInfoPtr info, const PkgBuffer &buffer, StreamPtr output) const override
87     {
88         return PKG_SUCCESS;
89     }
CompressBuffer(FileInfoPtr info,const PkgBuffer & buffer,StreamPtr output)90     int32_t CompressBuffer(FileInfoPtr info, const PkgBuffer &buffer, StreamPtr output) const override
91     {
92         return PKG_SUCCESS;
93     }
LoadPackageWithoutUnPack(const std::string & packagePath,std::vector<std::string> & fileIds)94     int32_t LoadPackageWithoutUnPack(const std::string &packagePath,
95         std::vector<std::string> &fileIds) override
96     {
97         return PKG_SUCCESS;
98     }
ParsePackage(StreamPtr stream,std::vector<std::string> & fileIds,int32_t type)99     int32_t ParsePackage(StreamPtr stream, std::vector<std::string> &fileIds, int32_t type) override
100     {
101         return PKG_SUCCESS;
102     }
SetPkgDecodeProgress(PkgDecodeProgress decodeProgress)103     void SetPkgDecodeProgress(PkgDecodeProgress decodeProgress) override {}
PostDecodeProgress(int type,size_t writeDataLen,const void * context)104     void PostDecodeProgress(int type, size_t writeDataLen, const void *context) override {}
LoadPackageWithStream(const std::string & packagePath,const std::string & keyPath,std::vector<std::string> & fileIds,uint8_t type,StreamPtr stream)105     int32_t LoadPackageWithStream(const std::string &packagePath, const std::string &keyPath,
106         std::vector<std::string> &fileIds, uint8_t type, StreamPtr stream) override
107     {
108         return PKG_SUCCESS;
109     }
CreatePkgStream(StreamPtr & stream,const std::string & fileName,Updater::RingBuffer * buffer)110     int32_t CreatePkgStream(StreamPtr &stream, const std::string &fileName, Updater::RingBuffer *buffer) override
111     {
112         return PKG_SUCCESS;
113     }
GetPkgFileStream(const std::string & fileName)114     PkgManager::StreamPtr GetPkgFileStream(const std::string &fileName) override
115     {
116         return nullptr;
117     }
RegisterPkgFileCreator(const std::string & fileType,PkgFileConstructor constructor)118     void RegisterPkgFileCreator(const std::string &fileType, PkgFileConstructor constructor) override
119     {
120         return;
121     }
ParseComponents(const std::string & packagePath,std::vector<std::string> & fileName)122     int32_t ParseComponents(const std::string &packagePath, std::vector<std::string> &fileName) override
123     {
124         return PKG_SUCCESS;
125     }
126 };
127 }
128 #endif // SCRIPT_UNITTEST_H