1 // Copyright 2020 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 // Unit test event handler that streams test events through an RPC service.
26 class RpcEventHandler : public EventHandler {
27  public:
28   RpcEventHandler(UnitTestService& service);
29   void ExecuteTests(span<std::string_view> suites_to_run);
30 
TestProgramStart(const ProgramSummary &)31   void TestProgramStart(const ProgramSummary&) override {}
EnvironmentsSetUpEnd()32   void EnvironmentsSetUpEnd() override {}
TestSuiteStart(const TestSuite &)33   void TestSuiteStart(const TestSuite&) override {}
TestSuiteEnd(const TestSuite &)34   void TestSuiteEnd(const TestSuite&) override {}
EnvironmentsTearDownEnd()35   void EnvironmentsTearDownEnd() override {}
TestProgramEnd(const ProgramSummary &)36   void TestProgramEnd(const ProgramSummary&) override {}
37 
38   void RunAllTestsStart() override;
39   void RunAllTestsEnd(const RunTestsSummary& run_tests_summary) override;
40   void TestCaseStart(const TestCase& test_case) override;
41   void TestCaseEnd(const TestCase& test_case, TestResult result) override;
42   void TestCaseExpect(const TestCase& test_case,
43                       const TestExpectation& expectation) override;
44   void TestCaseDisabled(const TestCase& test_case) override;
45 
46  private:
47   UnitTestService& service_;
48 };
49 
50 }  // namespace internal
51 }  // namespace pw::unit_test
52