diff --git a/runtime/main/extend/systemplugin/napi/index.js b/runtime/main/extend/systemplugin/napi/index.js index dde8e7fc..cee8d33b 100644 --- a/runtime/main/extend/systemplugin/napi/index.js +++ b/runtime/main/extend/systemplugin/napi/index.js @@ -64,6 +64,7 @@ import { mockHiAppEvent } from './ohos_hiAppEvent' import { mockHilog } from './ohos_hilog' import { mockHiSysEvent } from './ohos_hiSysEvent' import { mockHiTraceChain } from './ohos_hiTraceChain' +import { mockHiTraceMeter } from './ohos_hiTraceMeter' import { mockHidebug } from './ohos_hidebug' import { mockFaultLogger } from './ohos_faultLogger' import { mockTv } from './tv' @@ -395,6 +396,8 @@ export function mockRequireNapiFun() { return mockHidebug(); case "hiTraceChain": return mockHiTraceChain(); + case "hiTraceMeter": + return mockHiTraceMeter(); case "faultLogger": return mockFaultLogger(); case "tv": diff --git a/runtime/main/extend/systemplugin/napi/ohos_hiTraceMeter.js b/runtime/main/extend/systemplugin/napi/ohos_hiTraceMeter.js new file mode 100644 index 00000000..715acafa --- /dev/null +++ b/runtime/main/extend/systemplugin/napi/ohos_hiTraceMeter.js @@ -0,0 +1,32 @@ +/* + * 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. + */ + +export function mockHiTraceMeter() { + const hitrace = { + startTrace: function (...args) { + console.warn("HiTraceMeter.startTrace interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + finishTrace: function (...args) { + console.warn("HiTraceMeter.finishTrace interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + traceByValue: function (...args) { + console.warn("HiTraceMeter.traceByValue interface mocked in the Previewer. How this interface works on the" + + " Previewer may be different from that on a real device.") + }, + } + return hitrace; +}