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 WEB_JAVASCRIPT_RESULT_CALLBACK_TEST_H 17 #define WEB_JAVASCRIPT_RESULT_CALLBACK_TEST_H 18 19 #include "nweb_javascript_result_callback.h" 20 21 #include <string> 22 #include <vector> 23 #include <memory> 24 #include <map> 25 #include <condition_variable> 26 #include "nweb_value.h" 27 28 namespace OHOS::NWeb { 29 class NWebJavaScriptResultCallBackTest : public OHOS::NWeb::NWebJavaScriptResultCallBack { 30 public: NWebJavaScriptResultCallBackTest()31 NWebJavaScriptResultCallBackTest() {} 32 ~NWebJavaScriptResultCallBackTest() = default; 33 std::shared_ptr<OHOS::NWeb::NWebValue> 34 GetJavaScriptResult(std::vector<std::shared_ptr<OHOS::NWeb::NWebValue>> args, 35 const std::string& method, 36 const std::string& objectname) override; 37 void RegisterArkJSfunction(const std::string& objectname); 38 void UnregisterArkJSfunction(const std::string& objectname); 39 private: 40 std::mutex int_mtx_; 41 using ObjectClassMap = std::map<std::string, std::string>; 42 ObjectClassMap objector_map_; 43 std::mutex object_mtx_; 44 }; 45 } 46 #endif // WEB_JAVASCRIPT_RESULT_CALLBACK_TEST_H 47