Skip to content

Commit 4cb2a9b

Browse files
shaoltan-amazonaustina-csa
authored andcommitted
Add test logic to Matter Casting Automation test script for commissioner-generated-passcode flow. (project-chip#34079)
1 parent feb128e commit 4cb2a9b

File tree

3 files changed

+147
-13
lines changed

3 files changed

+147
-13
lines changed

.github/workflows/examples-linux-tv-casting-app.yaml

+11-1
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,22 @@ jobs:
6363
./scripts/run_in_build_env.sh \
6464
"scripts/examples/gn_build_example.sh examples/tv-casting-app/linux/ out/tv-casting-app chip_casting_simplified=true"
6565
66-
- name: Test casting from Linux tv-casting-app to Linux tv-app
66+
- name:
67+
Test casting from Linux tv-casting-app to Linux tv-app -
68+
Commissionee Generated Passcode
6769
run: |
6870
./scripts/run_in_build_env.sh \
6971
"python3 ./scripts/tests/run_tv_casting_test.py"
7072
timeout-minutes: 2 # Comment this out to debug if GitHub Action times out.
7173

74+
- name:
75+
Test casting from Linux tv-casting-app to Linux tv-app -
76+
Commissioner Generated Passcode
77+
run: |
78+
./scripts/run_in_build_env.sh \
79+
"python3 ./scripts/tests/run_tv_casting_test.py --commissioner-generated-passcode=True"
80+
timeout-minutes: 2 # Comment this out to debug if GitHub Action times out.
81+
7282
- name: Uploading Size Reports
7383
uses: ./.github/actions/upload-size-reports
7484
if: ${{ !env.ACT }}

scripts/tests/linux/tv_casting_test_sequences.py

+113-5
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@
6767

6868
# Values that identify the Linux tv-app and are noted in the 'Device Configuration' in the Linux tv-app output
6969
# as well as under the 'Discovered Commissioner' details in the Linux tv-casting-app output.
70-
VENDOR_ID = 0xFFF1 # Spec 7.20.2.1 MEI code: test vendor IDs are 0xFFF1 to 0xFFF4
71-
PRODUCT_ID = 0x8001 # Test product id
72-
DEVICE_TYPE_CASTING_VIDEO_PLAYER = 0x23 # Device type library 10.3: Casting Video Player
70+
VENDOR_ID = 0xFFF1 # 0xFFF1 = 65521; Spec 7.20.2.1 MEI code: test vendor IDs are 0xFFF1 to 0xFFF4
71+
PRODUCT_ID = 0x8001 # 0x8001 = 32769 = Test product id
72+
DEVICE_TYPE_CASTING_VIDEO_PLAYER = 0x23 # 0x23 = 35 = Device type library 10.3: Casting Video Player
73+
74+
# 0x457 = 1111 = Target Content Application Vendor ID for the commissioner generated passcode flow
75+
COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID = 0x457
76+
COMMISSIONER_GENERATED_PASSCODE = '0x00BC_614E' # 0x00BC_614E = 12345678 = Default commissioner generated passcode
7377

7478
# Value to verify the subscription state against in the Linux tv-casting-app output.
7579
ATTRIBUTE_CURRENT_PLAYBACK_STATE = 0x0000_0000 # Application Cluster Spec 6.10.6 Attribute ID: Current State of Playback
@@ -94,7 +98,7 @@
9498
Step(app=App.TV_CASTING_APP, output_msg=['Discovered CastingPlayer #0', f'Product ID: {PRODUCT_ID}', f'Vendor ID: {VENDOR_ID}',
9599
f'Device Type: {DEVICE_TYPE_CASTING_VIDEO_PLAYER}', 'Supports Commissioner Generated Passcode: true']),
96100

97-
# Send `cast request {valid_discovered_commissioner_number}\n` command to the tv-casting-app subprocess.
101+
# Send `cast request {valid_discovered_castingplayer_number}\n` command to the tv-casting-app subprocess.
98102
Step(app=App.TV_CASTING_APP, input_cmd='cast request 0\n'),
99103

100104
# Validate that the tv-casting-app begins the commissioning process.
@@ -112,7 +116,7 @@
112116
# Validate that we received the instructions on the tv-app output for sending the `controller ux ok` command.
113117
Step(app=App.TV_APP, output_msg=['Via Shell Enter: controller ux ok|cancel']),
114118

115-
# Send `controller ux ok` command to the tv-app subprocess.
119+
# Send `controller ux ok\n` command to the tv-app subprocess.
116120
Step(app=App.TV_APP, input_cmd='controller ux ok\n'),
117121

118122
# Validate that pairing succeeded between the tv-casting-app and the tv-app.
@@ -140,6 +144,110 @@
140144
# Signal to stop the tv-casting-app as we finished validation.
141145
Step(app=App.TV_CASTING_APP, input_cmd=STOP_APP),
142146

147+
# Signal to stop the tv-app as we finished validation.
148+
Step(app=App.TV_APP, input_cmd=STOP_APP)
149+
]
150+
),
151+
Sequence(
152+
name='commissioner_generated_passcode_test',
153+
steps=[
154+
# Signal to start the tv-app.
155+
Step(app=App.TV_APP, input_cmd=START_APP),
156+
157+
# Validate that the tv-app is up and running.
158+
Step(app=App.TV_APP, timeout_sec=APP_MAX_START_WAIT_SEC, output_msg=['Started commissioner']),
159+
160+
# Signal to start the tv-casting-app.
161+
Step(app=App.TV_CASTING_APP, input_cmd=START_APP),
162+
163+
# Validate that the server is properly initialized in the tv-casting-app output.
164+
Step(app=App.TV_CASTING_APP, timeout_sec=APP_MAX_START_WAIT_SEC, output_msg=['Server initialization complete']),
165+
166+
# Validate that there is a valid discovered casting player with {PRODUCT_ID}, {VENDOR_ID}, {DEVICE_TYPE_CASTING_VIDEO_PLAYER}, and the
167+
# `Commissioner Generated Passcode` flag is set to true in the tv-casting-app output.
168+
Step(app=App.TV_CASTING_APP, output_msg=['Discovered CastingPlayer #0', f'Product ID: {PRODUCT_ID}', f'Vendor ID: {VENDOR_ID}',
169+
f'Device Type: {DEVICE_TYPE_CASTING_VIDEO_PLAYER}', 'Supports Commissioner Generated Passcode: true']),
170+
171+
# Send `cast request {valid_discovered_castingplayer_number} commissioner-generated-passcode\n` command to the tv-casting-app subprocess.
172+
Step(app=App.TV_CASTING_APP, input_cmd='cast request 0 commissioner-generated-passcode\n'),
173+
174+
# Validate that the tv-casting-app begins the commissioning process.
175+
Step(app=App.TV_CASTING_APP, output_msg=[
176+
'CastingPlayer::VerifyOrEstablishConnection() calling OpenBasicCommissioningWindow()']),
177+
178+
# Validate that the `IdentificationDeclaration` message sent from the tv-casting-app to the tv-app will contain the following entries:
179+
# mCommissionerPasscode: true -> This flag instructs the commissioner to use the commissioner-generated-passcode flow for commissioning.
180+
# mCommissionerPasscodeReady: false -> This flag indicates that the commissionee has not obtained the commissioner passcode from the user and
181+
# thus is not ready for commissioning.
182+
# Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID} -> The initial VENDOR_ID of the casting player will be overridden to {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}.
183+
# Otherwise we will enter the commissionee-generated-passcode flow.
184+
Step(app=App.TV_CASTING_APP, output_msg=['IdentificationDeclarationOptions::LogDetail()', 'IdentificationDeclarationOptions::mCommissionerPasscode: true',
185+
'IdentificationDeclarationOptions::mCommissionerPasscodeReady: false', 'IdentificationDeclarationOptions::TargetAppInfos list:', f'TargetAppInfo 1, Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}']),
186+
187+
# Validate that we received the cast request from the tv-casting-app on the tv-app output.
188+
Step(app=App.TV_APP,
189+
output_msg=['------PROMPT USER: Test TV casting app is requesting permission to cast to this TV, approve?']),
190+
191+
# Validate that we received the instructions on the tv-app output for sending the `controller ux ok` command.
192+
Step(app=App.TV_APP, output_msg=['Via Shell Enter: controller ux ok|cancel']),
193+
194+
# Send `controller ux ok` command to the tv-app subprocess.
195+
Step(app=App.TV_APP, input_cmd='controller ux ok\n'),
196+
197+
# Validate that the tv-app sent a message to the tv-casting-app indicating that the tv-app is now displaying the passcode to the user.
198+
Step(app=App.TV_APP, output_msg=['Commissioner Declaration Start',
199+
'commissioner passcode: true', 'Commissioner Declaration End']),
200+
201+
# Validate that we received the cast request with the casting passcode on the tv-app output.
202+
Step(app=App.TV_APP, output_msg=[
203+
f'------PROMPT USER: Test TV casting app is requesting permission to cast to this TV. Casting passcode: [{COMMISSIONER_GENERATED_PASSCODE}].']),
204+
205+
# Validate that the tv-casting-app received the message from the tv-app indicating that the tv-app is now displaying the passcode to the user.
206+
Step(app=App.TV_CASTING_APP, output_msg=['Commissioner Declaration Start',
207+
'commissioner passcode: true', 'Commissioner Declaration End']),
208+
209+
# Validate that the user is prompted to input passcode from the tv-app on the tv-casting-app output.
210+
Step(app=App.TV_CASTING_APP, output_msg=['Awaiting user input', 'Input the Commissioner-Generated passcode displayed on the CastingPlayer UX.',
211+
f'cast setcommissionerpasscode {int(COMMISSIONER_GENERATED_PASSCODE, 16)}', 'Awaiting user input']),
212+
213+
# Send `cast setcommissionerpasscode {COMMISSIONER_GENERATED_PASSCODE}\n` to the tv-casting-app subprocess.
214+
Step(app=App.TV_CASTING_APP, input_cmd=f'cast setcommissionerpasscode {int(COMMISSIONER_GENERATED_PASSCODE, 16)}\n'),
215+
216+
# Validate the commissioner passcode that the user entered on the tv-casting-app output.
217+
Step(app=App.TV_CASTING_APP, output_msg=[
218+
f'CommandHandler() setcommissionerpasscode user entered passcode: {int(COMMISSIONER_GENERATED_PASSCODE, 16)}']),
219+
220+
# Validate that the `IdentificationDeclaration` message sent from the tv-casting-app to the tv-app will contain the following entries:
221+
# mCommissionerPasscode: true -> This flag instructs the commissioner to use the commissioner-generated-passcode flow for commissioning.
222+
# mCommissionerPasscodeReady: true -> This flag indicates that the commissionee has obtained the commissioner passcode from the user and
223+
# thus is ready for commissioning.
224+
# Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID} -> The initial VENDOR_ID of the casting player will be overridden to {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}.
225+
# Otherwise we will enter the commissionee-generated-passcode flow.
226+
Step(app=App.TV_CASTING_APP, output_msg=['IdentificationDeclarationOptions::LogDetail()', 'IdentificationDeclarationOptions::mCommissionerPasscode: true',
227+
'IdentificationDeclarationOptions::mCommissionerPasscodeReady: true', 'IdentificationDeclarationOptions::TargetAppInfos list:', f'TargetAppInfo 1, Vendor ID: {COMMISSIONER_GENERATED_PASSCODE_VENDOR_ID}']),
228+
229+
# Validate that pairing succeeded between the tv-casting-app and the tv-app.
230+
Step(app=App.TV_APP, output_msg=['Secure Pairing Success']),
231+
232+
# Validate that the connection succeeded in the tv-casting-app output.
233+
Step(app=App.TV_CASTING_APP, output_msg=['Successfully connected to CastingPlayer']),
234+
235+
# Validate that commissioning succeeded in the tv-app output.
236+
Step(app=App.TV_APP, output_msg=['------PROMPT USER: commissioning success']),
237+
238+
# Validate that we are able to subscribe to the media playback cluster by reading the CurrentState value and that it matches {ATTRIBUTE_CURRENT_PLAYBACK_STATE}.
239+
Step(app=App.TV_CASTING_APP, output_msg=[f'Read CurrentState value: {ATTRIBUTE_CURRENT_PLAYBACK_STATE}']),
240+
241+
# Validate the LaunchURL in the tv-app output.
242+
Step(app=App.TV_APP,
243+
output_msg=['ContentLauncherManager::HandleLaunchUrl TEST CASE ContentURL=https://www.test.com/videoid DisplayString=Test video']),
244+
245+
# Validate the LaunchURL in the tv-casting-app output.
246+
Step(app=App.TV_CASTING_APP, output_msg=['LaunchURL Success with response.data: exampleData']),
247+
248+
# Signal to stop the tv-casting-app as we finished validation.
249+
Step(app=App.TV_CASTING_APP, input_cmd=STOP_APP),
250+
143251
# Signal to stop the tv-app as we finished validation.
144252
Step(app=App.TV_APP, input_cmd=STOP_APP)
145253
]

scripts/tests/run_tv_casting_test.py

+23-7
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,26 @@ def run_test_sequence_steps(
270270
@click.command()
271271
@click.option('--tv-app-rel-path', type=str, default='out/tv-app/chip-tv-app', help='Path to the Linux tv-app executable.')
272272
@click.option('--tv-casting-app-rel-path', type=str, default='out/tv-casting-app/chip-tv-casting-app', help='Path to the Linux tv-casting-app executable.')
273-
def test_casting_fn(tv_app_rel_path, tv_casting_app_rel_path):
273+
@click.option('--commissioner-generated-passcode', type=bool, default=False, help='Enable the commissioner generated passcode test flow.')
274+
def test_casting_fn(tv_app_rel_path, tv_casting_app_rel_path, commissioner_generated_passcode):
274275
"""Test if the casting experience between the Linux tv-casting-app and the Linux tv-app continues to work.
275276
276-
Default paths for the executables are provided but can be overridden via command line arguments.
277-
For example: python3 run_tv_casting_test.py --tv-app-rel-path=path/to/tv-app
278-
--tv-casting-app-rel-path=path/to/tv-casting-app
277+
By default, it uses the provided executable paths and the commissionee generated passcode flow as the test sequence.
278+
279+
Example usages:
280+
1. Use default paths and test sequence:
281+
python3 run_tv_casting_test.py
282+
283+
2. Use custom executable paths and default test sequence:
284+
python3 run_tv_casting_test.py --tv-app-rel-path=path/to/tv-app --tv-casting-app-rel-path=path/to/tv-casting-app
285+
286+
3. Use default paths and a test sequence that is not the default test sequence (replace `test-sequence-name` with the actual name of the test sequence):
287+
python3 run_tv_casting_test.py --test-sequence-name=True
288+
289+
4. Use custom executable paths and a test sequence that is not the default test sequence (replace `test-sequence-name` with the actual name of the test sequence):
290+
python3 run_tv_casting_test.py --tv-app-rel-path=path/to/tv-app --tv-casting-app-rel-path=path/to/tv-casting-app --test-sequence-name=True
291+
292+
Note: In order to enable a new test sequence, we also need to define a @click.option() entry for the test sequence.
279293
"""
280294

281295
# Store the log files to a temporary directory.
@@ -288,15 +302,17 @@ def test_casting_fn(tv_app_rel_path, tv_casting_app_rel_path):
288302
# Get all the test sequences.
289303
test_sequences = Sequence.get_test_sequences()
290304

291-
# Get the test sequence of interest.
292-
test_sequence = Sequence.get_test_sequence_by_name(test_sequences, 'commissionee_generated_passcode_test')
305+
# Get the test sequence that we are interested in validating.
306+
test_sequence_name = 'commissionee_generated_passcode_test'
307+
if commissioner_generated_passcode:
308+
test_sequence_name = 'commissioner_generated_passcode_test'
309+
test_sequence = Sequence.get_test_sequence_by_name(test_sequences, test_sequence_name)
293310

294311
if not test_sequence:
295312
logging.error('No test sequence found by the test sequence name provided.')
296313
handle_casting_failure(None, [])
297314

298315
# At this point, we have retrieved the test sequence of interest.
299-
test_sequence_name = test_sequence.name
300316
test_sequence_steps = test_sequence.steps
301317

302318
# Configure command options to disable stdout buffering during tests.

0 commit comments

Comments
 (0)