1/* 2 * Copyright (c) 2024 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#define private public 17#include "ace_ability.h" 18#include "window.h" 19#include "MockGlobalResult.h" 20 21namespace OHOS::Ace::Platform { 22AceAbility::AceAbility(const AceRunArgs& runArgs) : runArgs_(runArgs) {} 23 24AceAbility::~AceAbility() {} 25 26void AceAbility::SetMockModuleList(const std::map<std::string, std::string>& mockJsonInfo) 27{ 28 g_setMockModuleList = true; 29} 30 31void AceAbility::InitEnv() 32{ 33 g_initEnv = true; 34} 35 36void AceAbility::OnBackPressed() const 37{ 38 g_onBackPressed = true; 39} 40 41bool AceAbility::OnInputEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) const 42{ 43 g_onInputEvent = true; 44 return true; 45} 46bool AceAbility::OnInputEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) const 47{ 48 g_onInputEvent = true; 49 return true; 50} 51bool AceAbility::OnInputEvent(const std::shared_ptr<MMI::AxisEvent>& axisEvent) const 52{ 53 g_onInputEvent = true; 54 return true; 55} 56bool AceAbility::OnInputMethodEvent(const unsigned int codePoint) const 57{ 58 g_onInputMethodEvent = true; 59 return true; 60} 61 62void AceAbility::OnConfigurationChanged(const DeviceConfig& newConfig) 63{ 64 g_onConfigurationChanged = true; 65} 66 67void AceAbility::SurfaceChanged( 68 const DeviceOrientation& orientation, const double& resolution, int32_t& width, int32_t& height, 69 WindowSizeChangeReason type) 70{ 71 g_surfaceChanged = true; 72} 73 74void AceAbility::ReplacePage(const std::string& url, const std::string& params) 75{ 76 g_replacePage = true; 77} 78void AceAbility::LoadDocument(const std::string& url, const std::string& componentName, SystemParams& systemParams) 79{ 80 g_loadAceDocument = true; 81} 82 83std::string AceAbility::GetJSONTree() 84{ 85 return "jsontree"; 86} 87 88std::string AceAbility::GetDefaultJSONTree() 89{ 90 return "defaultjsontree"; 91} 92 93bool AceAbility::OperateComponent(const std::string& attrsJson) 94{ 95 g_operateComponent = true; 96 return true; 97} 98 99void AceAbility::SetWindow(sptr<OHOS::Rosen::Window> rsWindow) 100{ 101 rsWindow_ = rsWindow; 102 g_setWindow = true; 103} 104 105std::unique_ptr<AceAbility> AceAbility::CreateInstance(AceRunArgs& runArgs) 106{ 107 auto aceAbility = std::make_unique<AceAbility>(runArgs); 108 return aceAbility; 109} 110 111sptr<OHOS::Rosen::Window> AceAbility::GetWindow() 112{ 113 return rsWindow_; 114} 115}