/* * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef NWEB_CREAT_WINDOW_H #define NWEB_CREAT_WINDOW_H #include "nweb.h" #include "nweb_init_params.h" #define private public #include "ui/rs_surface_node.h" #undef private namespace OHOS::NWeb { std::shared_ptr GetInitArgs(void); std::shared_ptr GetNwebForTest(); class NWebMock : public NWeb { public: void Resize(uint32_t width, uint32_t height, bool isKeyboard = false) override {} void OnPause() override {} void OnContinue() override {} void OnDestroy() override {} void OnFocus(const FocusReason& focusReason = FocusReason::FOCUS_DEFAULT) override {} void OnBlur(const BlurReason& blurReason) override {} void OnTouchPress(int32_t id, double x, double y, bool fromOverlay = false) override {} void OnTouchRelease(int32_t id, double x = 0, double y = 0, bool fromOverlay = false) override {} void OnTouchMove(int32_t id, double x, double y, bool fromOverlay = false) override {} void OnTouchMove(const std::vector> &touch_point_infos, bool fromOverlay = false) override {} void OnTouchCancel() override {} void OnNavigateBack() override {} bool SendKeyEvent(int32_t keyCode, int32_t keyAction) override { return true; } void SendMouseWheelEvent(double x, double y, double deltaX, double deltaY) override {} void SendMouseEvent(int x, int y, int button, int action, int count) override {} int Load(const std::string& url) override { return 0; } bool IsNavigatebackwardAllowed() override { return true; } bool IsNavigateForwardAllowed() override { return true; } bool CanNavigateBackOrForward(int numSteps) override { return true; } void NavigateBack() override {} void NavigateForward() override {} void NavigateBackOrForward(int step) override {} void DeleteNavigateHistory() override {} void Reload() override {} int Zoom(float zoomFactor) override { return 0; } int ZoomIn() override { return 0; } int ZoomOut() override { return 0; } void Stop() override {} void ExecuteJavaScript(const std::string& code) override {} void ExecuteJavaScript( const std::string& code, std::shared_ptr callback, bool extention) override {} std::shared_ptr GetPreference() override { return nullptr; } unsigned int GetWebId() override { return 0; } std::shared_ptr GetHitTestResult() override { std::shared_ptr test; return test; } void PutBackgroundColor(int color) override {} void InitialScale(float scale) override {} void PutDownloadCallback( std::shared_ptr downloadListener) override {} void PutReleaseSurfaceCallback( std::shared_ptr releaseSurfaceListener) override {} void SetNWebHandler(std::shared_ptr handler) override {} std::string Title() override { return nullptr; } int PageLoadProgress() override { return 0; } int ContentHeight() override { return 0; } float Scale() override { return 0; } int Load( const std::string& url, const std::map &additionalHttpHeaders) override { return 0; } int LoadWithDataAndBaseUrl(const std::string& baseUrl, const std::string& data, const std::string& mimeType, const std::string& encoding, const std::string& historyUrl) override { return 0; } int LoadWithData(const std::string& data, const std::string& mimeType, const std::string& encoding) override { return 0; } void RegisterArkJSfunction( const std::string& object_name, const std::vector& method_list, const int32_t object_id) override {} void UnregisterArkJSfunction( const std::string& object_name, const std::vector& method_list) override {} void SetNWebJavaScriptResultCallBack( std::shared_ptr callback) override {} void PutFindCallback( std::shared_ptr findListener) override {} void FindAllAsync(const std::string &searchStr) override {} void ClearMatches() override {} void FindNext(const bool forward) override {} void StoreWebArchive(const std::string &baseName, bool autoName, std::shared_ptr callback) override {} std::vector CreateWebMessagePorts() override { std::vector empty; return empty; } void PostWebMessage(const std::string& message, const std::vector& ports, const std::string& targetUri) override {} void ClosePort(const std::string& handle) override {} void PostPortMessage(const std::string& handle, std::shared_ptr data) override {} void SetPortMessageCallback(const std::string& handle, std::shared_ptr callback) override {} void SendDragEvent(std::shared_ptr dragEvent) override {} void ClearSslCache() override {} std::string GetUrl() override { return "/data"; } void ClearClientAuthenticationCache() override {} void UpdateLocale(const std::string& language, const std::string& region) override {} const std::string GetOriginalUrl() override { return ""; } bool GetFavicon(const void** data, size_t& width, size_t& height, ImageColorType& colorType, ImageAlphaType& alphaType) override { return false; } void PutNetworkAvailable(bool available) override {} void HasImages(std::shared_ptr callback) override {} void RemoveCache(bool include_disk_files) override {} std::shared_ptr GetHistoryList() override { return nullptr; } std::vector SerializeWebState() override { std::vector empty; return empty; } bool RestoreWebState(const std::vector &state) override { return false; } void PageUp(bool top) override {} void PageDown(bool bottom) override {} void ScrollTo(float x, float y) override {} void ScrollBy(float deltaX, float deltaY) override {} void SlideScroll(float vx, float vy) override {} bool GetCertChainDerData(std::vector& certChainData, bool isSingleCert) override { return false; } void SetScreenOffSet(double x, double y) override {} void SetAudioMuted(bool muted) override {} void SetShouldFrameSubmissionBeforeDraw(bool should) override {} void NotifyPopupWindowResult(bool result) override {} void SetAudioResumeInterval(int32_t resumeInterval) override {} void SetAudioExclusive(bool audioExclusive) override {} void RegisterScreenLockFunction(int32_t windowId, std::shared_ptr callback) override {} void UnRegisterScreenLockFunction(int32_t windowId) override {} std::shared_ptr GetOrCreateDragData() override { return nullptr; } void SendTouchpadFlingEvent(double x, double y, double vx, double vy) override {} int SetUrlTrustList(const std::string& urlTrustList) override { return 0; } int SetUrlTrustListWithErrMsg(const std::string& urlTrustList, std::string& detailErrMsg) override { return 0; } }; } #endif