1 /*
2 * Copyright 2021 HIMSA II K/S - www.himsa.com.
3 * Represented by EHIMA - www.ehima.com
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
18 #include "mock_state_machine.h"
19
20 using namespace le_audio::broadcaster;
21
22 IBroadcastStateMachineCallbacks* callbacks;
Initialize(IBroadcastStateMachineCallbacks * cb)23 void BroadcastStateMachine::Initialize(IBroadcastStateMachineCallbacks* cb) {
24 callbacks = cb;
25 }
26
CreateInstance(BroadcastStateMachineConfig msg)27 std::unique_ptr<BroadcastStateMachine> BroadcastStateMachine::CreateInstance(
28 BroadcastStateMachineConfig msg) {
29 auto instance =
30 std::make_unique<MockBroadcastStateMachine>(std::move(msg), callbacks);
31 MockBroadcastStateMachine::last_instance_ = instance.get();
32 return std::move(instance);
33 }
34
35 namespace le_audio {
36 namespace broadcaster {
37
operator <<(std::ostream & os,const BroadcastStateMachine::Message & state)38 std::ostream& operator<<(std::ostream& os,
39 const BroadcastStateMachine::Message& state) {
40 static const char* char_value_[BroadcastStateMachine::MESSAGE_COUNT] = {
41 "START", "SUSPEND", "STOP"};
42 os << char_value_[static_cast<uint8_t>(state)];
43 return os;
44 }
45
operator <<(std::ostream & os,const BroadcastStateMachine::State & state)46 std::ostream& operator<<(std::ostream& os,
47 const BroadcastStateMachine::State& state) {
48 static const char* char_value_[BroadcastStateMachine::STATE_COUNT] = {
49 "STOPPED", "CONFIGURING", "CONFIGURED", "STOPPING", "STREAMING"};
50 os << char_value_[static_cast<uint8_t>(state)];
51 return os;
52 }
53
operator <<(std::ostream & os,const BigConfig & config)54 std::ostream& operator<<(std::ostream& os, const BigConfig& config) {
55 return os;
56 }
57
operator <<(std::ostream & os,const BroadcastStateMachineConfig & config)58 std::ostream& operator<<(std::ostream& os,
59 const BroadcastStateMachineConfig& config) {
60 return os;
61 }
62
operator <<(std::ostream & os,const BroadcastStateMachine & machine)63 std::ostream& operator<<(std::ostream& os,
64 const BroadcastStateMachine& machine) {
65 return os;
66 }
67
68 } // namespace broadcaster
69 } // namespace le_audio
70
71 uint8_t MockBroadcastStateMachine::instance_counter_ = 0;
72 MockBroadcastStateMachine* MockBroadcastStateMachine::last_instance_ = nullptr;
73