|
14 | 14 | * See the License for the specific language governing permissions and
|
15 | 15 | * limitations under the License.
|
16 | 16 | */
|
17 |
| -#include "access/Privilege.h" |
18 |
| -#include "app/data-model-provider/MetadataList.h" |
19 |
| -#include "app/data-model-provider/MetadataTypes.h" |
20 |
| -#include "app/data-model/List.h" |
| 17 | +#include "app/data-model-provider/OperationTypes.h" |
| 18 | +#include "lib/core/TLVReader.h" |
| 19 | +#include <optional> |
21 | 20 | #include <pw_unit_test/framework.h>
|
22 | 21 |
|
| 22 | +#include <access/Privilege.h> |
23 | 23 | #include <app-common/zap-generated/ids/Attributes.h>
|
| 24 | +#include <app/data-model-provider/MetadataList.h> |
| 25 | +#include <app/data-model-provider/MetadataTypes.h> |
| 26 | +#include <app/data-model-provider/tests/ReadTesting.h> |
| 27 | +#include <app/data-model-provider/tests/WriteTesting.h> |
24 | 28 | #include <app/server-cluster/ServerClusterInterface.h>
|
25 | 29 | #include <lib/core/CHIPError.h>
|
26 | 30 | #include <lib/core/DataModelTypes.h>
|
|
30 | 34 |
|
31 | 35 | using namespace chip;
|
32 | 36 | using namespace chip::app;
|
33 |
| -using namespace chip::app::DataModel; |
34 | 37 | using namespace chip::app::Clusters;
|
| 38 | +using namespace chip::app::DataModel; |
| 39 | +using namespace chip::app::Testing; |
| 40 | +using namespace chip::Protocols::InteractionModel; |
35 | 41 |
|
36 | 42 | namespace {
|
37 | 43 |
|
@@ -204,8 +210,33 @@ TEST(TestServerClusterInterface, CommandsDefault)
|
204 | 210 | ASSERT_EQ(cluster.AcceptedCommands({ 1, 1 }, acceptedCommands), CHIP_NO_ERROR);
|
205 | 211 | ASSERT_TRUE(acceptedCommands.TakeBuffer().empty());
|
206 | 212 |
|
207 |
| - |
208 | 213 | DataModel::ListBuilder<CommandId> generatedCommands;
|
209 | 214 | ASSERT_EQ(cluster.GeneratedCommands({ 1, 1 }, generatedCommands), CHIP_NO_ERROR);
|
210 | 215 | ASSERT_TRUE(generatedCommands.TakeBuffer().empty());
|
211 | 216 | }
|
| 217 | + |
| 218 | +TEST(TestServerClusterInterface, WriteAttributeDefault) |
| 219 | +{ |
| 220 | + FakeServerClusterInterface cluster(1); |
| 221 | + |
| 222 | + WriteOperation test(0 /* endpoint */, 1 /* cluster */, 1234 /* attribute */); |
| 223 | + test.SetSubjectDescriptor(kAdminSubjectDescriptor); |
| 224 | + |
| 225 | + AttributeValueDecoder decoder = test.DecoderFor<uint32_t>(12345); |
| 226 | + |
| 227 | + ASSERT_EQ(cluster.WriteAttribute(test.GetRequest(), decoder), Status::UnsupportedWrite); |
| 228 | + ASSERT_FALSE(decoder.TriedDecode()); |
| 229 | +} |
| 230 | + |
| 231 | +TEST(TestServerClusterInterface, InvokeDefault) |
| 232 | +{ |
| 233 | + FakeServerClusterInterface cluster(1); |
| 234 | + |
| 235 | + TLV::TLVReader tlvReader; |
| 236 | + InvokeRequest request; |
| 237 | + |
| 238 | + request.path = { 0 /* endpoint */, 1 /* cluster */, 1234 /* command */ }; |
| 239 | + |
| 240 | + ASSERT_EQ(cluster.Invoke(request, tlvReader, nullptr /* command handler, assumed unused here */), |
| 241 | + Status::UnsupportedCommand); |
| 242 | +} |
0 commit comments