public void iOSFullScreen()
        {
            var fullScreenEventCounter = 0;
            var insetEventCounter      = 0;
            var resolutionEventCounter = 0;
            var safeAreaEventCounter   = 0;

            m_InputTest.Rotation = ScreenTestUtilities.OrientationRotation[ScreenOrientation.Portrait];
            m_Simulation         = new ScreenSimulation(DeviceInfoLibrary.GetIphoneXMax(), m_InputTest, new SimulationPlayerSettings());

            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 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);
예제 #3
0
        public void SetUp()
        {
            m_InputTest = new TestInput();

            m_TestDevice = DeviceInfoLibrary.GetDeviceWithSupportedOrientations(new[]
            {
                ScreenOrientation.Portrait,
                ScreenOrientation.LandscapeLeft,
                ScreenOrientation.LandscapeRight,
                ScreenOrientation.PortraitUpsideDown
            });
        }
        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, 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 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 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 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);
        }