buffet: Add command ID to CommandInstance class
Rather than passing command ID along with CommandInstance class,
make it to be part of CommandInstance itself. When a command
instance is added to CommandQueue, the command queue will generate
a new ID and set it to the command instance.
Because CommandInstance, when saved in CommandQueue, is now mutable,
remove 'const' in a bunch of places to allow the command instance
to be modifiable.
BUG=chromium:374864
TEST=USE=buffet P2_TEST_FILTER="buffet::*" FEATURES=test emerge-link platform2
Change-Id: Ia30dd4c9bd86b51694d9345dd91f6ed2ae0cb138
Reviewed-on: https://chromium-review.googlesource.com/213266
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/commands/command_instance_unittest.cc b/buffet/commands/command_instance_unittest.cc
index ace0738..844ac92 100644
--- a/buffet/commands/command_instance_unittest.cc
+++ b/buffet/commands/command_instance_unittest.cc
@@ -69,6 +69,7 @@
params.insert(std::make_pair("volume", int_prop.CreateValue(100)));
buffet::CommandInstance instance("robot._beep", "robotd", params);
+ EXPECT_EQ("", instance.GetID());
EXPECT_EQ("robot._beep", instance.GetName());
EXPECT_EQ("robotd", instance.GetCategory());
EXPECT_EQ(params, instance.GetParameters());
@@ -78,6 +79,12 @@
EXPECT_EQ(nullptr, instance.FindParameter("blah").get());
}
+TEST(CommandInstance, SetID) {
+ buffet::CommandInstance instance("robot._beep", "robotd", {});
+ instance.SetID("command_id");
+ EXPECT_EQ("command_id", instance.GetID());
+}
+
TEST_F(CommandInstanceTest, FromJson) {
auto json = CreateDictionaryValue(R"({
'name': 'robot.jump',