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 SpecEvent { 16 constructor (attr) { 17 this.id = attr.id 18 this.coreContext = attr.context 19 this.eventMonitors = [] 20 } 21 22 subscribeEvent (service) { 23 this.eventMonitors.push(service) 24 } 25 26 specStart () { 27 for (let monitor in this.eventMonitors) { 28 this.eventMonitors[monitor]['specStart']() 29 } 30 } 31 32 specDone () { 33 for (const monitor in this.eventMonitors) { 34 this.eventMonitors[monitor]['specDone']() 35 } 36 } 37} 38 39class SuiteEvent { 40 constructor (attr) { 41 this.id = attr.id 42 this.suiteContext = attr.coreContext 43 this.eventMonitors = [] 44 } 45 46 subscribeEvent (service) { 47 this.eventMonitors.push(service) 48 } 49 50 suiteStart () { 51 for (let monitor in this.eventMonitors) { 52 this.eventMonitors[monitor]['suiteStart']() 53 } 54 } 55 56 suiteDone () { 57 for (let monitor in this.eventMonitors) { 58 this.eventMonitors[monitor]['suiteDone']() 59 } 60 } 61} 62 63class TaskEvent { 64 constructor (attr) { 65 this.id = attr.id 66 this.coreContext = attr.coreContext 67 this.eventMonitors = [] 68 } 69 70 subscribeEvent (service) { 71 this.eventMonitors.push(service) 72 } 73 74 taskStart () { 75 for (let monitor in this.eventMonitors) { 76 this.eventMonitors[monitor]['taskStart']() 77 } 78 } 79 80 taskDone () { 81 for (let monitor in this.eventMonitors) { 82 this.eventMonitors[monitor]['taskDone']() 83 } 84 } 85 86 incorrectFormat (){ 87 for (let monitor in this.eventMonitors) { 88 this.eventMonitors[monitor]['incorrectFormat']() 89 } 90 } 91} 92 93export { SpecEvent, TaskEvent, SuiteEvent } 94