mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[test] Add integration test for light effect memory corruption fix (#10417)
This commit is contained in:
		| @@ -56,10 +56,29 @@ light: | |||||||
|     warm_white_color_temperature: 2000 K |     warm_white_color_temperature: 2000 K | ||||||
|     constant_brightness: true |     constant_brightness: true | ||||||
|     effects: |     effects: | ||||||
|  |       # Use default parameters: | ||||||
|       - random: |       - random: | ||||||
|           name: "Random Effect" |       # Customize parameters - use longer names to potentially trigger buffer issues | ||||||
|  |       - random: | ||||||
|  |           name: "My Very Slow Random Effect With Long Name" | ||||||
|  |           transition_length: 30ms | ||||||
|  |           update_interval: 30ms | ||||||
|  |       - random: | ||||||
|  |           name: "My Fast Random Effect That Changes Quickly" | ||||||
|  |           transition_length: 4ms | ||||||
|  |           update_interval: 5ms | ||||||
|  |       - random: | ||||||
|  |           name: "Random Effect With Medium Length Name Here" | ||||||
|           transition_length: 100ms |           transition_length: 100ms | ||||||
|           update_interval: 200ms |           update_interval: 200ms | ||||||
|  |       - random: | ||||||
|  |           name: "Another Random Effect With Different Parameters" | ||||||
|  |           transition_length: 2ms | ||||||
|  |           update_interval: 3ms | ||||||
|  |       - random: | ||||||
|  |           name: "Yet Another Random Effect To Test Memory" | ||||||
|  |           transition_length: 15ms | ||||||
|  |           update_interval: 20ms | ||||||
|       - strobe: |       - strobe: | ||||||
|           name: "Strobe Effect" |           name: "Strobe Effect" | ||||||
|       - pulse: |       - pulse: | ||||||
| @@ -73,6 +92,17 @@ light: | |||||||
|     red: test_red |     red: test_red | ||||||
|     green: test_green |     green: test_green | ||||||
|     blue: test_blue |     blue: test_blue | ||||||
|  |     effects: | ||||||
|  |       # Same random effects to test for cross-contamination | ||||||
|  |       - random: | ||||||
|  |       - random: | ||||||
|  |           name: "RGB Slow Random" | ||||||
|  |           transition_length: 20ms | ||||||
|  |           update_interval: 25ms | ||||||
|  |       - random: | ||||||
|  |           name: "RGB Fast Random" | ||||||
|  |           transition_length: 2ms | ||||||
|  |           update_interval: 3ms | ||||||
|  |  | ||||||
|   - platform: binary |   - platform: binary | ||||||
|     name: "Test Binary Light" |     name: "Test Binary Light" | ||||||
|   | |||||||
| @@ -108,14 +108,51 @@ async def test_light_calls( | |||||||
|         # Wait for flash to end |         # Wait for flash to end | ||||||
|         state = await wait_for_state_change(rgbcw_light.key) |         state = await wait_for_state_change(rgbcw_light.key) | ||||||
|  |  | ||||||
|         # Test 13: effect only |         # Test 13: effect only - test all random effects | ||||||
|         # First ensure light is on |         # First ensure light is on | ||||||
|         client.light_command(key=rgbcw_light.key, state=True) |         client.light_command(key=rgbcw_light.key, state=True) | ||||||
|         state = await wait_for_state_change(rgbcw_light.key) |         state = await wait_for_state_change(rgbcw_light.key) | ||||||
|         # Now set effect |  | ||||||
|         client.light_command(key=rgbcw_light.key, effect="Random Effect") |         # Test 13a: Default random effect (no name, gets default name "Random") | ||||||
|  |         client.light_command(key=rgbcw_light.key, effect="Random") | ||||||
|         state = await wait_for_state_change(rgbcw_light.key) |         state = await wait_for_state_change(rgbcw_light.key) | ||||||
|         assert state.effect == "Random Effect" |         assert state.effect == "Random" | ||||||
|  |  | ||||||
|  |         # Test 13b: Slow random effect with long name | ||||||
|  |         client.light_command( | ||||||
|  |             key=rgbcw_light.key, effect="My Very Slow Random Effect With Long Name" | ||||||
|  |         ) | ||||||
|  |         state = await wait_for_state_change(rgbcw_light.key) | ||||||
|  |         assert state.effect == "My Very Slow Random Effect With Long Name" | ||||||
|  |  | ||||||
|  |         # Test 13c: Fast random effect with long name | ||||||
|  |         client.light_command( | ||||||
|  |             key=rgbcw_light.key, effect="My Fast Random Effect That Changes Quickly" | ||||||
|  |         ) | ||||||
|  |         state = await wait_for_state_change(rgbcw_light.key) | ||||||
|  |         assert state.effect == "My Fast Random Effect That Changes Quickly" | ||||||
|  |  | ||||||
|  |         # Test 13d: Random effect with medium length name | ||||||
|  |         client.light_command( | ||||||
|  |             key=rgbcw_light.key, effect="Random Effect With Medium Length Name Here" | ||||||
|  |         ) | ||||||
|  |         state = await wait_for_state_change(rgbcw_light.key) | ||||||
|  |         assert state.effect == "Random Effect With Medium Length Name Here" | ||||||
|  |  | ||||||
|  |         # Test 13e: Another random effect | ||||||
|  |         client.light_command( | ||||||
|  |             key=rgbcw_light.key, | ||||||
|  |             effect="Another Random Effect With Different Parameters", | ||||||
|  |         ) | ||||||
|  |         state = await wait_for_state_change(rgbcw_light.key) | ||||||
|  |         assert state.effect == "Another Random Effect With Different Parameters" | ||||||
|  |  | ||||||
|  |         # Test 13f: Yet another random effect | ||||||
|  |         client.light_command( | ||||||
|  |             key=rgbcw_light.key, effect="Yet Another Random Effect To Test Memory" | ||||||
|  |         ) | ||||||
|  |         state = await wait_for_state_change(rgbcw_light.key) | ||||||
|  |         assert state.effect == "Yet Another Random Effect To Test Memory" | ||||||
|  |  | ||||||
|         # Test 14: stop effect |         # Test 14: stop effect | ||||||
|         client.light_command(key=rgbcw_light.key, effect="None") |         client.light_command(key=rgbcw_light.key, effect="None") | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user