Skip to content

Commit

Permalink
Add test cases for matter-lock driver
Browse files Browse the repository at this point in the history
Signed-off-by: Hunsup Jung <[email protected]>
  • Loading branch information
HunsupJung committed Dec 24, 2024
1 parent 4592168 commit fa76eda
Showing 1 changed file with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ end
test.set_test_init_function(test_init)

test.register_coroutine_test(
"Test profile change when battery percent remaining attribute (attribute ID 12) is available",
"Test profile change when attributes related to BAT feature is not available.",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
Expand All @@ -94,7 +94,6 @@ test.register_coroutine_test(
uint32(0),
uint32(1),
uint32(2),
uint32(12),
uint32(31),
uint32(65528),
uint32(65529),
Expand All @@ -104,12 +103,12 @@ test.register_coroutine_test(
})
}
)
mock_device:expect_metadata_update({ profile = "lock-user-pin-battery" })
mock_device:expect_metadata_update({ profile = "lock-user-pin" })
end
)

test.register_coroutine_test(
"Test profile change when battery percent remaining attribute is not available",
"Test profile change when BatChargeLevel attribute is available",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
Expand All @@ -128,6 +127,7 @@ test.register_coroutine_test(
uint32(0),
uint32(1),
uint32(2),
uint32(14), -- BatChargeLevel
uint32(31),
uint32(65528),
uint32(65529),
Expand All @@ -141,4 +141,39 @@ test.register_coroutine_test(
end
)

test.register_coroutine_test(
"Test profile change when BatChargeLevel and BatPercentRemaining attributes are available",
function()
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" })
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" })
test.socket.matter:__expect_send(
{
mock_device.id,
clusters.PowerSource.attributes.AttributeList:read()
}
)
test.wait_for_events()
test.socket.matter:__queue_receive(
{
mock_device.id,
clusters.PowerSource.attributes.AttributeList:build_test_report_data(mock_device, 1,
{
uint32(0),
uint32(1),
uint32(2),
uint32(12), -- BatPercentRemaining
uint32(14), -- BatChargeLevel
uint32(31),
uint32(65528),
uint32(65529),
uint32(65531),
uint32(65532),
uint32(65533),
})
}
)
mock_device:expect_metadata_update({ profile = "lock-user-pin-battery" })
end
)

test.run_registered_tests()

0 comments on commit fa76eda

Please sign in to comment.