/** * QA360 Device Emulation Module * * P0: Mobile and tablet device emulation * - Predefined device profiles * - Viewport resizing * - User agent emulation * - Touch/Mouse interaction switching * - Device pixel ratio handling * - Orientation (portrait/landscape) */ import type { Page } from '@playwright/test'; /** * Device viewport configuration */ export interface ViewportConfig { /** Viewport width in pixels */ width: number; /** Viewport height in pixels */ height: number; /** Device scale factor (default: 1) */ deviceScaleFactor?: number; /** Whether to emulate mobile (default: false) */ isMobile?: boolean; /** Whether to emulate touch (default: false for desktop, true for mobile) */ hasTouch?: boolean; /** Screen orientation */ landscape?: boolean; } /** * Device profile with full configuration */ export interface DeviceProfile extends ViewportConfig { /** Device name */ name: string; /** User agent string */ userAgent: string; /** Device category */ category: 'desktop' | 'tablet' | 'mobile'; } /** * Orientation options */ export type Orientation = 'portrait' | 'landscape'; /** * Device Emulation Helper */ export declare class DeviceEmulator { private page; private static profiles; constructor(page: Page); /** * Get all available device profiles */ static getProfiles(): Record; /** * Get a specific device profile */ static getProfile(name: string): DeviceProfile | undefined; /** * Get all profiles by category */ static getProfilesByCategory(category: 'desktop' | 'tablet' | 'mobile'): DeviceProfile[]; /** * Emulate a device by name */ emulate(device: string): Promise; /** * Emulate a device profile */ emulateProfile(profile: DeviceProfile): Promise; /** * Set viewport size */ setViewport(width: number, height: number, options?: Partial): Promise; /** * Set viewport to predefined dimensions */ desktop(): Promise; tablet(): Promise; mobile(): Promise; /** * Set screen orientation */ setOrientation(orientation: Orientation): Promise; /** * Rotate device (swap width and height) */ rotate(): Promise; /** * Set device pixel ratio */ setDeviceScaleFactor(dpr: number): Promise; /** * Enable/disable touch emulation */ setTouch(enabled: boolean): Promise; /** * Get current viewport info */ getViewport(): Promise; /** * Test at multiple viewport sizes (responsive testing) */ testAtSizes(sizes: Array<{ width: number; height: number; }>, testFn: () => Promise): Promise>; /** * Test at multiple breakpoints (common responsive sizes) */ testResponsive(testFn: () => Promise): Promise>; /** * Test on multiple device profiles */ testOnDevices(devices: string[], testFn: () => Promise): Promise>; } /** * Convenience function to create device emulator */ export declare function device(page: Page): DeviceEmulator; /** * Common viewport presets */ export declare const Viewport: { 'desktop-xl': { width: number; height: number; }; 'desktop-lg': { width: number; height: number; }; 'desktop-md': { width: number; height: number; }; 'desktop-sm': { width: number; height: number; }; 'tablet-lg': { width: number; height: number; }; 'tablet-md': { width: number; height: number; }; 'tablet-sm': { width: number; height: number; }; 'mobile-lg': { width: number; height: number; }; 'mobile-md': { width: number; height: number; }; 'mobile-sm': { width: number; height: number; }; 'mobile-xs': { width: number; height: number; }; }; /** * Common device lists */ export declare const Devices: { desktop: readonly ["desktop-1920x1080", "desktop-1366x768", "macbook-16"]; tablet: readonly ["ipad-pro", "ipad", "ipad-mini", "surface-pro"]; mobile: readonly ["iphone-15-pro-max", "iphone-15-pro", "iphone-se", "pixel-7-pro", "samsung-s23"]; popular: readonly ["desktop-1920x1080", "ipad", "iphone-15-pro", "pixel-7-pro"]; };