-
Notifications
You must be signed in to change notification settings - Fork 0
Add simulated Broadlink device for E2E testing #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
96cc530
Initial plan
Copilot 2878e1e
Add simulated Broadlink device infrastructure and test integration
Copilot eb3f11b
Fix code warnings and build errors in simulated Broadlink device
Copilot b553a0d
Add configurable discovery endpoint for Broadlink testing
Copilot c83ec96
Fix UDP client SendAsync calls to use correct API
Copilot a6cff4c
Fix simulated Broadlink device discovery and verification
Copilot 0e9cb94
Add comprehensive documentation for simulated devices
Copilot e36cc05
Address code review feedback: fix terminology, remove unused params, …
Copilot 7e3b34f
Refactor simulated devices per code review feedback
Copilot 0146614
Update documentation to link to code files instead of embedding samples
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
test/AdaptiveRemote.EndToEndTests.Features/BroadlinkDevice.feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| Feature: Broadlink Device Integration | ||
| As a user | ||
| I want the application to communicate with Broadlink IR devices | ||
| So that I can control my TV and AV equipment using the adaptive remote | ||
|
|
||
| Scenario: Broadlink receives Power command | ||
| Given the application is not running | ||
| When I start the application | ||
| Then I should see the application in the Ready phase | ||
| And I should not see any warning or error messages in the logs | ||
| When I click on the 'Power' button | ||
| Then I should see the Broadlink device recorded at least one inbound packet | ||
| And the recorded Broadlink packet's raw payload should not be empty | ||
| And no Broadlink packets should be marked as malformed | ||
| When I click on the 'Exit' button | ||
| And I wait for the application to shut down | ||
| Then I should not see any warning or error messages in the logs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| using AdaptiveRemote.EndtoEndTests; | ||
| using AdaptiveRemote.EndtoEndTests.SimulatedBroadlink; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
| using Reqnroll; | ||
|
|
||
| namespace AdaptiveRemote.EndToEndTests.Steps; | ||
|
|
||
| [Binding] | ||
| public class BroadlinkSteps : StepsBase | ||
| { | ||
| [Then(@"I should see the Broadlink device recorded at least one inbound packet")] | ||
| public void ThenIShouldSeeTheBroadlinkDeviceRecordedAtLeastOneInboundPacket() | ||
| { | ||
| ISimulatedBroadlinkDevice? device = Environment.Broadlink; | ||
| if (device == null) | ||
| { | ||
| Assert.Fail("Broadlink device is not running"); | ||
| } | ||
|
|
||
| // Poll for packets with a timeout of 10 seconds | ||
| bool found = WaitHelpers.ExecuteWithRetries(device.HasRecordedInboundPacketWithIrData, timeoutInSeconds: 10); | ||
|
|
||
| if (!found) | ||
| { | ||
| string recordedPackets = device.GetRecordedPacketsDebugString(); | ||
| Assert.Fail($"Expected Broadlink device to record at least one inbound packet with IR data, but none were found. Recorded packets: {recordedPackets}"); | ||
| } | ||
|
|
||
| TestContext.WriteLine("Successfully verified Broadlink device recorded inbound packet with IR data"); | ||
| } | ||
|
|
||
| [Then(@"the recorded Broadlink packet's raw payload should not be empty")] | ||
| public void ThenTheRecordedBroadlinkPacketRawPayloadShouldNotBeEmpty() | ||
| { | ||
| ISimulatedBroadlinkDevice? device = Environment.Broadlink; | ||
| if (device == null) | ||
| { | ||
| Assert.Fail("Broadlink device is not running"); | ||
| } | ||
|
|
||
| RecordedPacket? irPacket = device.GetFirstPacketWithIrData(); | ||
|
|
||
| if (irPacket == null) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| { | ||
| Assert.Fail("No packet with IR payload was recorded"); | ||
| } | ||
|
|
||
| Assert.IsTrue(irPacket.RawPayload!.Length > 0, "IR payload should not be empty"); | ||
| TestContext.WriteLine($"IR payload size: {irPacket.RawPayload.Length} bytes"); | ||
| } | ||
|
|
||
| [Then(@"no Broadlink packets should be marked as malformed")] | ||
| public void ThenNoBroadlinkPacketsShouldBeMarkedAsMalformed() | ||
| { | ||
| ISimulatedBroadlinkDevice? device = Environment.Broadlink; | ||
| if (device == null) | ||
| { | ||
| Assert.Fail("Broadlink device is not running"); | ||
| } | ||
|
|
||
| RecordedPacket? malformedPacket = device.GetFirstMalformedPacket(); | ||
|
|
||
| if (malformedPacket != null) | ||
| { | ||
| Assert.Fail($"Found malformed packet: {malformedPacket.DebugDescription}"); | ||
| } | ||
|
|
||
| TestContext.WriteLine("No malformed packets found"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally there would not be so much logic in the Step implementations themselves. The logic should be in the TestServices assembly, and the step definitions should be about translating and validating steps and parameters. That way if I need to build non-Gherkin tests, all the logic is available.
I'm not sure the best way to handle this. Either the logic could be build directly into the SimulatedBroadlinkDevice itself, or it could be build as extension methods on ISimulatedBroadlinkDevice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved logic to extension methods in
ISimulatedBroadlinkDeviceExtensions.cs-HasRecordedInboundPacketWithIrData(),GetRecordedPacketsDebugString(),GetFirstPacketWithIrData(), andGetFirstMalformedPacket(). Step definitions now just call these methods. (7e3b34f)