/* * Copyright (c) Double Symmetry GmbH * Commercial use requires a license. See https://rntp.dev/pricing */ package com.doublesymmetry.trackplayer import androidx.mediarouter.app.MediaRouteButton import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.uimanager.annotations.ReactProp import io.mockk.mockk import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Test /** * Robolectric can't merge the mediarouter library theme in this module, so the * drawable-tinting happy path (see [CastButtonManager.tintedRemoteIndicator]) is * only verifiable on-device. What we can guard here is the integration contract * that was the actual bug: the manager must expose a `tintColor` color prop to * React, and tinting must no-op safely when no color is supplied. */ class CastButtonManagerTest { @Test fun `exposes a tintColor color prop to react`() { val method = CastButtonManager::class.java.methods.single { it.name == "setTintColor" } val prop = method.getAnnotation(ReactProp::class.java) assertNotNull("setTintColor must be a @ReactProp", prop) assertEquals("tintColor", prop!!.name) assertEquals("Color", prop.customType) } @Test fun `setTintColor with null color is a no-op`() { val manager = CastButtonManager(mockk(relaxed = true)) // A null color must return early without touching the view. manager.setTintColor(mockk(), null) } }