• 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 */
15class ClassFilter {
16    constructor(suiteName, itName, params) {
17        this.suiteName = suiteName
18        this.itName = itName
19        this.params = params
20    }
21
22    filterSuite() {
23        return !this.params.split(',').map(item => item.split('#')[0]).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false)
24    }
25
26    filterIt() {
27        let classArray = this.params.split(',') || []
28        let suiteFilterResult = classArray.filter(item => !item.includes('#')).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false)
29        let itFilterResult = classArray.filter(item => item.includes('#')).map(item => item == (this.suiteName + '#' + this.itName)).reduce((pre, cur) => pre || cur, false)
30        return !(suiteFilterResult || itFilterResult)
31    }
32}
33
34class NotClassFilter {
35    constructor(suiteName, itName, params) {
36        this.suiteName = suiteName
37        this.itName = itName
38        this.params = params
39    }
40
41    filterSuite() {
42        return this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false)
43    }
44
45    filterIt() {
46        return this.params.includes(this.suiteName + '#' + this.itName)
47    }
48}
49
50class SuiteAndItNameFilter {
51    constructor(suiteName, itName, params) {
52        this.suiteName = suiteName
53        this.itName = itName
54        this.params = params
55    }
56
57    filterSuite() {
58        return !this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false)
59    }
60
61    filterIt() {
62        return !this.params.split(',').map(item => item == this.itName).reduce((pre, cur) => pre || cur, false)
63    }
64}
65
66
67class TestTypesFilter {
68    constructor(suiteName, itName, fi, params) {
69        this.suiteName = suiteName
70        this.itName = itName
71        this.params = params
72        this.fi = fi
73    }
74
75    filterIt() {
76        return !((this.params === (this.fi & this.params)) || this.fi === 0)
77    }
78}
79
80export {ClassFilter, NotClassFilter, SuiteAndItNameFilter, TestTypesFilter}
81