Пример #1
0
        public void SetMinMaxSizePasses()
        {
            {
                var info = new LayoutInfo();
                var min  = Vector3.one * 10f;
                var max  = Vector3.one * 100f;
                info.SetMinMaxSize(min, max);

                AssertionUtils.AreNearlyEqual(min, info.MinSize);
                AssertionUtils.AreNearlyEqual(max, info.MaxSize);
            }
            Debug.Log($"Success to SetMinMaxSize()!");

            {
                var info = new LayoutInfo();
                var min  = new Vector3(20, 40, 60);
                var max  = new Vector3(30, 10, 70);
                info.SetMinMaxSize(min, max);

                AssertionUtils.AreNearlyEqual(Vector3.Min(min, max), info.MinSize);
                AssertionUtils.AreNearlyEqual(Vector3.Max(min, max), info.MaxSize);
            }
            Debug.Log($"Success to MaxSize Property When greater MaxSize!");

            {
                var info = new LayoutInfo();
                var min  = new Vector3(-1, 40, -1);
                var max  = new Vector3(30, -1, 70);
                info.SetMinMaxSize(min, max);

                AssertionUtils.AreNearlyEqual(new Vector3(-1, 40, -1), info.MinSize);
                AssertionUtils.AreNearlyEqual(new Vector3(30, -1, 70), info.MaxSize);
            }
            Debug.Log($"Success to MaxSize Property When INVALID_VECTOR3!");
        }
Пример #2
0
        public void OnChangedValue_SetMinMaxSize_WhenThrowExceptionPasses()
        {
            var info = new LayoutInfo();

            info.OnChangedValue.Add((_self, _kind, _prev) => {
                throw new System.Exception();
            });

            var min = Vector3.one * 10f;
            var max = Vector3.one * 100f;

            info.SetMinMaxSize(min, max);

            AssertionUtils.AreNearlyEqual(min, info.MinSize);
            AssertionUtils.AreNearlyEqual(max, info.MaxSize);
        }
Пример #3
0
        public void AssignPasses()
        {
            var info  = new LayoutInfo();
            var other = new LayoutInfo();

            other.LayoutSize = Vector3.one * 100f;
            other.SetMinMaxSize(Vector3.one * 10f, Vector3.one * 200f);
            other.IgnoreLayoutGroup = true;
            other.SizeGrowInGroup   = 2f;
            other.OrderInGroup      = 10;

            info.Assign(other);

            AssertionUtils.AreNearlyEqual(other.LayoutSize, info.LayoutSize);
            AssertionUtils.AreNearlyEqual(other.MinSize, info.MinSize);
            AssertionUtils.AreNearlyEqual(other.MaxSize, info.MaxSize);
            Assert.AreEqual(other.IgnoreLayoutGroup, info.IgnoreLayoutGroup);
            AssertionUtils.AreNearlyEqual(other.SizeGrowInGroup, info.SizeGrowInGroup);
            Assert.AreEqual(other.OrderInGroup, info.OrderInGroup);
        }
Пример #4
0
        public void OnChangedValue_SetMinMaxSizePasses()
        {
            var info = new LayoutInfo();

            var callCounter = 0;

            (LayoutInfo self, LayoutInfo.ValueKind kind, LayoutInfo.OnChangedValueParam prevInfo)recievedValue = default;
            info.OnChangedValue.Add((_self, _kind, _prev) => {
                callCounter++;
                recievedValue = (_self, _kind, _prev);
            });

            {
                callCounter   = 0;
                recievedValue = default;

                var prev = (info.MinSize, info.MaxSize);
                var min  = Vector3.one * 10f;
                var max  = Vector3.one * 100f;
                info.SetMinMaxSize(min, max);

                Assert.AreEqual(1, callCounter);
                Assert.AreSame(info, recievedValue.self);
                Assert.AreEqual(LayoutInfo.ValueKind.MinSize | LayoutInfo.ValueKind.MaxSize, recievedValue.kind);
                Assert.AreEqual(prev.MinSize, recievedValue.prevInfo.MinSize);
                Assert.AreEqual(prev.MaxSize, recievedValue.prevInfo.MaxSize);
            }
            Debug.Log($"Success to OnChangedValue When SetMinMaxSize()!");

            {
                callCounter   = 0;
                recievedValue = default;

                var prev = (info.MinSize, info.MaxSize);
                var min  = info.MinSize + Vector3.one;
                var max  = info.MaxSize;
                info.SetMinMaxSize(min, max);

                Assert.AreEqual(1, callCounter);
                Assert.AreSame(info, recievedValue.self);
                Assert.AreEqual(LayoutInfo.ValueKind.MinSize, recievedValue.kind);
                Assert.AreEqual(prev.MinSize, recievedValue.prevInfo.MinSize);
                Assert.AreEqual(prev.MaxSize, recievedValue.prevInfo.MaxSize);
            }
            Debug.Log($"Success to OnChangedValue When SetMinMaxSize(min, same max)!");

            {
                callCounter   = 0;
                recievedValue = default;

                var prev = (info.MinSize, info.MaxSize);
                var min  = info.MinSize;
                var max  = info.MaxSize + Vector3.one;
                info.SetMinMaxSize(min, max);

                Assert.AreEqual(1, callCounter);
                Assert.AreSame(info, recievedValue.self);
                Assert.AreEqual(LayoutInfo.ValueKind.MaxSize, recievedValue.kind);
                Assert.AreEqual(prev.MinSize, recievedValue.prevInfo.MinSize);
                Assert.AreEqual(prev.MaxSize, recievedValue.prevInfo.MaxSize);
            }
            Debug.Log($"Success to OnChangedValue When SetMinMaxSize(same min, max)!");
        }