1#!/usr/bin/env python3 2# 3# Copyright 2018 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17 18class Event(object): 19 """The base class for all event objects.""" 20 21 22# TODO(markdr): Move these into test_runner.py 23class TestEvent(Event): 24 """The base class for test-related events.""" 25 26 def __init__(self): 27 pass 28 29 30class TestCaseEvent(TestEvent): 31 """The base class for test-case-related events.""" 32 33 def __init__(self, test_class, test_case): 34 super().__init__() 35 self.test_class = test_class 36 self.test_case = test_case 37 38 @property 39 def test_case_name(self): 40 return self.test_case 41 42 @property 43 def test_class_name(self): 44 return self.test_class.__class__.__name__ 45 46 47class TestCaseSignalEvent(TestCaseEvent): 48 """The base class for test-case-signal-related events.""" 49 50 def __init__(self, test_class, test_case, test_signal): 51 super().__init__(test_class, test_case) 52 self.test_signal = test_signal 53 54 55class TestCaseBeginEvent(TestCaseEvent): 56 """The event posted when a test case has begun.""" 57 58 59class TestCaseEndEvent(TestCaseSignalEvent): 60 """The event posted when a test case has ended.""" 61 62 63class TestCaseSkippedEvent(TestCaseSignalEvent): 64 """The event posted when a test case has been skipped.""" 65 66 67class TestCaseFailureEvent(TestCaseSignalEvent): 68 """The event posted when a test case has failed.""" 69 70 71class TestCasePassedEvent(TestCaseSignalEvent): 72 """The event posted when a test case has passed.""" 73 74 75class TestClassEvent(TestEvent): 76 """The base class for test-class-related events""" 77 78 def __init__(self, test_class): 79 super().__init__() 80 self.test_class = test_class 81 82 83class TestClassBeginEvent(TestClassEvent): 84 """The event posted when a test class has begun testing.""" 85 86 87class TestClassEndEvent(TestClassEvent): 88 """The event posted when a test class has finished testing.""" 89 90 def __init__(self, test_class, result): 91 super().__init__(test_class) 92 self.result = result