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, m_InputTest, 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 RuntimeAutoRotationOrientationEnable(ScreenOrientation orientation) { m_InputTest.Rotation = ScreenTestUtilities.OrientationRotation[orientation]; m_Simulation = new ScreenSimulation(m_TestDevice, m_InputTest, SimulatorPlayerSettingsUI.InitDefaultPlayerSettings(), m_Window); Screen.orientation = ScreenOrientation.AutoRotation; Screen.autorotateToPortrait = true; Screen.autorotateToPortraitUpsideDown = true; Screen.autorotateToLandscapeLeft = true; Screen.autorotateToLandscapeRight = true; ScreenTestUtilities.SetScreenAutoOrientation(orientation, false); Assert.AreNotEqual(orientation, Screen.orientation); ScreenTestUtilities.SetScreenAutoOrientation(orientation, true); Assert.AreEqual(orientation, Screen.orientation); }
public void ScreenResolutionChangesCorrectlyWhenChangingResolutionAndOrientation(ScreenOrientation initOrientation, ScreenOrientation newOrientation, int newWidth, int newHeight) { var initResolution = new Vector2(newWidth, newHeight); var flippedResolution = new Vector2(newHeight, newWidth); var isFlipped = initOrientation.IsLandscape() ^ newOrientation.IsLandscape(); var testDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(ScreenTestUtilities.ExplicitOrientations); var testWindow = new TestWindow(); m_Simulation = new ScreenSimulation(testDevice, m_InputTest, SimulatorPlayerSettingsUI.InitDefaultPlayerSettings(), testWindow); Screen.orientation = initOrientation; Screen.SetResolution(newWidth, newHeight, true); Assert.AreEqual(initResolution, testWindow.TargetSize); Screen.orientation = newOrientation; Assert.AreEqual(isFlipped ? flippedResolution : initResolution, testWindow.TargetSize); }
public void FullScreenModeAndroid(FullScreenMode fullScreenMode) { m_TestDevice.SystemInfo.operatingSystem = "Android"; m_InputTest.Rotation = ScreenTestUtilities.OrientationRotation[ScreenOrientation.PortraitUpsideDown]; m_Simulation = new ScreenSimulation(m_TestDevice, m_InputTest, new SimulationPlayerSettings()); m_Simulation.fullScreenMode = fullScreenMode; switch (fullScreenMode) { case FullScreenMode.Windowed: Assert.IsFalse(Screen.fullScreen); Assert.AreEqual(FullScreenMode.Windowed, Screen.fullScreenMode); break; default: Assert.IsTrue(Screen.fullScreen); Assert.AreEqual(FullScreenMode.FullScreenWindow, Screen.fullScreenMode); break; } }
public void AutoOrientationsInitializedFromPlayerSettings(bool portrait, bool portraitUpsideDown, bool landscapeLeft, bool landscapeRight) { PlayerSettings.defaultInterfaceOrientation = UIOrientation.AutoRotation; // Setting all to true to avoid setting all to false, that would throw an exception and enable Portrait PlayerSettings.allowedAutorotateToPortrait = true; PlayerSettings.allowedAutorotateToPortraitUpsideDown = true; PlayerSettings.allowedAutorotateToLandscapeLeft = true; PlayerSettings.allowedAutorotateToLandscapeRight = true; PlayerSettings.allowedAutorotateToPortrait = portrait; PlayerSettings.allowedAutorotateToPortraitUpsideDown = portraitUpsideDown; PlayerSettings.allowedAutorotateToLandscapeLeft = landscapeLeft; PlayerSettings.allowedAutorotateToLandscapeRight = landscapeRight; m_Simulation = new ScreenSimulation(m_TestDevice, m_InputTest, new SimulationPlayerSettings(), m_TestWindow); Assert.AreEqual(portrait, Screen.autorotateToPortrait); Assert.AreEqual(portraitUpsideDown, Screen.autorotateToPortraitUpsideDown); Assert.AreEqual(landscapeLeft, Screen.autorotateToLandscapeLeft); Assert.AreEqual(landscapeRight, Screen.autorotateToLandscapeRight); }
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, m_InputTest, 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 void WillRotateOnlyToEnabledOrientationsWhenAutoRotating(ScreenOrientation disabledOrientation) { var enabledOrientations = new List <ScreenOrientation>(ScreenTestUtilities.ExplicitOrientations); enabledOrientations.Remove(disabledOrientation); m_Simulation = new ScreenSimulation(m_TestDevice, m_InputTest, new SimulationPlayerSettings()); Screen.orientation = ScreenOrientation.AutoRotation; foreach (var orientation in enabledOrientations) { ScreenTestUtilities.SetScreenAutoOrientation(orientation, true); } ScreenTestUtilities.SetScreenAutoOrientation(disabledOrientation, false); foreach (var orientation in enabledOrientations) { m_InputTest.Rotate(orientation); Assert.AreEqual(orientation, Screen.orientation); } m_InputTest.Rotate(disabledOrientation); Assert.AreNotEqual(disabledOrientation, 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, m_InputTest, 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)); }
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, m_InputTest, new SimulationPlayerSettings()); Screen.orientation = ScreenOrientation.AutoRotation; Screen.autorotateToPortrait = true; Screen.autorotateToPortraitUpsideDown = true; Screen.autorotateToLandscapeLeft = true; Screen.autorotateToLandscapeRight = true; foreach (var orientation in supportedOrientations) { m_InputTest.Rotate(orientation); Assert.AreEqual(orientation, Screen.orientation); } m_InputTest.Rotate(unsupportedOrientation); Assert.AreNotEqual(unsupportedOrientation, Screen.orientation); }
public void AndroidFullScreen(DeviceInfo device, ScreenOrientation initOrientation, int windowedWidth, int windowedHeight, Vector4 windowedInsets, Rect safeArea) { var fullScreenEventCounter = 0; var insetEventCounter = 0; var resolutionEventCounter = 0; var safeAreaEventCounter = 0; var insetFromEvent = Vector4.zero; var safeAreaFromEvent = Rect.zero; m_InputTest.Rotation = ScreenTestUtilities.OrientationRotation[initOrientation]; m_Simulation = new ScreenSimulation(device, m_InputTest, new SimulationPlayerSettings()); m_Simulation.OnResolutionChanged += (i, i1) => resolutionEventCounter++; m_Simulation.OnFullScreenChanged += b => fullScreenEventCounter++; m_Simulation.OnInsetsChanged += inset => { insetEventCounter++; insetFromEvent = inset; }; m_Simulation.OnScreenSpaceSafeAreaChanged += sa => { safeAreaEventCounter++; safeAreaFromEvent = sa; }; var fullScreenSafeArea = Screen.safeArea; var fullScreenResolution = Screen.currentResolution; Assert.IsTrue(Screen.fullScreen); m_Simulation.fullScreen = false; Assert.IsFalse(Screen.fullScreen); Assert.AreEqual(1, fullScreenEventCounter); Assert.AreEqual(1, insetEventCounter); Assert.AreEqual(1, resolutionEventCounter); Assert.AreEqual(1, safeAreaEventCounter); fullScreenEventCounter = 0; insetEventCounter = 0; resolutionEventCounter = 0; safeAreaEventCounter = 0; // The way windowed on Android is handled has changed. Now simulator behavior does not match reality - cases are correct but simulator returns completely incorrect values // Assert.AreEqual(windowedWidth, Screen.currentResolution.width); // Assert.AreEqual(windowedHeight, Screen.currentResolution.height); // Assert.AreEqual(windowedWidth, Screen.currentResolution.width); // Assert.AreEqual(windowedHeight, Screen.currentResolution.height); // Assert.AreEqual(windowedInsets, insetFromEvent); // Assert.AreEqual(windowedInsets, m_Simulation.Insets); // // Assert.AreEqual(safeArea, Screen.safeArea); m_Simulation.fullScreen = true; Assert.IsTrue(Screen.fullScreen); Assert.AreEqual(1, fullScreenEventCounter); Assert.AreEqual(1, insetEventCounter); Assert.AreEqual(1, resolutionEventCounter); Assert.AreEqual(1, safeAreaEventCounter); Assert.AreEqual(fullScreenSafeArea, Screen.safeArea); Assert.AreEqual(fullScreenResolution, Screen.currentResolution); }
public void SetUp() { m_InputProvider = new TestInput(); m_ScreenSimulation = new ScreenSimulation(m_Device, m_InputProvider, SimulatorPlayerSettingsUI.InitDefaultPlayerSettings(), m_SimulatorWindow); }
public void AndroidFullScreen(DeviceInfo device, int targetDpi, ScreenOrientation initOrientation, int windowedWidth, int windowedHeight, Vector4 windowedInsets, Rect safeArea, Rect[] cutouts) { var fullScreenEventCounter = 0; var insetEventCounter = 0; var resolutionEventCounter = 0; var safeAreaEventCounter = 0; var insetFromEvent = Vector4.zero; var safeAreaFromEvent = Rect.zero; var playerSettings = new SimulationPlayerSettings(); if (targetDpi > 0) { playerSettings.resolutionScalingMode = ResolutionScalingMode.FixedDpi; playerSettings.targetDpi = targetDpi; } m_Simulation = new ScreenSimulation(device, playerSettings); m_Simulation.DeviceRotation = ScreenTestUtilities.OrientationRotation[initOrientation]; m_Simulation.OnResolutionChanged += (i, i1) => resolutionEventCounter++; m_Simulation.OnFullScreenChanged += b => fullScreenEventCounter++; m_Simulation.OnInsetsChanged += inset => { insetEventCounter++; insetFromEvent = inset; }; m_Simulation.OnScreenSpaceSafeAreaChanged += sa => { safeAreaEventCounter++; safeAreaFromEvent = sa; }; var fullScreenSafeArea = Screen.safeArea; var fullScreenResolution = Screen.currentResolution; Assert.IsTrue(Screen.fullScreen); m_Simulation.fullScreen = false; Assert.IsFalse(Screen.fullScreen); Assert.AreEqual(1, fullScreenEventCounter); Assert.AreEqual(1, insetEventCounter); Assert.AreEqual(1, resolutionEventCounter); Assert.AreEqual(1, safeAreaEventCounter); fullScreenEventCounter = 0; insetEventCounter = 0; resolutionEventCounter = 0; safeAreaEventCounter = 0; Assert.AreEqual(windowedWidth, Screen.currentResolution.width); Assert.AreEqual(windowedHeight, Screen.currentResolution.height); Assert.AreEqual(windowedInsets, insetFromEvent); Assert.AreEqual(windowedInsets, m_Simulation.Insets); Assert.AreEqual(safeArea, Screen.safeArea); Assert.AreEqual(cutouts.Length, Screen.cutouts.Length); Assert.AreEqual(cutouts.FirstOrDefault(), Screen.cutouts.FirstOrDefault()); m_Simulation.fullScreen = true; Assert.IsTrue(Screen.fullScreen); Assert.AreEqual(1, fullScreenEventCounter); Assert.AreEqual(1, insetEventCounter); Assert.AreEqual(1, resolutionEventCounter); Assert.AreEqual(1, safeAreaEventCounter); Assert.AreEqual(fullScreenSafeArea, Screen.safeArea); Assert.AreEqual(fullScreenResolution, Screen.currentResolution); }