• 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    assertLargerOrEqual(expectValue: number):void
74    assertLessOrEqual(expectValue: number):void
75    assertNaN():void
76    assertNegUnlimited(): void
77    assertPosUnlimited(): void
78    not(): Assert;
79    assertDeepEquals(expectValue: any):void
80    assertPromiseIsPending(): void
81    assertPromiseIsRejected(): void
82    assertPromiseIsRejectedWith(expectValue?: any): void
83    assertPromiseIsRejectedWithError(...expectValue): void
84    assertPromiseIsResolved(): void
85    assertPromiseIsResolvedWith(expectValue?: any): void
86}
87
88export function expect(actualValue?: any): Assert
89
90export class ArgumentMatchers {
91    static any;
92    static anyString;
93    static anyBoolean;
94    static anyNumber;
95    static anyObj;
96    static anyFunction;
97    static matchRegexs(Regex: RegExp): void
98}
99
100declare interface when {
101    afterReturn(value: any): any
102    afterReturnNothing(): undefined
103    afterAction(action: any): any
104    afterThrow(e_msg: string): string
105    (argMatchers?: any): when;
106}
107
108export interface VerificationMode {
109    times(count: Number): void
110    never(): void
111    once(): void
112    atLeast(count: Number): void
113    atMost(count: Number): void
114}
115
116export class MockKit {
117    constructor()
118    mockFunc(obj: Object, func: Function): Function
119    mockObject(obj: Object): Object
120    verify(methodName: String, argsArray: Array<any>): VerificationMode
121    ignoreMock(obj: Object, func: Function): void
122    clear(obj: Object): void
123    clearAll(): void
124}
125
126export class SysTestKit {
127    static actionStart(tag: string): void
128    static actionEnd(tag: string): void
129    static existKeyword(keyword: string, timeout?: number): boolean
130}
131
132export class Hypium {
133    static setData(data: {[key: string]: any}): void
134    static setTimeConfig(systemTime: any)
135    static hypiumTest(abilityDelegator: any, abilityDelegatorArguments: any, testsuite: Function): void
136}