1 // Copyright 2024 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 
15 #pragma once
16 
17 #include "pw_async_fuchsia/dispatcher.h"
18 #include "pw_bluetooth_sapphire/internal/host/common/macros.h"
19 #include "pw_bluetooth_sapphire/internal/host/gap/fake_adapter.h"
20 #include "pw_bluetooth_sapphire/internal/host/testing/loop_fixture.h"
21 #include "pw_unit_test/framework.h"
22 
23 namespace bt::fidl::testing {
24 
25 class FakeAdapterTestFixture : public bt::testing::TestLoopFixture {
26  public:
27   FakeAdapterTestFixture() = default;
28   ~FakeAdapterTestFixture() override = default;
29 
SetUp()30   void SetUp() override {
31     adapter_ = std::make_unique<bt::gap::testing::FakeAdapter>(pw_dispatcher());
32   }
33 
TearDown()34   void TearDown() override { adapter_ = nullptr; }
35 
pw_dispatcher()36   pw::async::Dispatcher& pw_dispatcher() { return dispatcher_; }
37 
38  protected:
adapter()39   bt::gap::testing::FakeAdapter* adapter() const { return adapter_.get(); }
40 
41  private:
42   std::unique_ptr<bt::gap::testing::FakeAdapter> adapter_;
43   pw::async_fuchsia::FuchsiaDispatcher dispatcher_{dispatcher()};
44 
45   BT_DISALLOW_COPY_AND_ASSIGN_ALLOW_MOVE(FakeAdapterTestFixture);
46 };
47 
48 }  // namespace bt::fidl::testing
49