public void iOSFullScreen() { var fullScreenEventCounter = 0; var insetEventCounter = 0; var resolutionEventCounter = 0; var safeAreaEventCounter = 0; m_Simulation = new ScreenSimulation(DeviceInfoLibrary.GetIphoneXMax(), new SimulationPlayerSettings()); m_Simulation.DeviceRotation = ScreenTestUtilities.OrientationRotation[ScreenOrientation.Portrait]; m_Simulation.OnResolutionChanged += (i, i1) => resolutionEventCounter++; m_Simulation.OnFullScreenChanged += b => fullScreenEventCounter++; m_Simulation.OnInsetsChanged += vector4 => insetEventCounter++; m_Simulation.OnScreenSpaceSafeAreaChanged += rect => safeAreaEventCounter++; m_Simulation.fullScreen = true; Assert.IsTrue(Screen.fullScreen); m_Simulation.fullScreen = false; Assert.IsTrue(Screen.fullScreen); Assert.AreEqual(0, fullScreenEventCounter); Assert.AreEqual(0, insetEventCounter); Assert.AreEqual(0, resolutionEventCounter); Assert.AreEqual(0, safeAreaEventCounter); }
public static IEnumerable <InputProviderTouchFromMouseCase> InputProviderTouchFromMouseCases() { // Custom orientation, no resolution change yield return(new InputProviderTouchFromMouseCase { deviceInfo = DeviceInfoLibrary.GetGalaxy10e(), screenOrientation = ScreenOrientation.Portrait, resolutionWidth = 1080, resolutionHeight = 2280, inputTouchPosition = new[] { new Vector2(1, 1), new Vector2(1000, 1500), new Vector2(100, 100) }, resultTouchPosition = new[] { new Vector2(1, 2279), new Vector2(1000, 780), new Vector2(100, 2180) } }); yield return(new InputProviderTouchFromMouseCase { deviceInfo = DeviceInfoLibrary.GetGalaxy10e(), screenOrientation = ScreenOrientation.LandscapeLeft, resolutionWidth = 2280, resolutionHeight = 1080, inputTouchPosition = new[] { new Vector2(1, 1), new Vector2(1000, 333), new Vector2(99, 100) }, resultTouchPosition = new[] { new Vector2(1, 1), new Vector2(333, 1000), new Vector2(100, 99) } }); yield return(new InputProviderTouchFromMouseCase { deviceInfo = DeviceInfoLibrary.GetGalaxy10e(), screenOrientation = ScreenOrientation.PortraitUpsideDown, resolutionWidth = 1080, resolutionHeight = 2280, inputTouchPosition = new[] { new Vector2(1, 8), new Vector2(1000, 1503), new Vector2(100, 100) }, resultTouchPosition = new[] { new Vector2(1079, 8), new Vector2(80, 1503), new Vector2(980, 100) } }); yield return(new InputProviderTouchFromMouseCase { deviceInfo = DeviceInfoLibrary.GetGalaxy10e(), screenOrientation = ScreenOrientation.LandscapeRight, resolutionWidth = 2280, resolutionHeight = 1080, inputTouchPosition = new[] { new Vector2(1, 1), new Vector2(1000, 333), new Vector2(100, 100) }, resultTouchPosition = new[] { new Vector2(2279, 1079), new Vector2(1947, 80), new Vector2(2180, 980) } }); // Custom orientation and custom resolution yield return(new InputProviderTouchFromMouseCase { deviceInfo = DeviceInfoLibrary.GetGalaxy10e(), screenOrientation = ScreenOrientation.Portrait, resolutionWidth = 2000, resolutionHeight = 4000, inputTouchPosition = new[] { new Vector2(1, 1), new Vector2(1079, 2279), new Vector2(99, 699) }, resultTouchPosition = new[] { new Vector2(1.85f, 3998.24f), new Vector2(1998.15f, 1.75f), new Vector2(183.33f, 2773.68f) } }); yield return(new InputProviderTouchFromMouseCase { deviceInfo = DeviceInfoLibrary.GetGalaxy10e(), screenOrientation = ScreenOrientation.LandscapeLeft, resolutionWidth = 1140, resolutionHeight = 540, inputTouchPosition = new[] { new Vector2(1, 1), new Vector2(1000, 333), new Vector2(99, 100) }, resultTouchPosition = new[] { new Vector2(0.5f, 0.5f), new Vector2(166.5f, 500), new Vector2(50, 49.5f) } }); yield return(new InputProviderTouchFromMouseCase { deviceInfo = DeviceInfoLibrary.GetGalaxy10e(), screenOrientation = ScreenOrientation.PortraitUpsideDown, resolutionWidth = 2280, resolutionHeight = 1080, inputTouchPosition = new[] { new Vector2(1, 8), new Vector2(1000, 1503), new Vector2(100, 100) }, resultTouchPosition = new[] { new Vector2(2277.88f, 3.79f), new Vector2(168.88f, 711.94f), new Vector2(2068.88f, 47.36f) } }); }
public void SetUp() { m_TestDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(new[] { ScreenOrientation.Portrait, ScreenOrientation.LandscapeLeft, ScreenOrientation.LandscapeRight, ScreenOrientation.PortraitUpsideDown }); }
public void ResolutionScalingInitializedCorrectly(UIOrientation orientation, int screenWidth, int screenHeight, float screenDpi, int scaledDpi) { PlayerSettings.defaultInterfaceOrientation = orientation; var serializedSettings = PlayerSettings.GetSerializedObject(); serializedSettings.Update(); serializedSettings.FindProperty("resolutionScalingMode").intValue = 1; serializedSettings.FindProperty("targetPixelDensity").intValue = scaledDpi; serializedSettings.ApplyModifiedPropertiesWithoutUndo(); var testDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(ScreenTestUtilities.ExplicitOrientations, screenWidth, screenHeight, default, screenDpi);
public void OneTimeSetUp() { m_CachedOrientation = PlayerSettings.defaultInterfaceOrientation; m_CachedAutoPortrait = PlayerSettings.allowedAutorotateToPortrait; m_CachedAutoPortraitReversed = PlayerSettings.allowedAutorotateToPortraitUpsideDown; m_CachedAutoLandscapeLeft = PlayerSettings.allowedAutorotateToLandscapeLeft; m_CachedAutoLandscapeRight = PlayerSettings.allowedAutorotateToLandscapeRight; var serializedSettings = PlayerSettings.GetSerializedObject(); serializedSettings.Update(); m_CachedScalingMode = serializedSettings.FindProperty("resolutionScalingMode").intValue; m_CachedScaledDPI = serializedSettings.FindProperty("targetPixelDensity").intValue; m_TestDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(ScreenTestUtilities.ExplicitOrientations); }
public void WillRotateOnlyToSupportedOrientationsWhenExplicitlySet(ScreenOrientation unsupportedOrientation) { var supportedOrientations = new List <ScreenOrientation>(ScreenTestUtilities.ExplicitOrientations); supportedOrientations.Remove(unsupportedOrientation); var testDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(supportedOrientations.ToArray()); m_Simulation = new ScreenSimulation(testDevice, new SimulationPlayerSettings()); foreach (var orientation in supportedOrientations) { Screen.orientation = orientation; Assert.AreEqual(orientation, Screen.orientation); } Screen.orientation = unsupportedOrientation; Assert.AreNotEqual(unsupportedOrientation, Screen.orientation); }
public void ScreenResolutionChangesCorrectlyWhenChangingOrientation(ScreenOrientation initOrientation, ScreenOrientation newOrientation, int screenWidth, int screenHeight) { var portraitResolution = new Vector2(screenWidth, screenHeight); var landscapeResolution = new Vector2(screenHeight, screenWidth); var testDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(ScreenTestUtilities.ExplicitOrientations, screenWidth, screenHeight); m_Simulation = new ScreenSimulation(testDevice, new SimulationPlayerSettings()); var width = Screen.currentResolution.width; var height = Screen.currentResolution.height; m_Simulation.OnResolutionChanged += (w, h) => { width = w; height = h; }; Screen.orientation = initOrientation; Assert.AreEqual(initOrientation.IsLandscape() ? landscapeResolution : portraitResolution, new Vector2(width, height)); Screen.orientation = newOrientation; Assert.AreEqual(newOrientation.IsLandscape() ? landscapeResolution : portraitResolution, new Vector2(width, height)); }
public static IEnumerable <DeviceViewMatrixCase> DeviceViewMatrixCases() { yield return(new DeviceViewMatrixCase { DeviceInfo = DeviceInfoLibrary.GetGalaxy10e(), Rotation = 0, Scale = 1.0f, InputPosition = new Vector2(200, 400), ResultPosition = new Vector2(150, 350) }); yield return(new DeviceViewMatrixCase { DeviceInfo = DeviceInfoLibrary.GetGalaxy10e(), Rotation = 90, Scale = 1.0f, InputPosition = new Vector2(200, 400), ResultPosition = new Vector2(350, 2165) }); yield return(new DeviceViewMatrixCase { DeviceInfo = DeviceInfoLibrary.GetGalaxy10e(), Rotation = 180, Scale = 1.0f, InputPosition = new Vector2(200, 400), ResultPosition = new Vector2(930, 1965) }); yield return(new DeviceViewMatrixCase { DeviceInfo = DeviceInfoLibrary.GetGalaxy10e(), Rotation = 270, Scale = 1.0f, InputPosition = new Vector2(200, 400), ResultPosition = new Vector2(730, 150) }); yield return(new DeviceViewMatrixCase { DeviceInfo = DeviceInfoLibrary.GetGalaxy10e(), Rotation = 0, Scale = 0.2f, InputPosition = new Vector2(200, 400), ResultPosition = new Vector2(950, 1950) }); }
public void WillRotateOnlyToSupportedOrientationsWhenAutoRotating(ScreenOrientation unsupportedOrientation) { var supportedOrientations = new List <ScreenOrientation>(ScreenTestUtilities.ExplicitOrientations); supportedOrientations.Remove(unsupportedOrientation); var testDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(supportedOrientations.ToArray()); m_Simulation = new ScreenSimulation(testDevice, new SimulationPlayerSettings()); Screen.orientation = ScreenOrientation.AutoRotation; Screen.autorotateToPortrait = true; Screen.autorotateToPortraitUpsideDown = true; Screen.autorotateToLandscapeLeft = true; Screen.autorotateToLandscapeRight = true; foreach (var orientation in supportedOrientations) { m_Simulation.DeviceRotation = ScreenTestUtilities.OrientationRotation[orientation]; Assert.AreEqual(orientation, Screen.orientation); } m_Simulation.DeviceRotation = ScreenTestUtilities.OrientationRotation[unsupportedOrientation]; Assert.AreNotEqual(unsupportedOrientation, Screen.orientation); }
public void ScreenResolutionChangesCorrectlyWhenChangingResolutionAndOrientation(ScreenOrientation initOrientation, ScreenOrientation newOrientation, int newWidth, int newHeight) { var width = 0; var height = 0; var initResolution = new Vector2(newWidth, newHeight); var flippedResolution = new Vector2(newHeight, newWidth); var isFlipped = initOrientation.IsLandscape() ^ newOrientation.IsLandscape(); var testDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(ScreenTestUtilities.ExplicitOrientations); m_Simulation = new ScreenSimulation(testDevice, new SimulationPlayerSettings()); m_Simulation.OnResolutionChanged += (w, h) => { width = w; height = h; }; Screen.orientation = initOrientation; Screen.SetResolution(newWidth, newHeight, true); Assert.AreEqual(initResolution, new Vector2(width, height)); Screen.orientation = newOrientation; Assert.AreEqual(isFlipped ? flippedResolution : initResolution, new Vector2(width, height)); }