Skip to content

Commit

Permalink
Regenerate generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Jul 1, 2021
1 parent 2589532 commit 1747160
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
74 changes: 73 additions & 1 deletion examples/chip-tool/commands/tests/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ class TestCluster : public TestCommand
case 100:
err = TestSendClusterTestClusterCommandWriteAttribute_100();
break;
case 101:
err = TestSendClusterTestClusterCommandTest_101();
break;
}

if (CHIP_NO_ERROR != err)
Expand All @@ -357,7 +360,7 @@ class TestCluster : public TestCommand

private:
std::atomic_uint16_t mTestIndex;
const uint16_t mTestCount = 101;
const uint16_t mTestCount = 102;

//
// Tests methods
Expand Down Expand Up @@ -7829,6 +7832,75 @@ class TestCluster : public TestCommand

runner->NextTest();
}

// Test Send Test Command to unsupported endpoint
typedef void (*SuccessCallback_101)(void * context);
chip::Callback::Callback<SuccessCallback_101> * mOnSuccessCallback_101 = nullptr;
chip::Callback::Callback<DefaultFailureCallback> * mOnFailureCallback_101 = nullptr;
bool mIsFailureExpected_101 = 1;

CHIP_ERROR TestSendClusterTestClusterCommandTest_101()
{
ChipLogProgress(chipTool, "Test Cluster - Send Test Command to unsupported endpoint: Sending command...");

mOnFailureCallback_101 =
new chip::Callback::Callback<DefaultFailureCallback>(OnTestSendClusterTestClusterCommandTest_101_FailureResponse, this);
mOnSuccessCallback_101 =
new chip::Callback::Callback<SuccessCallback_101>(OnTestSendClusterTestClusterCommandTest_101_SuccessResponse, this);

chip::Controller::TestClusterCluster cluster;
cluster.Associate(mDevice, 200);

CHIP_ERROR err = CHIP_NO_ERROR;

err = cluster.Test(mOnSuccessCallback_101->Cancel(), mOnFailureCallback_101->Cancel());

if (CHIP_NO_ERROR != err)
{
delete mOnFailureCallback_101;
delete mOnSuccessCallback_101;
}

return err;
}

static void OnTestSendClusterTestClusterCommandTest_101_FailureResponse(void * context, uint8_t status)
{
ChipLogProgress(chipTool, "Test Cluster - Send Test Command to unsupported endpoint: Failure Response");

TestCluster * runner = reinterpret_cast<TestCluster *>(context);

delete runner->mOnFailureCallback_101;
delete runner->mOnSuccessCallback_101;

if (runner->mIsFailureExpected_101 == false)
{
ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback");
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL);
return;
}

runner->NextTest();
}

static void OnTestSendClusterTestClusterCommandTest_101_SuccessResponse(void * context)
{
ChipLogProgress(chipTool, "Test Cluster - Send Test Command to unsupported endpoint: Success Response");

TestCluster * runner = reinterpret_cast<TestCluster *>(context);

delete runner->mOnFailureCallback_101;
delete runner->mOnSuccessCallback_101;

if (runner->mIsFailureExpected_101 == true)
{
ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback");
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL);
return;
}

runner->NextTest();
}
};

class Test_3_1_1 : public TestCommand
Expand Down
17 changes: 17 additions & 0 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,23 @@ - (void)testSendClusterTestCluster_000100_WriteAttribute

[self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil];
}
- (void)testSendClusterTestCluster_000101_Test
{
XCTestExpectation * expectation = [self expectationWithDescription:@"Send Test Command to unsupported endpoint"];
CHIPDevice * device = GetPairedDevice(kDeviceId);
dispatch_queue_t queue = dispatch_get_main_queue();
CHIPTestCluster * cluster = [[CHIPTestCluster alloc] initWithDevice:device endpoint:200 queue:queue];
XCTAssertNotNil(cluster);

[cluster test:^(NSError * err, NSDictionary * values) {
NSLog(@"Send Test Command to unsupported endpoint Error: %@", err);

XCTAssertEqual(err.code, 1);
[expectation fulfill];
}];

[self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil];
}

- (void)testSendClusterTest_3_1_1_000000_ReadAttribute
{
Expand Down

0 comments on commit 1747160

Please sign in to comment.