Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eebfb5ed authored by Myles Watson's avatar Myles Watson
Browse files

Use hci_layer_fake in AclManagerTest

Bug: 301661850
Test: atest bluetooth_test_gd_unit
Flag: EXEMPT, test-only update
Change-Id: I7d688f0a33497dabeb24ca18128dea3fea317acd
parent a8697b4e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ class ClassicImplTest : public ::testing::Test {
    bluetooth::common::InitFlags::SetAllForTesting();
    thread_ = new Thread("thread", Thread::Priority::NORMAL);
    handler_ = new Handler(thread_);
    hci_layer_ = new TestHciLayer();
    hci_layer_ = new HciLayerFake();
    controller_ = new testing::MockController();

    EXPECT_CALL(*controller_, GetNumAclPacketBuffers);
@@ -246,7 +246,7 @@ class ClassicImplTest : public ::testing::Test {

  Thread* thread_;
  Handler* handler_;
  TestHciLayer* hci_layer_{nullptr};
  HciLayerFake* hci_layer_{nullptr};
  testing::MockController* controller_;
  acl_manager::RoundRobinScheduler* round_robin_scheduler_{nullptr};

+3 −3
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ class TestController : public testing::MockController {
class AclManagerNoCallbacksTest : public ::testing::Test {
 protected:
  void SetUp() override {
    test_hci_layer_ = new TestHciLayer;  // Ownership is transferred to registry
    test_hci_layer_ = new HciLayerFake;     // Ownership is transferred to registry
    test_controller_ = new TestController;  // Ownership is transferred to registry

    EXPECT_CALL(*test_controller_, GetMacAddress());
@@ -172,7 +172,7 @@ class AclManagerNoCallbacksTest : public ::testing::Test {
  }

  TestModuleRegistry fake_registry_;
  TestHciLayer* test_hci_layer_ = nullptr;
  HciLayerFake* test_hci_layer_ = nullptr;
  TestController* test_controller_ = nullptr;
  os::Thread& thread_ = fake_registry_.GetTestThread();
  AclManager* acl_manager_ = nullptr;
@@ -1170,7 +1170,7 @@ TEST_F(AclManagerWithConnectionTest, send_read_clock) {
class AclManagerWithResolvableAddressTest : public AclManagerNoCallbacksTest {
 protected:
  void SetUp() override {
    test_hci_layer_ = new TestHciLayer;  // Ownership is transferred to registry
    test_hci_layer_ = new HciLayerFake;  // Ownership is transferred to registry
    test_controller_ = new TestController;
    fake_registry_.InjectTestModule(&HciLayer::Factory, test_hci_layer_);
    fake_registry_.InjectTestModule(&Controller::Factory, test_controller_);
+61 −295

File changed.

Preview size limit exceeded, changes collapsed.

+36 −26

File changed.

Preview size limit exceeded, changes collapsed.

+3 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ packet::PacketView<packet::kLittleEndian> GetPacketView(

std::unique_ptr<BasePacketBuilder> NextPayload(uint16_t handle);

class TestHciLayer : public HciLayer {
class HciLayerFake : public HciLayer {
 public:
  void EnqueueCommand(
      std::unique_ptr<CommandBuilder> command,
@@ -42,6 +42,8 @@ class TestHciLayer : public HciLayer {

  CommandView GetCommand();

  CommandView GetCommand(OpCode op_code);

  void AssertNoQueuedCommand();

  void RegisterEventHandler(EventCode event_code, common::ContextualCallback<void(EventView)> event_handler) override;
Loading