• 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 #include "nweb_javascript_result_callback_test.h"
17 
18 #include <iostream>
19 #include "nweb_test_log.h"
20 
21 namespace OHOS::NWeb {
GetJavaScriptResult(std::vector<std::shared_ptr<NWebValue>> args,const std::string & method,const std::string & object_name)22 std::shared_ptr<NWebValue> NWebJavaScriptResultCallBackTest::GetJavaScriptResult(
23     std::vector<std::shared_ptr<NWebValue>> args, const std::string &method, const std::string &object_name)
24 {
25     TESTLOG_I("GetJavaScriptResult=%{public}s", object_name.c_str());
26     TESTLOG_I("GetJavaScriptResult=%{public}s", method.c_str());
27     std::shared_ptr<NWebValue> value = std::make_shared<NWebValue>(NWebValue::Type::NONE);
28     return value;
29 }
RegisterArkJSfunction(const std::string & objectname)30 void NWebJavaScriptResultCallBackTest::RegisterArkJSfunction(const std::string &objectname)
31 {
32     std::unique_lock<std::mutex> lk(object_mtx_);
33     if (objector_map_.find(objectname) != objector_map_.end()) {
34         return;
35     }
36     objector_map_[objectname] = "method";
37 }
UnregisterArkJSfunction(const std::string & objectname)38 void NWebJavaScriptResultCallBackTest::UnregisterArkJSfunction(const std::string &objectname)
39 {
40     std::unique_lock<std::mutex> lk(object_mtx_);
41     if (objector_map_.find(objectname) == objector_map_.end()) {
42         return;
43     }
44     objector_map_.erase(objectname);
45 }
46 }
47