ByTraceHiDebugJsunit.test.ets 5.8 KB
Newer Older
J
jiyong_sd 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
// @ts-nocheck
/**
 * Copyright (c) 2021 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.
 */
import {describe, it, expect} from "hypium/index";
import byTrace from '@ohos.bytrace'
import hiAppEvent from '@ohos.hiAppEvent'
import hiDebug from '@ohos.hidebug'
import hiLog from '@ohos.hilog'

export default function byTraceHiDebugJsunit() {
  describe('byTraceHiDebugTest', function () {
    console.log("************* byTraceHiDebug Test start*************");

    /*
     * @tc.number    : DFX_HiAppEvent_Event_DISTRIBUTED_SERVICE_START_0100
     * @tc.name      : DISTRIBUTED_SERVICE_START
     * @tc.desc      : distributed service event.
     */
    it('DFX_HiAppEvent_Event_DISTRIBUTED_SERVICE_START_0100', 0, async function (done) {
      console.log("************* DFX_HiAppEvent_Event_DISTRIBUTED_SERVICE_START_0100 Test start*************");
      try {
        expect('hiappevent.distributed_service_start').assertEqual(hiAppEvent.Event.DISTRIBUTED_SERVICE_START);
      } catch (error) {
        expect().assertFail();
      }
      console.log("************* DFX_HiAppEvent_Event_DISTRIBUTED_SERVICE_START_0100 Test end*************");
      done();
    });

    /*
     * @tc.number    : DFX_HiLog_HiLog_info_0100
     * @tc.name      : info
     * @tc.desc      : Outputs info-level logs.
     */
    it('DFX_HiLog_HiLog_info_0100', 0, async function (done) {
      console.log("************* DFX_HiLog_HiLog_info_0100 Test start*************");
      try {
        hiLog.info(0xFFFF1, "HILOGTEST", "%{public}s", 'DFX_HiLog_HiLog_info_0100')
        expect(true).assertTrue();
      } catch (error) {
        expect().assertFail();
      }
      console.log("************* DFX_HiLog_HiLog_info_0100 Test end*************");
      done();
    });

    /*
     * @tc.number    : DFX_HiLog_HiLog_error_0100
     * @tc.name      : error
     * @tc.desc      : Outputs error-level logs.
     */
    it('DFX_HiLog_HiLog_error_0100', 0, async function (done) {
      console.log("************* DFX_HiLog_HiLog_error_0100 Test start*************");
      try {
        hiLog.error(0xFFFF2, "HILOGTEST", "%{public}s", 'DFX_HiLog_HiLog_error_0100')
        expect(true).assertTrue();
      } catch (error) {
        expect().assertFail();
      }
      console.log("************* DFX_HiLog_HiLog_error_0100 Test end*************");
      done();
    });

    /*
     * @tc.number    : DFX_HiLog_HiLog_fatal_0100
     * @tc.name      : fatal
     * @tc.desc      : Outputs fatal-level logs.
     */
    it('DFX_HiLog_HiLog_fatal_0100', 0, async function (done) {
      console.log("************* DFX_HiLog_HiLog_fatal_0100 Test start*************");
      try {
        hiLog.fatal(0xFFFF3, "HILOGTEST", "%{public}s", 'DFX_HiLog_HiLog_fatal_0100')
        expect(true).assertTrue();
      } catch (error) {
        expect().assertFail();
      }
      console.log("************* DFX_HiLog_HiLog_fatal_0100 Test end*************");
      done();
    });

    /*
     * @tc.number    : DFX_HiLog_HiLog_isLoggable_0100
     * @tc.name      : isLoggable
     * @tc.desc      : Checks whether logs of the specified tag, and level can be printed.
     */
    it('DFX_HiLog_HiLog_isLoggable_0100', 0, async function (done) {
      console.log("************* DFX_HiLog_HiLog_isLoggable_0100 Test start*************");
      try {
        const res = hiLog.isLoggable(0xD000700, "HILOGTEST", 3)
C
chenxuihui 已提交
102
        expect(res).assertEqual(false);
J
jiyong_sd 已提交
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
      } catch (error) {
        expect().assertFail();
      }
      console.log("************* DFX_HiLog_HiLog_isLoggable_0100 Test end*************");
      done();
    });

    /*
     * @tc.number    : DFX_HiLog_LogLevel_WARN_0100
     * @tc.name      : WARN
     * @tc.desc      : enum test
     */
    it('DFX_HiLog_LogLevel_WARN_0100', 0, async function (done) {
      console.log("************* DFX_HiLog_LogLevel_WARN_0100 Test start*************");
      try {
        expect(5).assertEqual(hiLog.LogLevel.WARN);
      } catch (error) {
        expect().assertFail();
      }
      console.log("************* DFX_HiLog_LogLevel_WARN_0100 Test end*************");
      done();
    });

    /*
     * @tc.number    : DFX_HiLog_LogLevel_ERROR_0100
     * @tc.name      : ERROR
     * @tc.desc      : enum test
     */
    it('DFX_HiLog_LogLevel_ERROR_0100', 0, async function (done) {
      console.log("************* DFX_HiLog_LogLevel_ERROR_0100 Test start*************");
      try {
        expect(6).assertEqual(hiLog.LogLevel.ERROR);
      } catch (error) {
        expect().assertFail();
      }
      console.log("************* DFX_HiLog_LogLevel_ERROR_0100 Test end*************");
      done();
    });

    /*
     * @tc.number    : DFX_HiLog_LogLevel_FATAL_0100
     * @tc.name      : FATAL
     * @tc.desc      : enum test
     */
    it('DFX_HiLog_LogLevel_FATAL_0100', 0, async function (done) {
      console.log("************* DFX_HiLog_LogLevel_FATAL_0100 Test start*************");
      try {
        expect(7).assertEqual(hiLog.LogLevel.FATAL);
      } catch (error) {
        expect().assertFail();
      }
      console.log("************* DFX_HiLog_LogLevel_FATAL_0100 Test end*************");
      done();
    });

    console.log("************* byTraceHiDebug Test end*************");
  })
}