1 // Copyright 2022 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://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, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 #pragma once 15 16 #include "pw_span/span.h" 17 #include "pw_unit_test/framework.h" 18 19 namespace pw::unit_test { 20 21 class UnitTestService; 22 23 namespace internal { 24 25 // GoogleTest event handler that streams test events through an RPC service. 26 class RpcEventHandler : public testing::EmptyTestEventListener { 27 public: 28 RpcEventHandler(UnitTestService& service); 29 void ExecuteTests(span<std::string_view> suites_to_run); 30 31 void OnTestProgramStart(const testing::UnitTest& unit_test) override; 32 void OnTestProgramEnd(const testing::UnitTest& unit_test) override; 33 void OnTestStart(const testing::TestInfo& test_info) override; 34 void OnTestEnd(const testing::TestInfo& test_info) override; 35 void OnTestPartResult( 36 const testing::TestPartResult& test_part_result) override; 37 void OnTestDisabled(const testing::TestInfo& test_info) override; 38 39 private: 40 UnitTestService& service_; 41 }; 42 43 } // namespace internal 44 } // namespace pw::unit_test 45