Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ val notificationItem = NotificationItem(1, 1636389288682, "testing", "{\"message
val wearDeviceName = "Device Name"

val attributes: Map<String, *> = mapOf(
"friendly_name" to "Testing",
"icon" to "mdi:cellphone",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ private val previewEntityWidgetConfigureState = EntityWidgetConfigureState(
},
entityDisplayState = Loaded(listOf(EntityDisplayWithContext(EntityDisplayWithoutContext(previewEntity1)))),
selectedEntityId = previewEntity1.entityId,
availableAttributes = listOf("brightness", "friendly_name"),
availableAttributes = listOf("brightness", "power"),
selectedAttributeIds = listOf("brightness"),
label = "Office light",
textSize = "30",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ private val previewEntityWidgetConfigureState = EntityWidgetConfigureState(
EntityDisplayWithContext(
EntityDisplayWithoutContext(
previewEntity1,
name = "Preview Entity 1",
),
),
),
),
selectedEntityId = previewEntity1.entityId,
availableAttributes = listOf("brightness", "friendly_name"),
availableAttributes = listOf("brightness", "power"),
selectedAttributeIds = listOf("brightness"),
label = "Office light",
textSize = "30",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ class EntityWidgetConfigureScreenTest {
fun `Given an unselected attribute when its chip is clicked then onAttributeAdded is triggered`() {
composeTestRule.apply {
testScreen(configuredState) {
onNodeWithText("friendly_name").performScrollTo().performClick()
assertEquals("friendly_name", attributeAdded)
onNodeWithText("power").performScrollTo().performClick()
assertEquals("power", attributeAdded)
}
}
}
Expand Down Expand Up @@ -318,7 +318,7 @@ class EntityWidgetConfigureScreenTest {
val ENTITY = Entity(
entityId = "light.office",
state = "on",
attributes = mapOf("friendly_name" to "Office light"),
attributes = mapOf("power" to "50W"),
lastChanged = LocalDateTime.MIN,
lastUpdated = LocalDateTime.MIN,
)
Expand All @@ -331,7 +331,7 @@ class EntityWidgetConfigureScreenTest {

val configuredState = newWidgetState.copy(
selectedEntityId = ENTITY.entityId,
availableAttributes = listOf("brightness", "friendly_name"),
availableAttributes = listOf("brightness", "power"),
selectedAttributeIds = listOf("brightness"),
label = "Office light",
stateSeparator = " - ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class EntityWidgetConfigureViewModelTest {
assertTrue(state.isUpdateWidget)
assertEquals(serverId, state.selectedServerId)
assertEquals(entity.entityId, state.selectedEntityId)
assertEquals(listOf("brightness", "friendly_name"), state.selectedAttributeIds)
assertEquals(listOf("brightness", "power"), state.selectedAttributeIds)
assertEquals("Office light", state.label)
assertEquals("28", state.textSize)
assertEquals(" - ", state.stateSeparator)
Expand Down Expand Up @@ -193,12 +193,12 @@ class EntityWidgetConfigureViewModelTest {
fun `Given custom attributes when attributes are added then input is parsed and cleared`() = runTest {
val viewModel = createViewModel(entity.entityId)
viewModel.onAttributeAdded("brightness")
viewModel.onCustomAttributeChanged("friendly_name, unit_of_measurement, brightness")
viewModel.onCustomAttributeChanged("power, unit_of_measurement, brightness")

viewModel.onCustomAttributesAdded()

val state = viewModel.state.value
assertEquals(listOf("brightness", "friendly_name", "unit_of_measurement"), state.selectedAttributeIds)
assertEquals(listOf("brightness", "power", "unit_of_measurement"), state.selectedAttributeIds)
assertEquals("", state.customAttribute)
}

Expand Down Expand Up @@ -234,7 +234,7 @@ class EntityWidgetConfigureViewModelTest {
id = widgetId,
serverId = serverId,
entityId = entity.entityId,
attributeIds = "brightness,friendly_name",
attributeIds = "brightness,power",
label = "Office light",
textSize = 28F,
stateSeparator = " - ",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FriendlyStateTest {
private fun createEntity(
entityId: String = "light.living_room",
state: String = "on",
attributes: Map<String, Any?> = mapOf("friendly_name" to "Living Room Light"),
attributes: Map<String, Any?> = emptyMap(),
) = Entity(
entityId = entityId,
state = state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class CompressedEntityTest {
val lastChanged = 42.0
val lastUpdated = 41.1
val attributes = mapOf(
"friendly_name" to Random.nextInt().toString(),
"dummy" to Random.nextInt().toString(),
"icon" to Random.nextInt().toString(),
)
val rawData = """{"s":"$state","lc":$lastChanged,"lu":$lastUpdated,"a":{"friendly_name":"${attributes["friendly_name"]}","icon":"${attributes["icon"]}"}}"""
val rawData = """{"s":"$state","lc":$lastChanged,"lu":$lastUpdated,"a":{"dummy":"${attributes["dummy"]}","icon":"${attributes["icon"]}"}}"""
val expected = CompressedEntityState(state = JsonPrimitive(state), attributes = attributes, lastChanged = lastChanged, lastUpdated = lastUpdated)
assertEquals(expected, kotlinJsonMapper.decodeFromString<CompressedEntityState>(rawData))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import io.homeassistant.companion.android.data.SimplifiedEntity
import java.time.LocalDateTime

val attributes: Map<String, Any> = mapOf(
"friendly_name" to "Testing",
"icon" to "mdi:cellphone",
)

val lightAttributes: Map<String, Any> = mapOf(
"friendly_name" to "Light",
"icon" to "mdi:light-bulb",
"supported_color_modes" to listOf("color_temp", "hs"),
"supported_features" to 36,
Expand All @@ -24,7 +22,6 @@ val lightAttributes: Map<String, Any> = mapOf(
)

val fanAttributes: Map<String, Any> = mapOf(
"friendly_name" to "Fan",
"icon" to "mdi:fan",
"supported_features" to 1,
"percentage" to 20,
Expand All @@ -45,10 +42,10 @@ val previewEntityList = mapOf(
val previewFavoritesList = listOf("light.first", "scene.first")

val simplifiedEntity =
SimplifiedEntity(previewEntity1.entityId, attributes["friendly_name"].toString(), attributes["icon"].toString())
SimplifiedEntity(previewEntity1.entityId, previewEntity1.entityId, attributes["icon"].toString())

val playPreviewEntityScene1 = Entity("scene.first", "on", mapOf("friendly_name" to "Cleaning mode"), dateTime, dateTime)
val playPreviewEntityScene2 = Entity("scene.second", "on", mapOf("friendly_name" to "Colorful"), dateTime, dateTime)
val playPreviewEntityScene3 = Entity("scene.third", "on", mapOf("friendly_name" to "Goodbye"), dateTime, dateTime)
val playPreviewEntityScene1 = Entity("scene.first", "on", emptyMap(), dateTime, dateTime)
val playPreviewEntityScene2 = Entity("scene.second", "on", emptyMap(), dateTime, dateTime)
val playPreviewEntityScene3 = Entity("scene.third", "on", emptyMap(), dateTime, dateTime)

val sensorList = listOf(BatterySensorManager.isChargingState)
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class EntityListViewPreviewsTest {
EntityViewList(
entityLists = mapOf(
stringResource(R.string.lights) to listOf(
EntityDisplayWithoutContext(previewEntity1),
EntityDisplayWithoutContext(previewEntity2),
EntityDisplayWithoutContext(previewEntity1, name = "Main"),
EntityDisplayWithoutContext(previewEntity2, name = "Floor secondary"),
),
),
entityListsOrder = listOf(stringResource(R.string.lights)),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading