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 bluetooth::le_audio::broadcaster;
21
22 IBroadcastStateMachineCallbacks* callbacks;
23 AdvertisingCallbacks* adv_callbacks;
Initialize(IBroadcastStateMachineCallbacks * cb,AdvertisingCallbacks * adv_cb)24 void BroadcastStateMachine::Initialize(IBroadcastStateMachineCallbacks* cb,
25 AdvertisingCallbacks* adv_cb) {
26 callbacks = cb;
27 adv_callbacks = adv_cb;
28 }
29
CreateInstance(BroadcastStateMachineConfig msg)30 std::unique_ptr<BroadcastStateMachine> BroadcastStateMachine::CreateInstance(
31 BroadcastStateMachineConfig msg) {
32 auto instance =
33 std::make_unique<MockBroadcastStateMachine>(std::move(msg), callbacks, adv_callbacks);
34 MockBroadcastStateMachine::last_instance_ = instance.get();
35 return std::move(instance);
36 }
37
38 namespace bluetooth::le_audio {
39 namespace broadcaster {
40
operator <<(std::ostream & os,const BroadcastStateMachine::Message & state)41 std::ostream& operator<<(std::ostream& os, const BroadcastStateMachine::Message& state) {
42 static const char* char_value_[BroadcastStateMachine::MESSAGE_COUNT] = {"START", "SUSPEND",
43 "STOP"};
44 os << char_value_[static_cast<uint8_t>(state)];
45 return os;
46 }
47
operator <<(std::ostream & os,const BroadcastStateMachine::State & state)48 std::ostream& operator<<(std::ostream& os, const BroadcastStateMachine::State& state) {
49 static const char* char_value_[BroadcastStateMachine::STATE_COUNT] = {
50 "STOPPED", "CONFIGURING", "CONFIGURED", "ENABLING", "DISABLING", "STOPPING", "STREAMING"};
51 os << char_value_[static_cast<uint8_t>(state)];
52 return os;
53 }
54
operator <<(std::ostream & os,const BigConfig &)55 std::ostream& operator<<(std::ostream& os, const BigConfig& /*config*/) { return os; }
56
operator <<(std::ostream & os,const BroadcastStateMachineConfig &)57 std::ostream& operator<<(std::ostream& os, const BroadcastStateMachineConfig& /*config*/) {
58 return os;
59 }
60
operator <<(std::ostream & os,const BroadcastStateMachine &)61 std::ostream& operator<<(std::ostream& os, const BroadcastStateMachine& /*machine*/) { return os; }
62
63 } // namespace broadcaster
64 } // namespace bluetooth::le_audio
65
66 uint8_t MockBroadcastStateMachine::instance_counter_ = 0;
67 MockBroadcastStateMachine* MockBroadcastStateMachine::last_instance_ = nullptr;
68