!2359 轻量模拟不直接包含其余模块代码

Merge pull request !2359 from ZhengJiangliang/temp_preview
This commit is contained in:
openharmony_ci 2023-03-16 03:44:22 +00:00 committed by Gitee
commit e200948c3d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 215 additions and 2 deletions

View File

@ -75,12 +75,12 @@ ohos_shared_library("previewer_window_napi") {
libs = []
sources = [
"../../../ability/ability_runtime/frameworks/native/runtime/js_runtime_utils.cpp",
"../interfaces/kits/napi/window_runtime/window_napi/js_window.cpp",
"../interfaces/kits/napi/window_runtime/window_napi/js_window_utils.cpp",
"../interfaces/kits/napi/window_runtime/window_stage_napi/js_window_stage.cpp",
# mock
"mock/ability_runtime/js_runtime_utils.cpp",
"mock/js_transition_controller.cpp",
"mock/js_window_register_manager.cpp",
"mock/permission.cpp",
@ -94,12 +94,12 @@ ohos_shared_library("previewer_window_napi") {
"mock",
"mock/ui",
"mock/transaction",
"mock/ability_runtime",
"../wm/include",
"../utils/include",
"../interfaces/innerkits/wm",
"../interfaces/innerkits/dm",
"../interfaces/kits/napi/window_runtime/window_stage_napi",
"../../../ability/ability_runtime/interfaces/inner_api/runtime/include",
"../../../../commonlibrary/c_utils/base/include",
]

View File

@ -0,0 +1,115 @@
/*
* Copyright (c) 2023 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.
*/
#include "js_runtime_utils.h"
namespace OHOS {
namespace AbilityRuntime {
NativeValue* CreateJsError(NativeEngine& engine, int32_t errCode, const std::string& message)
{
return nullptr;
}
void BindNativeFunction(NativeEngine& engine, NativeObject& object, const char* name,
const char* moduleName, NativeCallback func)
{
return;
}
AsyncTask::AsyncTask(NativeDeferred* deferred, std::unique_ptr<AsyncTask::ExecuteCallback>&& execute,
std::unique_ptr<AsyncTask::CompleteCallback>&& complete)
{
return;
}
AsyncTask::AsyncTask(NativeReference* callbackRef, std::unique_ptr<AsyncTask::ExecuteCallback>&& execute,
std::unique_ptr<AsyncTask::CompleteCallback>&& complete)
{
return;
}
AsyncTask::~AsyncTask() = default;
void AsyncTask::Schedule(const std::string &name, NativeEngine& engine, std::unique_ptr<AsyncTask>&& task)
{
return;
}
void AsyncTask::Resolve(NativeEngine& engine, NativeValue* value)
{
return;
}
void AsyncTask::ResolveWithNoError(NativeEngine& engine, NativeValue* value)
{
return;
}
void AsyncTask::Reject(NativeEngine& engine, NativeValue* error)
{
return;
}
void AsyncTask::ResolveWithCustomize(NativeEngine& engine, NativeValue* error, NativeValue* value)
{
return;
}
void AsyncTask::RejectWithCustomize(NativeEngine& engine, NativeValue* error, NativeValue* value)
{
return;
}
void AsyncTask::Execute(NativeEngine* engine, void* data)
{
return;
}
void AsyncTask::Complete(NativeEngine* engine, int32_t status, void* data)
{
return;
}
bool AsyncTask::Start(const std::string &name, NativeEngine& engine)
{
return true;
}
std::unique_ptr<AsyncTask> CreateAsyncTaskWithLastParam(NativeEngine& engine, NativeValue* lastParam,
AsyncTask::ExecuteCallback&& execute, AsyncTask::CompleteCallback&& complete, NativeValue** result)
{
return nullptr;
}
std::unique_ptr<AsyncTask> CreateAsyncTaskWithLastParam(NativeEngine& engine, NativeValue* lastParam,
AsyncTask::ExecuteCallback&& execute, nullptr_t, NativeValue** result)
{
return nullptr;
}
std::unique_ptr<AsyncTask> CreateAsyncTaskWithLastParam(NativeEngine& engine, NativeValue* lastParam,
nullptr_t, AsyncTask::CompleteCallback&& complete, NativeValue** result)
{
return nullptr;
}
std::unique_ptr<AsyncTask> CreateAsyncTaskWithLastParam(NativeEngine& engine, NativeValue* lastParam,
nullptr_t, nullptr_t, NativeValue** result)
{
return nullptr;
}
} // namespace AbilityRuntime
} // namespace OHOS

View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 2023 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 OHOS_ABILITY_RUNTIME_JS_RUNTIME_UTILS_H
#define OHOS_ABILITY_RUNTIME_JS_RUNTIME_UTILS_H
#include <cstdint>
#include "native_engine/native_engine.h"
namespace OHOS {
namespace AbilityRuntime {
template<class T>
inline T* ConvertNativeValueTo(NativeValue* value)
{
return nullptr;
}
template<class T>
inline NativeValue* CreateJsValue(NativeEngine& engine, const T& value)
{
return engine.CreateUndefined();
}
template<class T>
inline bool ConvertFromJsValue(NativeEngine& engine, NativeValue* jsValue, T& value)
{
return true;
}
template<class T>
NativeValue* CreateNativeArray(NativeEngine& engine, const std::vector<T>& data)
{
return nullptr;
}
template<class T>
T* CheckParamsAndGetThis(NativeEngine* engine, NativeCallbackInfo* info, const char* name = nullptr)
{
return nullptr;
}
NativeValue* CreateJsError(NativeEngine& engine, int32_t errCode, const std::string& message = std::string());
void BindNativeFunction(NativeEngine& engine, NativeObject& object, const char* name,
const char* moduleName, NativeCallback func);
class AsyncTask final {
public:
using ExecuteCallback = std::function<void()>;
using CompleteCallback = std::function<void(NativeEngine&, AsyncTask&, int32_t)>;
static void Schedule(const std::string& name, NativeEngine& engine, std::unique_ptr<AsyncTask>&& task);
AsyncTask(NativeDeferred* deferred, std::unique_ptr<ExecuteCallback>&& execute,
std::unique_ptr<CompleteCallback>&& complete);
AsyncTask(NativeReference* callbackRef, std::unique_ptr<ExecuteCallback>&& execute,
std::unique_ptr<CompleteCallback>&& complete);
~AsyncTask();
void Resolve(NativeEngine& engine, NativeValue* value);
void Reject(NativeEngine& engine, NativeValue* error);
void ResolveWithNoError(NativeEngine& engine, NativeValue* value);
void ResolveWithCustomize(NativeEngine& engine, NativeValue* error, NativeValue* value);
void RejectWithCustomize(NativeEngine& engine, NativeValue* error, NativeValue* value);
private:
static void Execute(NativeEngine* engine, void* data);
static void Complete(NativeEngine* engine, int32_t status, void* data);
bool Start(const std::string &name, NativeEngine& engine);
};
std::unique_ptr<AsyncTask> CreateAsyncTaskWithLastParam(NativeEngine& engine, NativeValue* lastParam,
AsyncTask::ExecuteCallback&& execute, AsyncTask::CompleteCallback&& complete, NativeValue** result);
std::unique_ptr<AsyncTask> CreateAsyncTaskWithLastParam(NativeEngine& engine, NativeValue* lastParam,
AsyncTask::ExecuteCallback&& execute, nullptr_t, NativeValue** result);
std::unique_ptr<AsyncTask> CreateAsyncTaskWithLastParam(NativeEngine& engine, NativeValue* lastParam,
nullptr_t, AsyncTask::CompleteCallback&& complete, NativeValue** result);
std::unique_ptr<AsyncTask> CreateAsyncTaskWithLastParam(NativeEngine& engine, NativeValue* lastParam,
nullptr_t, nullptr_t, NativeValue** result);
} // namespace AbilityRuntime
} // namespace OHOS
#endif // OHOS_ABILITY_RUNTIME_JS_RUNTIME_UTILS_H