1 /* 2 * Copyright (c) 2021 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 CLIENT_STUB_H 17 #define CLIENT_STUB_H 18 #include <cstdlib> 19 #include <cstring> 20 #include <iostream> 21 #include "gtest/gtest.h" 22 #include "log.h" 23 #include "update_client.h" 24 #include "update_helper.h" 25 26 constexpr int32_t TEST_NVALUE_TYPE_CONTEXT = 1000; 27 constexpr int32_t TEST_NVALUE_TYPE_UPGRADE = 1001; 28 constexpr int32_t TEST_NVALUE_TYPE_UPDATE_POLICY = 1002; 29 30 class TestNApiValue { 31 public: 32 TestNApiValue(int type, const void *value); ~TestNApiValue()33 ~TestNApiValue() {} 34 GetType()35 int GetType() const 36 { 37 return type_; 38 } 39 public: 40 int type_; 41 bool bValue; 42 int intValue; 43 int64_t int64Value; 44 std::string strValue; 45 }; 46 47 struct TestNApiEnv { 48 int testStage = 0; 49 bool testAsyncorPermose = true; 50 int engineType = 0; 51 bool noneClient = false; 52 OHOS::update_engine::UpdateContext clientContext; 53 OHOS::update_engine::VersionInfo pakcageInfo; 54 OHOS::update_engine::Progress progress; 55 std::string errorMsg; 56 std::string eventType; 57 // Save the applied memory and release it at last 58 std::vector<TestNApiValue*> testValueList; 59 }; 60 61 updateClient::UpdateSession *TestGetUpdateSession(); 62 void FreeAllNapiValues(); 63 #endif // CLIENT_STUB_H 64