@@ -1091,6 +1091,47 @@ TEST_F_FROM_FIXTURE(TestCommandInteraction, TestCommandSender_ExtendableApiWithP
1091
1091
EXPECT_EQ (mockCommandSenderExtendedDelegate.onErrorCalledTimes , 0 );
1092
1092
}
1093
1093
1094
+ TEST_F_FROM_FIXTURE (TestCommandInteraction, TestCommandSender_ValidateSecondLargeAddRequestDataRollbacked)
1095
+ {
1096
+ mockCommandSenderExtendedDelegate.ResetCounter ();
1097
+ PendingResponseTrackerImpl pendingResponseTracker;
1098
+ app::CommandSender commandSender (kCommandSenderTestOnlyMarker , &mockCommandSenderExtendedDelegate,
1099
+ &mpTestContext->GetExchangeManager (), &pendingResponseTracker);
1100
+
1101
+ app::CommandSender::AddRequestDataParameters addRequestDataParams;
1102
+
1103
+ CommandSender::ConfigParameters config;
1104
+ config.SetRemoteMaxPathsPerInvoke (2 );
1105
+ EXPECT_EQ (commandSender.SetCommandSenderConfig (config), CHIP_NO_ERROR);
1106
+
1107
+ // The specific values chosen here are arbitrary.
1108
+ uint16_t firstCommandRef = 1 ;
1109
+ uint16_t secondCommandRef = 2 ;
1110
+ auto commandPathParams = MakeTestCommandPath ();
1111
+ SimpleTLVPayload simplePayloadWriter;
1112
+ addRequestDataParams.SetCommandRef (firstCommandRef);
1113
+
1114
+ EXPECT_EQ (commandSender.AddRequestData (commandPathParams, simplePayloadWriter, addRequestDataParams), CHIP_NO_ERROR);
1115
+
1116
+ uint32_t remainingSize = commandSender.mInvokeRequestBuilder .GetWriter ()->GetRemainingFreeLength ();
1117
+ // Because request is made of both request data and request path (commandPathParams), using
1118
+ // `remainingSize` is large enough fail.
1119
+ ForcedSizeBuffer requestData (remainingSize);
1120
+
1121
+ addRequestDataParams.SetCommandRef (secondCommandRef);
1122
+ EXPECT_EQ (commandSender.AddRequestData (commandPathParams, requestData, addRequestDataParams), CHIP_ERROR_NO_MEMORY);
1123
+
1124
+ // Confirm that we can still send out a request with the first command.
1125
+ EXPECT_EQ (commandSender.SendCommandRequest (mpTestContext->GetSessionBobToAlice ()), CHIP_NO_ERROR);
1126
+ EXPECT_EQ (commandSender.GetInvokeResponseMessageCount (), 0u );
1127
+
1128
+ mpTestContext->DrainAndServiceIO ();
1129
+
1130
+ EXPECT_EQ (mockCommandSenderExtendedDelegate.onResponseCalledTimes , 1 );
1131
+ EXPECT_EQ (mockCommandSenderExtendedDelegate.onFinalCalledTimes , 1 );
1132
+ EXPECT_EQ (mockCommandSenderExtendedDelegate.onErrorCalledTimes , 0 );
1133
+ }
1134
+
1094
1135
TEST_F (TestCommandInteraction, TestCommandHandlerEncodeSimpleCommandData)
1095
1136
{
1096
1137
// Send response which has simple command data and command path
@@ -1741,55 +1782,6 @@ TEST_F_FROM_FIXTURE(TestCommandInteraction, TestCommandHandler_AcceptMultipleCom
1741
1782
EXPECT_EQ (commandDispatchedCount, 2u );
1742
1783
}
1743
1784
1744
- #if 0
1745
- TEST_F_FROM_FIXTURE(TestCommandInteraction, TestCommandSender_ValidateSecondLargeAddRequestDataRollbacked)
1746
- {
1747
- TestContext & ctx = *static_cast<TestContext *>(apContext);
1748
- CHIP_ERROR err = CHIP_NO_ERROR;
1749
- mockCommandSenderExtendedDelegate.ResetCounter();
1750
- PendingResponseTrackerImpl pendingResponseTracker;
1751
- app::CommandSender commandSender(kCommandSenderTestOnlyMarker, &mockCommandSenderExtendedDelegate, &ctx.GetExchangeManager(),
1752
- &pendingResponseTracker);
1753
- app::CommandSender::AddRequestDataParameters addRequestDataParams;
1754
-
1755
- CommandSender::ConfigParameters config;
1756
- config.SetRemoteMaxPathsPerInvoke(2);
1757
- err = commandSender.SetCommandSenderConfig(config);
1758
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
1759
-
1760
- // The specific values chosen here are arbitrary.
1761
- uint16_t firstCommandRef = 1;
1762
- uint16_t secondCommandRef = 2;
1763
- auto commandPathParams = MakeTestCommandPath();
1764
- SimpleTLVPayload simplePayloadWriter;
1765
- addRequestDataParams.SetCommandRef(firstCommandRef);
1766
-
1767
- err = commandSender.AddRequestData(commandPathParams, simplePayloadWriter, addRequestDataParams);
1768
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
1769
-
1770
- uint32_t remainingSize = commandSender.mInvokeRequestBuilder.GetWriter()->GetRemainingFreeLength();
1771
- // Because request is made of both request data and request path (commandPathParams), using
1772
- // `remainingSize` is large enough fail.
1773
- ForcedSizeBuffer requestData(remainingSize);
1774
-
1775
- addRequestDataParams.SetCommandRef(secondCommandRef);
1776
- err = commandSender.AddRequestData(commandPathParams, requestData, addRequestDataParams);
1777
- NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_NO_MEMORY);
1778
-
1779
- // Confirm that we can still send out a request with the first command.
1780
- err = commandSender.SendCommandRequest(ctx.GetSessionBobToAlice());
1781
- NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
1782
- NL_TEST_ASSERT(apSuite, commandSender.GetInvokeResponseMessageCount() == 0);
1783
-
1784
- ctx.DrainAndServiceIO();
1785
-
1786
- NL_TEST_ASSERT(apSuite,
1787
- mockCommandSenderExtendedDelegate.onResponseCalledTimes == 1 &&
1788
- mockCommandSenderExtendedDelegate.onFinalCalledTimes == 1 &&
1789
- mockCommandSenderExtendedDelegate.onErrorCalledTimes == 0);
1790
- }
1791
- #endif
1792
-
1793
1785
TEST_F_FROM_FIXTURE (TestCommandInteraction, TestCommandHandler_FillUpInvokeResponseMessageWhereSecondResponseIsStatusResponse)
1794
1786
{
1795
1787
BasicCommandPathRegistry<4 > basicCommandPathRegistry;
0 commit comments