Test widget background type mapping#7010
Closed
sgallese wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds centralized widget background-type parsing via WidgetUtils.getWidgetBackgroundType and covers it with Robolectric tests, then reuses it in entity widget configuration to keep background + text color logic consistent.
Changes:
- Added
WidgetUtilsTestto verify background option string →WidgetBackgroundTypemapping (including fallback behavior). - Refactored
EntityWidgetConfigureActivityto useWidgetUtils.getWidgetBackgroundTypeand derive text color from the resolved enum.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/src/test/kotlin/io/homeassistant/companion/android/widgets/common/WidgetUtilsTest.kt | Adds Robolectric unit tests for widget background type mapping. |
| app/src/main/kotlin/io/homeassistant/companion/android/widgets/entity/EntityWidgetConfigureActivity.kt | Uses WidgetUtils for background type selection and updates text color selection accordingly. |
Comment on lines
+345
to
+346
| val selectedBackgroundOption = binding.backgroundType.selectedItem as String? ?: "" | ||
| val selectedBackgroundType = WidgetUtils.getWidgetBackgroundType(this, selectedBackgroundOption) |
| @RunWith(RobolectricTestRunner::class) | ||
| @Config(application = HiltTestApplication::class) | ||
| class WidgetUtilsTest { | ||
| private val context = ApplicationProvider.getApplicationContext<HiltTestApplication>() |
Contributor
Author
|
Closing because #7007 already covers this migration work. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
WidgetUtils.getWidgetBackgroundType().Refs #6307.
Testing
./gradlew :app:testFullDebugUnitTest --tests '*WidgetUtilsTest*'./gradlew :app:ktlintCheck./gradlew :app:assembleFullDebugEntityWidgetConfigureActivityonPixel_8_API_35and verified the theme dropdown behavior.Manual verification screenshots
Captured from
Pixel_8_API_35.entity-widget-config.mp4