buffet: Remove DBusCommandDispatcher::FindProxy.
It is only used for testing.
BUG=None
TEST=cros_workon_make buffet --test
Change-Id: I6053089817e8ee2ad05129fc9ffdc33f10b4e63b
Reviewed-on: https://chromium-review.googlesource.com/228790
Tested-by: Anton Muhin <antonm@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Anton Muhin <antonm@chromium.org>
diff --git a/buffet/commands/dbus_command_dispatcher.cc b/buffet/commands/dbus_command_dispatcher.cc
index 005354a..d36a927 100644
--- a/buffet/commands/dbus_command_dispatcher.cc
+++ b/buffet/commands/dbus_command_dispatcher.cc
@@ -37,12 +37,6 @@
<< "The command instance is not in the dispatcher command map";
}
-DBusCommandProxy* DBusCommandDispacher::FindProxy(
- CommandInstance* command_instance) const {
- auto p = command_map_.find(command_instance);
- return p != command_map_.end() ? p->second.get() : nullptr;
-}
-
std::unique_ptr<DBusCommandProxy> DBusCommandDispacher::CreateDBusCommandProxy(
CommandInstance* command_instance) {
return std::unique_ptr<DBusCommandProxy>(
diff --git a/buffet/commands/dbus_command_dispatcher.h b/buffet/commands/dbus_command_dispatcher.h
index 0bfc21f..ca546e7 100644
--- a/buffet/commands/dbus_command_dispatcher.h
+++ b/buffet/commands/dbus_command_dispatcher.h
@@ -41,10 +41,6 @@
void OnCommandAdded(CommandInstance* command_instance) override;
void OnCommandRemoved(CommandInstance* command_instance) override;
- // Finds a D-Bus command proxy for the given command instance.
- // Returns nullptr if the proxy does not exist.
- DBusCommandProxy* FindProxy(CommandInstance* command_instance) const;
-
protected:
virtual std::unique_ptr<DBusCommandProxy> CreateDBusCommandProxy(
CommandInstance* command_instance);
diff --git a/buffet/commands/dbus_command_dispatcher_unittest.cc b/buffet/commands/dbus_command_dispatcher_unittest.cc
index 0cc1142..9808363 100644
--- a/buffet/commands/dbus_command_dispatcher_unittest.cc
+++ b/buffet/commands/dbus_command_dispatcher_unittest.cc
@@ -107,6 +107,12 @@
command_queue_.Add(std::move(command_instance));
}
+ DBusCommandProxy* FindProxy(CommandInstance* command_instance) {
+ const auto& command_map = command_dispatcher_->command_map_;
+ auto it = command_map.find(command_instance);
+ return it != command_map.end() ? it->second.get() : nullptr;
+ }
+
void FinishCommand(DBusCommandProxy* proxy) {
proxy->HandleDone();
}
@@ -130,8 +136,7 @@
AddNewCommand("{'name':'base.shutdown'}", id);
CommandInstance* command_instance = command_queue_.Find(id);
ASSERT_NE(nullptr, command_instance);
- DBusCommandProxy* command_proxy =
- command_dispatcher_->FindProxy(command_instance);
+ DBusCommandProxy* command_proxy = FindProxy(command_instance);
ASSERT_NE(nullptr, command_proxy);
EXPECT_EQ(CommandInstance::kStatusQueued, command_instance->GetStatus());
@@ -151,8 +156,7 @@
EXPECT_CALL(*mock_exported_object_manager_, SendSignal(_)).Times(2);
FinishCommand(command_proxy);
- EXPECT_EQ(nullptr,
- command_dispatcher_->FindProxy(command_instance));
+ EXPECT_EQ(nullptr, FindProxy(command_instance));
EXPECT_EQ(nullptr, command_queue_.Find(id));
}
@@ -166,8 +170,7 @@
})", id);
CommandInstance* command_instance = command_queue_.Find(id);
ASSERT_NE(nullptr, command_instance);
- DBusCommandProxy* command_proxy =
- command_dispatcher_->FindProxy(command_instance);
+ DBusCommandProxy* command_proxy = FindProxy(command_instance);
ASSERT_NE(nullptr, command_proxy);
EXPECT_EQ(CommandInstance::kStatusQueued, command_instance->GetStatus());
@@ -187,8 +190,7 @@
EXPECT_CALL(*mock_exported_object_manager_, SendSignal(_)).Times(2);
FinishCommand(command_proxy);
- EXPECT_EQ(nullptr,
- command_dispatcher_->FindProxy(command_instance));
+ EXPECT_EQ(nullptr, FindProxy(command_instance));
EXPECT_EQ(nullptr, command_queue_.Find(id));
}