How to test with Mock Device Kit on Android
Updated: Jun 22, 2026
Use this guide when your Android project already integrates the Wearables Device Access Toolkit and you need to test without physical glasses.
Copy this prompt into your AI coding tool to add Android Mock Device Kit tests:
Use https://wearables.developer.meta.com/docs/develop/dat/testing-mdk-android/, then use the Wearables MCP endpoint https://mcp.developer.meta.com/wearables to call search_dat_docs for current Android Mock Device Kit test guidance. Inspect my Android tests first, then add the smallest instrumentation coverage for mock device pairing, runtime permissions, camera feed or captured photo behavior, and cleanup. Keep the test deterministic and run the relevant local test command.
Set up Mock Device Kit in instrumentation tests
Create a reusable base rule or test class that configures Mock Device Kit, grants permissions, and resets state.
import android.content.Context
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.platform.app.InstrumentationRegistry
import com.meta.wearable.dat.mockdevice.MockDeviceKit
import com.meta.wearable.dat.mockdevice.api.MockDeviceKitInterface
import org.junit.After
import org.junit.Before
import org.junit.Rule
open class MockDeviceKitTestCase<T : Any>(
private val activityClass: Class<T>
) {
@get:Rule
val scenarioRule = ActivityScenarioRule(activityClass)
protected lateinit var mockDeviceKit: MockDeviceKitInterface
protected lateinit var targetContext: Context
@Before
open fun setUp() {
val instrumentation = InstrumentationRegistry.getInstrumentation()
targetContext = instrumentation.targetContext
mockDeviceKit = MockDeviceKit.getInstance(targetContext)
mockDeviceKit.enable()
grantRuntimePermissions()
}
@After
open fun tearDown() {
mockDeviceKit.disable()
}
private fun grantRuntimePermissions() {
val packageName = targetContext.packageName
val shell = InstrumentationRegistry.getInstrumentation().uiAutomation
shell.executeShellCommand("pm grant $packageName android.permission.BLUETOOTH_CONNECT")
shell.executeShellCommand("pm grant $packageName android.permission.CAMERA")
}
}
Mock camera feeds let you test streaming logic without hardware. The examples below assume assets live under androidTest/assets.
Provide a mock video feed
@Test
fun testCameraStreaming() {
val device = mockDeviceKit.pairGlasses(GlassesModel.RAYBAN_META).getOrThrow()
prepareForStreaming(device)
val camera = device.services.camera
camera.setCameraFeed(getAssetUri("test_video.mp4"))
// Assert on streaming state in your UI
}
@Test
fun testPhotoCapture() {
val device = mockDeviceKit.pairGlasses(GlassesModel.RAYBAN_META).getOrThrow()
prepareForStreaming(device)
val camera = device.services.camera
camera.setCapturedImage(getAssetUri("test_image.png"))
// Assert on capture results
}