|
14 | 14 | * See the License for the specific language governing permissions and
|
15 | 15 | * limitations under the License.
|
16 | 16 | */
|
| 17 | +#include "app/ConcreteCommandPath.h" |
17 | 18 | #include <app/codegen-data-model/CodegenDataModel.h>
|
18 | 19 |
|
19 | 20 | #include <app/codegen-data-model/tests/AttributeReportIBEncodeDecode.h>
|
| 21 | +#include <app/codegen-data-model/tests/EmberInvokeOverride.h> |
20 | 22 | #include <app/codegen-data-model/tests/EmberReadWriteOverride.h>
|
21 | 23 |
|
22 | 24 | #include <access/AccessControl.h>
|
@@ -69,6 +71,9 @@ constexpr NodeId kTestNodeId = 0xFFFF'1234'ABCD'4321;
|
69 | 71 | constexpr AttributeId kAttributeIdReadOnly = 0x3001;
|
70 | 72 | constexpr AttributeId kAttributeIdTimedWrite = 0x3002;
|
71 | 73 |
|
| 74 | +constexpr CommandId kMockCommandId1 = 0x1234; |
| 75 | +constexpr CommandId kMockCommandId2 = 0x1122; |
| 76 | + |
72 | 77 | constexpr EndpointId kEndpointIdThatIsMissing = kMockEndpointMin - 1;
|
73 | 78 |
|
74 | 79 | constexpr AttributeId kReadOnlyAttributeId = 0x5001;
|
@@ -2430,6 +2435,41 @@ TEST(TestCodegenModelViaMocks, EmberWriteAttributeAccessInterfaceTest)
|
2430 | 2435 | TestEmberScalarNullWrite<int64_t, ZCL_INT64S_ATTRIBUTE_TYPE>();
|
2431 | 2436 | }
|
2432 | 2437 |
|
| 2438 | +TEST(TestCodegenModelViaMocks, EmberInvokeTest) |
| 2439 | +{ |
| 2440 | + // Ember invoke is extrealy hard-coded, so generally we just need to validate that |
| 2441 | + // correct paths are invoked. |
| 2442 | + |
| 2443 | + UseMockNodeConfig config(gTestNodeConfig); |
| 2444 | + chip::app::CodegenDataModel model; |
| 2445 | + |
| 2446 | + { |
| 2447 | + const ConcreteCommandPath kCommandPath(kMockEndpoint1, MockClusterId(1), kMockCommandId1); |
| 2448 | + const InvokeRequest kInvokeRequest{ .path = kCommandPath }; |
| 2449 | + chip::TLV::TLVReader tlvReader; |
| 2450 | + |
| 2451 | + const uint32_t kDispatchCountPre = chip::Test::DispatchCount(); |
| 2452 | + |
| 2453 | + ASSERT_EQ(model.Invoke(kInvokeRequest, tlvReader, nullptr /* handler, NOT used by impl*/), CHIP_NO_ERROR); |
| 2454 | + |
| 2455 | + EXPECT_EQ(chip::Test::DispatchCount(), kDispatchCountPre + 1); // single dispatch |
| 2456 | + EXPECT_EQ(chip::Test::GetLastDispatchPath(), kCommandPath); // for the right path |
| 2457 | + } |
| 2458 | + |
| 2459 | + { |
| 2460 | + const ConcreteCommandPath kCommandPath(kMockEndpoint1, MockClusterId(1), kMockCommandId2); |
| 2461 | + const InvokeRequest kInvokeRequest{ .path = kCommandPath }; |
| 2462 | + chip::TLV::TLVReader tlvReader; |
| 2463 | + |
| 2464 | + const uint32_t kDispatchCountPre = chip::Test::DispatchCount(); |
| 2465 | + |
| 2466 | + ASSERT_EQ(model.Invoke(kInvokeRequest, tlvReader, nullptr /* handler, NOT used by impl*/), CHIP_NO_ERROR); |
| 2467 | + |
| 2468 | + EXPECT_EQ(chip::Test::DispatchCount(), kDispatchCountPre + 1); // single dispatch |
| 2469 | + EXPECT_EQ(chip::Test::GetLastDispatchPath(), kCommandPath); // for the right path |
| 2470 | + } |
| 2471 | +} |
| 2472 | + |
2433 | 2473 | TEST(TestCodegenModelViaMocks, EmberWriteAttributeAccessInterfaceReturningError)
|
2434 | 2474 | {
|
2435 | 2475 | UseMockNodeConfig config(gTestNodeConfig);
|
|
0 commit comments