• 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 NWEB_CREAT_WINDOW_H
17 #define NWEB_CREAT_WINDOW_H
18 
19 #include "nweb.h"
20 
21 #define private public
22 #include "ui/rs_surface_node.h"
23 #undef private
24 
25 namespace OHOS::NWeb {
26 NWebInitArgs GetInitArgs(void);
27 
28 class NWebMock : public NWeb {
29 public:
Resize(uint32_t width,uint32_t height)30     void Resize(uint32_t width, uint32_t height) override
31     {}
OnPause()32     void OnPause() const override
33     {}
OnContinue()34     void OnContinue() const override
35     {}
OnDestroy()36     void OnDestroy() override
37     {}
38     void OnFocus(const FocusReason& focusReason = FocusReason::FOCUS_DEFAULT) const override
39     {}
OnBlur(const BlurReason & blurReason)40     void OnBlur(const BlurReason& blurReason) const override
41     {}
42     void OnTouchPress(int32_t id, double x, double y, bool fromOverlay = false) override
43     {}
44     void OnTouchRelease(int32_t id, double x = 0, double y = 0, bool fromOverlay = false) override
45     {}
46     void OnTouchMove(int32_t id, double x, double y, bool fromOverlay = false) override
47     {}
OnTouchCancel()48     void OnTouchCancel() override
49     {}
OnNavigateBack()50     void OnNavigateBack() override
51     {}
SendKeyEvent(int32_t keyCode,int32_t keyAction)52     bool SendKeyEvent(int32_t keyCode, int32_t keyAction) override
53     {
54         return true;
55     }
SendMouseWheelEvent(double x,double y,double deltaX,double deltaY)56     void SendMouseWheelEvent(double x, double y, double deltaX, double deltaY) override
57     {}
SendMouseEvent(int x,int y,int button,int action,int count)58     void SendMouseEvent(int x, int y, int button, int action, int count) override
59     {}
Load(const std::string & url)60     int Load(const std::string& url) const override
61     {
62         return 0;
63     }
IsNavigatebackwardAllowed()64     bool IsNavigatebackwardAllowed() const override
65     {
66         return true;
67     }
IsNavigateForwardAllowed()68     bool IsNavigateForwardAllowed() const override
69     {
70         return true;
71     }
CanNavigateBackOrForward(int numSteps)72     bool CanNavigateBackOrForward(int numSteps) const override
73     {
74         return true;
75     }
NavigateBack()76     void NavigateBack() const override
77     {}
NavigateForward()78     void NavigateForward() const override
79     {}
NavigateBackOrForward(int step)80     void NavigateBackOrForward(int step) const override
81     {}
DeleteNavigateHistory()82     void DeleteNavigateHistory() override
83     {}
Reload()84     void Reload() const override
85     {}
Zoom(float zoomFactor)86     int Zoom(float zoomFactor) const override
87     {
88         return 0;
89     }
ZoomIn()90     int ZoomIn() const override
91     {
92         return 0;
93     }
ZoomOut()94     int ZoomOut() const override
95     {
96         return 0;
97     }
Stop()98     void Stop() const override
99     {}
ExecuteJavaScript(const std::string & code)100     void ExecuteJavaScript(const std::string& code) const override
101     {}
ExecuteJavaScript(const std::string & code,std::shared_ptr<NWebValueCallback<std::shared_ptr<NWebMessage>>> callback,bool extention)102     void ExecuteJavaScript(
103         const std::string& code,
104         std::shared_ptr<NWebValueCallback<std::shared_ptr<NWebMessage>>> callback,
105         bool extention) const override
106     {}
GetPreference()107     const std::shared_ptr<NWebPreference> GetPreference() const override
108     {
109         return nullptr;
110     }
GetWebId()111     unsigned int GetWebId() const override
112     {
113         return 0;
114     }
GetHitTestResult()115     HitTestResult GetHitTestResult() const override
116     {
117         HitTestResult test;
118         return test;
119     }
PutBackgroundColor(int color)120     void PutBackgroundColor(int color) const override
121     {}
InitialScale(float scale)122     void InitialScale(float scale) const override
123     {}
PutDownloadCallback(std::shared_ptr<NWebDownloadCallback> downloadListener)124     void PutDownloadCallback(
125         std::shared_ptr<NWebDownloadCallback> downloadListener) override
126     {}
PutReleaseSurfaceCallback(std::shared_ptr<NWebReleaseSurfaceCallback> releaseSurfaceListener)127     void PutReleaseSurfaceCallback(
128         std::shared_ptr<NWebReleaseSurfaceCallback> releaseSurfaceListener) override
129     {}
SetNWebHandler(std::shared_ptr<NWebHandler> handler)130     void SetNWebHandler(std::shared_ptr<NWebHandler> handler) override
131     {}
GetNWebHandler()132     const std::shared_ptr<NWebHandler> GetNWebHandler() const override
133     {
134         return nullptr;
135     }
Title()136     std::string Title() override
137     {
138         return nullptr;
139     }
PageLoadProgress()140     int PageLoadProgress() override
141     {
142         return 0;
143     }
ContentHeight()144     int ContentHeight() override
145     {
146         return 0;
147     }
Scale()148     float Scale() override
149     {
150         return 0;
151     }
Load(std::string & url,std::map<std::string,std::string> additionalHttpHeaders)152     int Load(
153         std::string& url,
154         std::map<std::string, std::string> additionalHttpHeaders) override
155     {
156         return 0;
157     }
LoadWithDataAndBaseUrl(const std::string & baseUrl,const std::string & data,const std::string & mimeType,const std::string & encoding,const std::string & historyUrl)158     int LoadWithDataAndBaseUrl(const std::string& baseUrl,
159                                         const std::string& data,
160                                         const std::string& mimeType,
161                                         const std::string& encoding,
162                                         const std::string& historyUrl) override
163     {
164         return 0;
165     }
LoadWithData(const std::string & data,const std::string & mimeType,const std::string & encoding)166     int LoadWithData(const std::string& data,
167                               const std::string& mimeType,
168                               const std::string& encoding) override
169     {
170         return 0;
171     }
RegisterArkJSfunction(const std::string & object_name,const std::vector<std::string> & method_list)172     void RegisterArkJSfunction(
173         const std::string& object_name,
174         const std::vector<std::string>& method_list) override
175     {}
UnregisterArkJSfunction(const std::string & object_name,const std::vector<std::string> & method_list)176     void UnregisterArkJSfunction(
177         const std::string& object_name,
178         const std::vector<std::string>& method_list) override
179     {}
SetNWebJavaScriptResultCallBack(std::shared_ptr<NWebJavaScriptResultCallBack> callback)180     void SetNWebJavaScriptResultCallBack(
181         std::shared_ptr<NWebJavaScriptResultCallBack> callback) override
182     {}
PutFindCallback(std::shared_ptr<NWebFindCallback> findListener)183     void PutFindCallback(
184         std::shared_ptr<NWebFindCallback> findListener) override
185     {}
FindAllAsync(const std::string & searchStr)186     void FindAllAsync(const std::string &searchStr) const override
187     {}
ClearMatches()188     void ClearMatches() const override
189     {}
FindNext(const bool forward)190     void FindNext(const bool forward) const override
191     {}
StoreWebArchive(const std::string & baseName,bool autoName,std::shared_ptr<NWebValueCallback<std::string>> callback)192     void StoreWebArchive(const std::string &baseName, bool autoName,
193         std::shared_ptr<NWebValueCallback<std::string>> callback) const override
194     {}
CreateWebMessagePorts(std::vector<std::string> & ports)195     void CreateWebMessagePorts(std::vector<std::string>& ports) override
196     {}
PostWebMessage(std::string & message,std::vector<std::string> & ports,std::string & targetUri)197     void PostWebMessage(std::string& message, std::vector<std::string>& ports, std::string& targetUri) override
198     {}
ClosePort(std::string & handle)199     void ClosePort(std::string& handle) override
200     {}
PostPortMessage(std::string & handle,std::shared_ptr<NWebMessage> data)201     void PostPortMessage(std::string& handle, std::shared_ptr<NWebMessage> data) override
202     {}
SetPortMessageCallback(std::string & handle,std::shared_ptr<NWebValueCallback<std::shared_ptr<NWebMessage>>> callback)203     void SetPortMessageCallback(std::string& handle,
204         std::shared_ptr<NWebValueCallback<std::shared_ptr<NWebMessage>>> callback) override
205     {}
SendDragEvent(const DragEvent & dragEvent)206     void SendDragEvent(const DragEvent& dragEvent) const override
207     {}
ClearSslCache()208     void ClearSslCache() override
209     {}
GetUrl()210     std::string GetUrl() const override
211     {
212         return "/data";
213     }
ClearClientAuthenticationCache()214     void ClearClientAuthenticationCache() override
215     {}
UpdateLocale(const std::string & language,const std::string & region)216     void UpdateLocale(const std::string& language, const std::string& region) override
217     {}
218 
GetOriginalUrl()219     const std::string GetOriginalUrl() const override
220     {
221         return "";
222     }
GetFavicon(const void ** data,size_t & width,size_t & height,ImageColorType & colorType,ImageAlphaType & alphaType)223     bool GetFavicon(const void** data, size_t& width, size_t& height,
224         ImageColorType& colorType, ImageAlphaType& alphaType) override
225     {
226         return false;
227     }
PutNetworkAvailable(bool available)228     void PutNetworkAvailable(bool available) override
229     {}
230 
HasImages(std::shared_ptr<NWebValueCallback<bool>> callback)231     void HasImages(std::shared_ptr<NWebValueCallback<bool>> callback) override
232     {}
233 
RemoveCache(bool include_disk_files)234     void RemoveCache(bool include_disk_files) override
235     {}
GetHistoryList()236     std::shared_ptr<NWebHistoryList> GetHistoryList() override
237     {
238         return nullptr;
239     }
SerializeWebState()240     WebState SerializeWebState() override
241     {
242         return nullptr;
243     }
RestoreWebState(WebState state)244     bool RestoreWebState(WebState state) override
245     {
246         return false;
247     }
PageUp(bool top)248     void PageUp(bool top) override
249     {}
PageDown(bool bottom)250     void PageDown(bool bottom) override
251     {}
ScrollTo(float x,float y)252     void ScrollTo(float x, float y) override
253     {}
ScrollBy(float deltaX,float deltaY)254     void ScrollBy(float deltaX, float deltaY) override
255     {}
SlideScroll(float vx,float vy)256     void SlideScroll(float vx, float vy) override
257     {}
GetCertChainDerData(std::vector<std::string> & certChainData,bool isSingleCert)258     bool GetCertChainDerData(std::vector<std::string>& certChainData, bool isSingleCert) override
259     {
260         return false;
261     }
SetScreenOffSet(double x,double y)262     void SetScreenOffSet(double x, double y) override
263     {}
SetAudioMuted(bool muted)264     void SetAudioMuted(bool muted) override
265     {}
SetShouldFrameSubmissionBeforeDraw(bool should)266     void SetShouldFrameSubmissionBeforeDraw(bool should) override
267     {}
NotifyPopupWindowResult(bool result)268     void NotifyPopupWindowResult(bool result) override
269     {}
SetAudioResumeInterval(int32_t resumeInterval)270     void SetAudioResumeInterval(int32_t resumeInterval) override
271     {}
SetAudioExclusive(bool audioExclusive)272     void SetAudioExclusive(bool audioExclusive) override
273     {}
RegisterScreenLockFunction(int32_t windowId,const SetKeepScreenOn && handle)274     void RegisterScreenLockFunction(int32_t windowId, const SetKeepScreenOn&& handle) override
275     {}
UnRegisterScreenLockFunction(int32_t windowId)276     void UnRegisterScreenLockFunction(int32_t windowId) override
277     {}
GetOrCreateDragData()278     std::shared_ptr<NWebDragData> GetOrCreateDragData() override
279     {
280         return nullptr;
281     }
282 };
283 }
284 #endif
285