• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-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
16export const DEFAULT = 0B0000
17
18export const when: when;
19
20export enum TestType {
21    FUNCTION = 0B1,
22    PERFORMANCE = 0B1 << 1,
23    POWER = 0B1 << 2,
24    RELIABILITY = 0B1 << 3,
25    SECURITY = 0B1 << 4,
26    GLOBAL = 0B1 << 5,
27    COMPATIBILITY = 0B1 << 6,
28    USER = 0B1 << 7,
29    STANDARD = 0B1 << 8,
30    SAFETY = 0B1 << 9,
31    RESILIENCE = 0B1 << 10
32}
33
34export enum Size {
35    SMALLTEST = 0B1 << 16,
36    MEDIUMTEST = 0B1 << 17,
37    LARGETEST = 0B1 << 18
38}
39
40export enum Level {
41    LEVEL0 = 0B1 << 24,
42    LEVEL1 = 0B1 << 25,
43    LEVEL2 = 0B1 << 26,
44    LEVEL3 = 0B1 << 27,
45    LEVEL4 = 0B1 << 28
46}
47
48export function describe(testSuiteName: string, callback: Function): void
49
50export function beforeEach(callback: Function): void
51
52export function afterEach(callback: Function): void
53
54export function beforeAll(callback: Function): void
55
56export function afterAll(callback: Function): void
57
58export function it(testCaseName: string, attribute: (TestType | Size | Level), callback: Function)
59
60export interface Assert {
61    assertClose(expectValue: number, precision: number): void
62    assertContain(expectValue: any): void
63    assertEqual(expectValue: any): void
64    assertFail(): void
65    assertFalse(): void
66    assertTrue(): void
67    assertInstanceOf(expectValue: string): void
68    assertLarger(expectValue: number): void
69    assertLess(expectValue: number): void
70    assertNull(): void
71    assertThrowError(expectValue: string): void
72    assertUndefined(): void
73}
74
75export function expect(actualValue?: any): Assert
76
77export class ArgumentMatchers {
78    static any;
79    static anyString;
80    static anyBoolean;
81    static anyNumber;
82    static anyObj;
83    static anyFunction;
84    static matchRegexs(Regex: RegExp): void
85}
86
87declare interface when {
88    afterReturn(value: any): any
89    afterReturnNothing(): undefined
90    afterAction(action: any): any
91    afterThrow(e_msg: string): string
92    (argMatchers?: any): when;
93}
94
95export interface VerificationMode {
96    times(count: Number): void
97    never(): void
98    once(): void
99    atLeast(count: Number): void
100    atMost(count: Number): void
101}
102
103export class MockKit {
104    constructor()
105    mockFunc(obj: Object, func: Function): Function
106    mockObject(obj: Object): Object
107    verify(methodName: String, argsArray: Array<any>): VerificationMode
108    ignoreMock(obj: Object, func: Function): void
109    clear(obj: Object): void
110    clearAll(): void
111}
112
113export class SysTestKit {
114    static actionStart(tag: string): void
115    static actionEnd(tag: string): void
116    static existKeyword(keyword: string, timeout?: number): boolean
117}
118
119export class Hypium {
120    static setData(data: {[key: string]: any}): void
121    static setTimeConfig(systemTime: any)
122    static hypiumTest(abilityDelegator: any, abilityDelegatorArguments: any, testsuite: Function): void
123}