!596 add napi mock for hitrace

Merge pull request !596 from wenlong_12/master
This commit is contained in:
openharmony_ci
2022-07-29 03:53:30 +00:00
committed by Gitee
2 changed files with 35 additions and 0 deletions
@@ -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":
@@ -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;
}