1 // Copyright 2018 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #include <fbl/vector.h> 8 #include <zxtest/base/observer.h> 9 10 namespace zxtest { 11 // Forward declaration. 12 class TestCase; 13 class TestInfo; 14 15 namespace internal { 16 17 class EventBroadcaster : public LifecycleObserver { 18 public: 19 EventBroadcaster(); 20 EventBroadcaster(const EventBroadcaster&) = delete; 21 EventBroadcaster(EventBroadcaster&&); 22 ~EventBroadcaster() final; 23 24 EventBroadcaster& operator=(const EventBroadcaster&) = delete; 25 EventBroadcaster& operator=(EventBroadcaster&&) = delete; 26 27 // Reports before every TestCase is set up. 28 void OnTestCaseStart(const TestCase& test_case) final; 29 30 // Reports before every test starts. 31 void OnTestStart(const TestCase& test_case, const TestInfo& test) final; 32 33 // Reports before every test starts. 34 void OnTestSkip(const TestCase& test_case, const TestInfo& test) final; 35 36 // Reports before every TestCase is set up. 37 void OnTestFailure(const TestCase& test_case, const TestInfo& test) final; 38 39 // Reports before every TestCase is set up. 40 void OnTestSuccess(const TestCase& test_case, const TestInfo& test) final; 41 42 // Reports before every TestCase is torn down. 43 void OnTestCaseEnd(const TestCase& test_case) final; 44 45 // Adds a lifecycle observer to the registered list of observers. 46 void Subscribe(LifecycleObserver* observer); 47 48 private: 49 fbl::Vector<LifecycleObserver*> lifecycle_observers_; 50 }; 51 52 } // namespace internal 53 } // namespace zxtest 54