blob: 4cd090b45162bc43cc4a8211166d3830ae32c432 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "adapter_test_fixture.h"
namespace bthost::testing {
using bt::testing::FakeController;
using TestingBase = bt::testing::ControllerTest<FakeController>;
void AdapterTestFixture::SetUp() {
TestingBase::SetUp();
data_plane_ = bt::l2cap::testing::FakeL2cap::Create();
gatt_ = std::make_unique<bt::gatt::testing::FakeLayer>();
adapter_ = bt::gap::Adapter::Create(transport()->WeakPtr(), gatt_->AsWeakPtr(), data_plane_);
FakeController::Settings settings;
settings.ApplyDualModeDefaults();
test_device()->set_settings(settings);
StartTestDevice();
bool success = false;
adapter_->Initialize([&](bool result) { success = result; }, [] {});
RunLoopUntilIdle();
ASSERT_TRUE(success);
ASSERT_TRUE(adapter_->le());
ASSERT_TRUE(adapter_->bredr());
}
void AdapterTestFixture::TearDown() {
// Drain all scheduled tasks.
RunLoopUntilIdle();
// Cleanly shut down the stack.
adapter_ = nullptr;
RunLoopUntilIdle();
gatt_ = nullptr;
data_plane_ = nullptr;
TestingBase::TearDown();
}
} // namespace bthost::testing