mockdevice-testing

작성자: facebook

물리적 안경 하드웨어 없이 테스트하기 위한 MockDeviceKit

npx skills add https://github.com/facebook/meta-wearables-dat-ios --skill mockdevice-testing

MockDevice Testing (iOS)

Use MockDeviceKit to test DAT SDK integrations without physical Meta glasses.

MockDeviceKit simulates Meta glasses behavior for development and testing. It provides:

  • MockDeviceKit.shared — Entry point (MockDeviceKitInterface) for creating simulated devices
  • MockGlasses — Simulated glasses, created with pairGlasses(model:)
  • MockGlassesServices — Per-device services: camera, captouch, display
  • MockCameraKit — Simulated camera with configurable video feed and photo capture
  • MockCaptouchKit — Simulated touchpad (tap(), tapAndHold())
  • MockDisplayKit — Simulated Display surface for MWDATDisplay content
  • MockPermissions — Control DAT permission results without the Meta AI app

GlassesModel cases: .rayBanMeta, .oakleyMetaHSTN, .oakleyMetaVanguard, .rayBanMetaOptics, .metaGlasses, .metaRayBanDisplay. Use .metaRayBanDisplay when you need a display-capable simulated device.

Setup

Add MWDATMockDevice to your target via Swift Package Manager (it's included in the meta-wearables-dat-ios package).

import MWDATMockDevice

To test a Display experience, also add MWDATDisplay to the target. After enabling MockDeviceKit, use the normal DeviceSession.addDisplay() API.

Creating a mock device

import MWDATMockDevice

let mockDeviceKit = MockDeviceKit.shared
mockDeviceKit.enable()

let mockDevice = try mockDeviceKit.pairGlasses(model: .rayBanMeta)

enable() starts from a registered, permissions-granted state. Pass a MockDeviceKitConfig when you want to exercise the registration or permission flow instead:

mockDeviceKit.enable(
    config: MockDeviceKitConfig(initiallyRegistered: false, initialPermissionsGranted: false)
)

Use mockDeviceKit.pairedDevices, mockDeviceKit.unpairDevice(_:), and mockDeviceKit.disable() to tear devices down.

Simulating device states

// Simulate glasses lifecycle
mockDevice.powerOn()
mockDevice.unfold()
mockDevice.don()    // Simulate wearing the glasses

// Later...
mockDevice.doff()   // Simulate removing
mockDevice.fold()
mockDevice.powerOff()

// Battery, charging, and thermal state
mockDevice.setBatteryLevel(35)
mockDevice.setChargingState(.charging)
mockDevice.setThermalLevel(.severe)

Simulating touchpad input

A single tap pauses an active camera stream, and a second tap resumes it — the CameraAccess tests use this to cover the StreamState.paused path.

mockDevice.services.captouch.tap()
mockDevice.services.captouch.tapAndHold()

Configuring permissions

MockDeviceKit provides permissions to control permission behavior without the Meta AI app.

By default, requestPermission() returns .granted. Use set(_:_:) to control checkPermissionStatus() and setRequestResult(_:result:) to control requestPermission() outcomes.

let mockDeviceKit = MockDeviceKit.shared

// Simulate denied camera permission status
mockDeviceKit.permissions.set(.camera, .denied)

// Simulate denied request result (user tapping "deny")
mockDeviceKit.permissions.setRequestResult(.camera, result: .denied)

Setting up mock camera feeds

Video streaming

let camera = mockDevice.services.camera
camera.setCameraFeed(fileURL: videoURL)

// Or stream live from the phone's own camera
camera.setCameraFeed(cameraFacing: .back)  // CameraFacing is .front or .back

Photo capture

let camera = mockDevice.services.camera
camera.setCapturedImage(fileURL: imageURL)

Writing tests with MockDeviceKit

Create a reusable test base class:

import MWDATCore
import MWDATMockDevice
import XCTest

@MainActor
class MockDeviceKitTestCase: XCTestCase {
    private var mockDevice: MockGlasses?
    private var cameraKit: MockCameraKit?

    override func setUp() async throws {
        try await super.setUp()
        try? Wearables.configure()
        MockDeviceKit.shared.enable()
        let device = try MockDeviceKit.shared.pairGlasses(model: .rayBanMeta)
        mockDevice = device
        cameraKit = device.services.camera

        // Make the device available to Wearables before creating a session
        device.powerOn()
        device.unfold()
    }

    override func tearDown() async throws {
        MockDeviceKit.shared.disable()
        mockDevice = nil
        cameraKit = nil
        try await super.tearDown()
    }
}

The device only shows up in Wearables.shared.devicesStream() after it is powered on and unfolded, so wait for your view model's "device available" state before calling createSession(deviceSelector:).

Using MockDeviceKit in the CameraAccess sample

The CameraAccess sample app includes a Debug menu for MockDeviceKit:

  1. Tap the Debug icon to open the MockDeviceKit menu
  2. Tap Pair RayBan Meta to create a simulated device
  3. Use PowerOn, Unfold, Don to simulate glasses states
  4. Select video/image files to configure mock camera feeds
  5. Start streaming to see simulated frames

Supported media formats

TypeFormats
Videoh.265 (HEVC); the samples ship an .mp4 file
ImageJPEG, PNG

Links

facebook의 다른 스킬

gc-safe-coding
facebook
전체 설명과 근거는 doc/GCSafeCoding.md를 참조하십시오.
app-review-prep
facebook
Meta 앱을 App Review용으로 준비합니다 — 현재 상태, 미해결 요구 사항, 부여된 권한, 제출 내역을 확인합니다. 앱을 제출하기 전에 사용하세요…
api-health
facebook
Meta 앱의 API 상태를 모니터링합니다 — 비율 제한, 호출량, API 지원 중단 여부를 확인합니다. 트래픽 제한을 진단하거나, 용량을 계획하거나, API 버전 변경에 대비하는 데 사용합니다…
debug-webhooks
facebook
Meta 앱의 웹훅 문제를 해결합니다 — 활성 구독을 검사하고, 잘못된 구성을 식별하며, 테스트 페이로드를 전송하여 전달을 확인합니다. 다음과 같은 경우에 사용하세요…
api-integration
facebook
개발자가 Meta API 통합을 처음부터 설정하도록 안내합니다 — 적절한 API를 찾아내고, 설정 가이드, 인증 요구 사항 등을 가져옵니다…
webhook-setup
facebook
Meta 앱용 웹훅을 처음부터 끝까지 설정하세요 — 사용 가능한 주제를 탐색하고, 필드를 구독하고, 테스트 페이로드로 검증합니다. 웹훅을 구성할 때 사용하세요…
test-ui
facebook
iwsdk CLI를 사용하여 포크 예제에 대해 Test UI 시스템(PanelUI, ScreenSpace)을 테스트합니다.
flags
facebook
React 릴리스 채널 간 기능 플래그 상태를 검사하고 비교합니다. 모든 채널(www, www-modern, canary, next, experimental, rn 변형)의 플래그를 보거나 --diff로 특정 채널을 비교합니다. 출력 형식은 기본 테이블 보기, CSV 내보내기, 정리 상태 그룹화를 포함합니다. 플래그 상태는 기호로 표시됩니다: 활성화(✅), 비활성화(❌), 변형 테스트(🧪), 프로파일링 전용(📊). 일반적인 실수: __VARIANT__ 플래그는 www에서 두 상태 모두 테스트되며, --diff를 사용하여 의미 있는 차이를 찾습니다...