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

Commit 39c1e8b4 authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge "Add mock for VendorSpecificEventManager" into main

parents 9031a9b2 66f53983
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -16,20 +16,24 @@
#pragma once

#include "hci/hci_packets.h"
#include "hci/vendor_specific_event_manager_interface.h"
#include "module.h"

namespace bluetooth {
namespace hci {

class VendorSpecificEventManager : public bluetooth::Module {
class VendorSpecificEventManager : public VendorSpecificEventManagerInterface,
                                   public bluetooth::Module {
 public:
  VendorSpecificEventManager();
  VendorSpecificEventManager(const VendorSpecificEventManager&) = delete;
  VendorSpecificEventManager& operator=(const VendorSpecificEventManager&) = delete;

  void RegisterEventHandler(VseSubeventCode event, common::ContextualCallback<void(VendorSpecificEventView)> handler);
  void RegisterEventHandler(
      VseSubeventCode event,
      common::ContextualCallback<void(VendorSpecificEventView)> handler) override;

  void UnregisterEventHandler(VseSubeventCode event);
  void UnregisterEventHandler(VseSubeventCode event) override;

  static const ModuleFactory Factory;

+39 −0
Original line number Diff line number Diff line
/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once

#include "common/contextual_callback.h"
#include "hci/hci_packets.h"

namespace bluetooth {
namespace hci {

class VendorSpecificEventManagerInterface {
 public:
  VendorSpecificEventManagerInterface() = default;
  virtual ~VendorSpecificEventManagerInterface() = default;
  VendorSpecificEventManagerInterface(const VendorSpecificEventManagerInterface&) = delete;
  VendorSpecificEventManagerInterface& operator=(const VendorSpecificEventManagerInterface&) =
      delete;

  virtual void RegisterEventHandler(
      VseSubeventCode event, common::ContextualCallback<void(VendorSpecificEventView)> handler) = 0;

  virtual void UnregisterEventHandler(VseSubeventCode event) = 0;
};

}  // namespace hci
}  // namespace bluetooth
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#pragma once

#include <gmock/gmock.h>

#include "common/contextual_callback.h"
#include "hci/hci_packets.h"
#include "hci/vendor_specific_event_manager_interface.h"

namespace bluetooth::hci::testing {

class MockVendorSpecificEventManager : public VendorSpecificEventManagerInterface {
 public:
  MOCK_METHOD(
      (void),
      RegisterEventHandler,
      (VseSubeventCode, common::ContextualCallback<void(VendorSpecificEventView)>),
      (override));
  MOCK_METHOD((void), UnregisterEventHandler, (VseSubeventCode), (override));
};

}  // namespace bluetooth::hci::testing
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ hci::AclManager* GetAclManager() {
      ->GetInstance<hci::AclManager>();
}

hci::VendorSpecificEventManager* GetVendorSpecificEventManager() {
hci::VendorSpecificEventManagerInterface* GetVendorSpecificEventManager() {
  return Stack::GetInstance()
      ->GetStackManager()
      ->GetInstance<hci::VendorSpecificEventManager>();
+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class RemoteNameRequestModule;
class DistanceMeasurementManager;
class LeAdvertisingManager;
class LeScanningManager;
class VendorSpecificEventManager;
class VendorSpecificEventManagerInterface;
#if TARGET_FLOSS
class MsftExtensionManager;
#endif
@@ -75,7 +75,7 @@ hci::LeScanningManager* GetScanning();
hal::SnoopLogger* GetSnoopLogger();
storage::StorageModule* GetStorage();
hci::AclManager* GetAclManager();
hci::VendorSpecificEventManager* GetVendorSpecificEventManager();
hci::VendorSpecificEventManagerInterface* GetVendorSpecificEventManager();
metrics::CounterMetrics* GetCounterMetrics();
#if TARGET_FLOSS
hci::MsftExtensionManager* GetMsftExtensionManager();
Loading