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

Commit 32c91e3e authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Module: Add TestModule for dependency injection"

parents 2519d527 d1091ba2
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