Skip to content

Commit ccd52a1

Browse files
committed
Unit tests for GeneratedCommands pass
1 parent 28ab9e3 commit ccd52a1

File tree

8 files changed

+88
-184
lines changed

8 files changed

+88
-184
lines changed

src/app/data-model-provider/MetadataTypes.h

-5
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,6 @@ class ProviderMetadataTree
218218
virtual CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) = 0;
219219
virtual std::optional<CommandInfo> GetAcceptedCommandInfo(const ConcreteCommandPath & path) = 0;
220220

221-
// "generated" commands are purely for reporting what types of command ids can be
222-
// returned as responses.
223-
virtual ConcreteCommandPath FirstGeneratedCommand(const ConcreteClusterPath & cluster) = 0;
224-
virtual ConcreteCommandPath NextGeneratedCommand(const ConcreteCommandPath & before) = 0;
225-
226221
/// List items. TODO: convert ALL items above to the new format
227222

228223
/// List all the generated commands for the given path

src/app/tests/test-interaction-model-api.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,5 @@ MetadataList<CommandId> TestImCustomDataModel::GeneratedCommands(const ConcreteC
246246
return CodegenDataModelProviderInstance(nullptr /* delegate */)->GeneratedCommands(path);
247247
}
248248

249-
ConcreteCommandPath TestImCustomDataModel::FirstGeneratedCommand(const ConcreteClusterPath & cluster)
250-
{
251-
return CodegenDataModelProviderInstance(nullptr /* delegate */)->FirstGeneratedCommand(cluster);
252-
}
253-
254-
ConcreteCommandPath TestImCustomDataModel::NextGeneratedCommand(const ConcreteCommandPath & before)
255-
{
256-
return CodegenDataModelProviderInstance(nullptr /* delegate */)->NextGeneratedCommand(before);
257-
}
258-
259249
} // namespace app
260250
} // namespace chip

src/app/tests/test-interaction-model-api.h

-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ class TestImCustomDataModel : public DataModel::Provider
131131
DataModel::CommandEntry FirstAcceptedCommand(const ConcreteClusterPath & cluster) override;
132132
DataModel::CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) override;
133133
std::optional<DataModel::CommandInfo> GetAcceptedCommandInfo(const ConcreteCommandPath & path) override;
134-
ConcreteCommandPath FirstGeneratedCommand(const ConcreteClusterPath & cluster) override;
135-
ConcreteCommandPath NextGeneratedCommand(const ConcreteCommandPath & before) override;
136134
void Temporary_ReportAttributeChanged(const AttributePathParams & path) override {}
137135
};
138136

src/controller/tests/data_model/DataModelFixtures.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -574,16 +574,5 @@ MetadataList<CommandId> CustomDataModel::GeneratedCommands(const ConcreteCluster
574574
return CodegenDataModelProviderInstance(nullptr /* delegate */)->GeneratedCommands(path);
575575
}
576576

577-
578-
ConcreteCommandPath CustomDataModel::FirstGeneratedCommand(const ConcreteClusterPath & cluster)
579-
{
580-
return CodegenDataModelProviderInstance(nullptr /* delegate */)->FirstGeneratedCommand(cluster);
581-
}
582-
583-
ConcreteCommandPath CustomDataModel::NextGeneratedCommand(const ConcreteCommandPath & before)
584-
{
585-
return CodegenDataModelProviderInstance(nullptr /* delegate */)->NextGeneratedCommand(before);
586-
}
587-
588577
} // namespace app
589578
} // namespace chip

src/controller/tests/data_model/DataModelFixtures.h

-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ class CustomDataModel : public DataModel::Provider
143143
DataModel::CommandEntry FirstAcceptedCommand(const ConcreteClusterPath & cluster) override;
144144
DataModel::CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) override;
145145
std::optional<DataModel::CommandInfo> GetAcceptedCommandInfo(const ConcreteCommandPath & path) override;
146-
ConcreteCommandPath FirstGeneratedCommand(const ConcreteClusterPath & cluster) override;
147-
ConcreteCommandPath NextGeneratedCommand(const ConcreteCommandPath & before) override;
148146
void Temporary_ReportAttributeChanged(const AttributePathParams & path) override {}
149147
};
150148

