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

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

Module: Add TestModule for dependency injection

Test: HciLayerTest
Change-Id: I32dbfaa051be5cb42adb7a081b37966479df5268
parent c8032598
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -115,11 +115,23 @@ class ModuleRegistry {
  // Stop all running modules in reverse order of start
  void StopAll();

 private:
 protected:
  Module* Get(const ModuleFactory* module) const;

  std::map<const ModuleFactory*, Module*> started_modules_;
  std::vector<const ModuleFactory*> start_order_;
};

class TestModuleRegistry : public ModuleRegistry {
 public:
  void InjectTestModule(const ModuleFactory* module, Module* instance) {
    start_order_.push_back(module);
    started_modules_[module] = instance;
  }

  Module* GetModuleUnderTest(const ModuleFactory* module) const {
    return Get(module);
  }
};

}  // namespace bluetooth