package com.fireworksdk.bridge.models import org.json.JSONObject import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Test /** * Covers the play icon configuration plumbing shared by VideoFeed, CircleStory and PlayerDeck, * which all funnel into [FWVideoFeedConfigModel.FWPlayIconModel]. */ class FWVideoFeedConfigModelPlayIconTest { @Test fun `deserialize maps every play icon field`() { val json = JSONObject( mapOf( "playIcon" to mapOf( "hidden" to true, "iconWidth" to 48, "imageName" to "custom_play", ), ), ) val playIcon = FWVideoFeedConfigModelDeserializer.deserialize(json)?.playIcon assertEquals( FWVideoFeedConfigModel.FWPlayIconModel( hidden = true, iconWidth = 48, imageName = "custom_play", ), playIcon, ) } @Test fun `deserialize leaves appearance unset when the host only sizes the icon`() { val json = JSONObject(mapOf("playIcon" to mapOf("iconWidth" to 36))) val playIcon = FWVideoFeedConfigModelDeserializer.deserialize(json)?.playIcon assertEquals(36, playIcon?.iconWidth) assertNull(playIcon?.imageName) } @Test fun `deserialize leaves play icon null when the host omits it`() { val json = JSONObject(mapOf("backgroundColor" to "#000000")) assertNull(FWVideoFeedConfigModelDeserializer.deserialize(json)?.playIcon) } @Test fun `play icon survives a serialize deserialize round trip`() { val model = FWVideoFeedConfigModel( playIcon = FWVideoFeedConfigModel.FWPlayIconModel( hidden = false, iconWidth = 48, imageName = "custom_play", ), ) val restored = FWVideoFeedConfigModelDeserializer.deserialize( FWVideoFeedConfigModelSerializer.serialize(model), ) assertEquals(model.playIcon, restored?.playIcon) } }