src/data-model-providers/codegen/CodegenDataModelProvider.cpp

+1-31
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ const CommandId * GetAcceptedCommands(const EmberAfCluster & cluster)
128128
return cluster.acceptedCommandList;
129129
}
130130

131-
const CommandId * GetGeneratedCommands(const EmberAfCluster & cluster)
132-
{
133-
return cluster.generatedCommandList;
134-
}
135-
136131
/// Load the cluster information into the specified destination
137132
std::variant<CHIP_ERROR, DataModel::ClusterInfo> LoadClusterInfo(const ConcreteClusterPath & path, const EmberAfCluster & cluster)
138133
{
@@ -844,9 +839,6 @@ std::optional<DataModel::CommandInfo> CodegenDataModelProvider::GetAcceptedComma
844839

845840
MetadataList<CommandId> CodegenDataModelProvider::GeneratedCommands(const ConcreteClusterPath & path)
846841
{
847-
// For fixed:
848-
// ???? depends on how it looks like
849-
//
850842
CommandHandlerInterface * interface =
851843
CommandHandlerInterfaceRegistry::Instance().GetCommandHandler(path.mEndpointId, path.mClusterId);
852844
if (interface != nullptr)
@@ -905,7 +897,7 @@ MetadataList<CommandId> CodegenDataModelProvider::GeneratedCommands(const Concre
905897
}
906898

907899
const EmberAfCluster * cluster = FindServerCluster(path);
908-
if (cluster == nullptr)
900+
if ((cluster == nullptr) || (cluster->generatedCommandList == nullptr))
909901
{
910902
return {};
911903
}
@@ -918,28 +910,6 @@ MetadataList<CommandId> CodegenDataModelProvider::GeneratedCommands(const Concre
918910
return MetadataList<CommandId>::FromConstSpan({ cluster->generatedCommandList, commandCount });
919911
}
920912

921-
ConcreteCommandPath CodegenDataModelProvider::FirstGeneratedCommand(const ConcreteClusterPath & path)
922-
{
923-
EnumeratorCommandFinder handlerFinder(&CommandHandlerInterface::EnumerateGeneratedCommands);
924-
CommandId commandId =
925-
FindCommand(ConcreteCommandPath(path.mEndpointId, path.mClusterId, kInvalidCommandId), handlerFinder,
926-
detail::EnumeratorCommandFinder::Operation::kFindFirst, mGeneratedCommandsIterator, GetGeneratedCommands);
927-
928-
VerifyOrReturnValue(commandId != kInvalidCommandId, kInvalidCommandPath);
929-
return ConcreteCommandPath(path.mEndpointId, path.mClusterId, commandId);
930-
}
931-
932-
ConcreteCommandPath CodegenDataModelProvider::NextGeneratedCommand(const ConcreteCommandPath & before)
933-
{
934-
EnumeratorCommandFinder handlerFinder(&CommandHandlerInterface::EnumerateGeneratedCommands);
935-
936-
CommandId commandId = FindCommand(before, handlerFinder, detail::EnumeratorCommandFinder::Operation::kFindNext,
937-
mGeneratedCommandsIterator, GetGeneratedCommands);
938-
939-
VerifyOrReturnValue(commandId != kInvalidCommandId, kInvalidCommandPath);
940-
return ConcreteCommandPath(before.mEndpointId, before.mClusterId, commandId);
941-
}
942-
943913
void CodegenDataModelProvider::InitDataModelForTesting()
944914
{
945915
// Call the Ember-specific InitDataModelHandler

src/data-model-providers/codegen/CodegenDataModelProvider.h

-3
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ class CodegenDataModelProvider : public DataModel::Provider
184184
DataModel::CommandEntry NextAcceptedCommand(const ConcreteCommandPath & before) override;
185185
std::optional<DataModel::CommandInfo> GetAcceptedCommandInfo(const ConcreteCommandPath & path) override;
186186

187-
ConcreteCommandPath FirstGeneratedCommand(const ConcreteClusterPath & cluster) override;
188-
ConcreteCommandPath NextGeneratedCommand(const ConcreteCommandPath & before) override;
189-
190187
void Temporary_ReportAttributeChanged(const AttributePathParams & path) override;
191188

192189
protected:

0 commit comments

Comments
 (0)