Exemplo n.º 1
0
        public void TestUndoAndRedo()
        {
            AuxiliaryController           ac   = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();
            List <AuxiliaryLineParameter> list = new List <AuxiliaryLineParameter>();

            list.Add(ac.CloneParameter());

            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Down);
            list.Add(ac.CloneParameter());

            ChangeAuxiliaryLineSizeWhereTopRight(ac, -100, -5, true);
            list.Add(ac.CloneParameter());

            ChangeAuxiliaryLineSizeWhereTopRight(ac, -5, -100, false);
            list.Add(ac.CloneParameter());

            ac.CancelEvent();
            AreParameterEqual(list[2], ac);

            ac.CancelEvent();
            AreParameterEqual(list[1], ac);

            ac.RedoEvent();
            AreParameterEqual(list[2], ac);

            ChangeAuxiliaryLineSizeWhereTopRight(ac, 50, 5, true);
            list.Add(ac.CloneParameter());

            ac.CancelEvent();
            AreParameterEqual(list[2], ac);

            ac.RedoEvent();
            AreParameterEqual(list[4], ac);
        }
Exemplo n.º 2
0
        public AuxiliaryLineTestData Execute(AuxiliaryController ac, int degree)
        {
            Point leftTop     = ac.AuxiliaryLeftTop;
            Point leftBottom  = ac.AuxiliaryLeftBottom;
            Point rightTop    = ac.AuxiliaryRightTop;
            Point rightBottom = ac.AuxiliaryRightBottom;
            int   centerX     = CalcCenterX(leftTop, rightBottom);
            int   centerY     = CalcCenterY(leftBottom, rightTop);

            // テストデータ作成
            Point newLeftTop     = CalcRotatePoint(leftTop, centerX, centerY, degree);
            Point newLeftBottom  = CalcRotatePoint(leftBottom, centerX, centerY, degree);
            Point newRightTop    = CalcRotatePoint(rightTop, centerX, centerY, degree);
            Point newRightBottom = CalcRotatePoint(rightBottom, centerX, centerY, degree);

            AuxiliaryLineParameter before   = ac.CloneParameter();
            AuxiliaryLineTestData  testData = new AuxiliaryLineTestData(newLeftTop, newLeftBottom, newRightTop, newRightBottom, degree);

            if (IsOutOfRangeImagePoint(newLeftTop, ac) ||
                IsOutOfRangeImagePoint(newLeftBottom, ac) ||
                IsOutOfRangeImagePoint(newRightTop, ac) ||
                IsOutOfRangeImagePoint(newRightBottom, ac))
            {
                testData = new AuxiliaryLineTestData(before);
            }

            // 回転実施
            ac.SetEvent(degree);
            ac.PublishEvent(null);

            return(testData);
        }
Exemplo n.º 3
0
        public void TestCorrectAuxiliaryLineOriginAfterInputCursorKeyUpIfAuxiliaryLineOriginTopIsZero()
        {
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();

            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Up);
            Assert.AreEqual(0, ac.AuxiliaryTop);
        }
Exemplo n.º 4
0
 private void MoveAuxiliaryLine(AuxiliaryController ac,
                                System.Windows.Point startPoint,
                                System.Windows.Point finishPoint,
                                int correctLeftAfterMove,
                                int correctTopAfterMove)
 {
     ac.SetEvent(startPoint);
     ac.PublishEvent(finishPoint);
     Assert.AreEqual(ac.AuxiliaryLeft, correctLeftAfterMove);
     Assert.AreEqual(ac.AuxiliaryTop, correctTopAfterMove);
 }
Exemplo n.º 5
0
        public void TestUndoInputCursorKeyLeft()
        {
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();

            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Left);
            Assert.AreEqual(0, ac.AuxiliaryTop);
            Assert.AreEqual(0, ac.AuxiliaryLeft);

            ac.CancelEvent();
            Assert.AreEqual(0, ac.AuxiliaryTop);
            Assert.AreEqual(0, ac.AuxiliaryLeft);
        }
Exemplo n.º 6
0
        public void TestRedoInputCursorKeyUp()
        {
            AuxiliaryController           ac   = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();
            List <AuxiliaryLineParameter> list = new List <AuxiliaryLineParameter>();

            list.Add(ac.CloneParameter());

            // 上キー操作で上に移動するようあらかじめ下に移動しておく
            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Down);
            list.Add(ac.CloneParameter());

            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Up);
            list.Add(ac.CloneParameter());

            ac.CancelEvent();
            AreParameterEqual(list[1], ac);

            ac.RedoEvent();
            AreParameterEqual(list[2], ac);
        }
Exemplo n.º 7
0
        public void TestUndoInputCursorKeyRight()
        {
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();

            // 矩形を小さくして、右キーで矩形を移動できるだけのスペースを作る
            AuxiliaryLineTestData testData
                = new AuxiliaryLineChangeSizeBottomRight(ac).ChangeSize(-100, -5, true);

            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Right);
            Assert.AreEqual(0, ac.AuxiliaryTop);
            Assert.AreEqual(1, ac.AuxiliaryLeft);

            ac.CancelEvent();
            Assert.AreEqual(0, ac.AuxiliaryTop);
            Assert.AreEqual(0, ac.AuxiliaryLeft);
        }
Exemplo n.º 8
0
        public void TestRedoNoProcessBeforeAtLeastOneOperationCanceled()
        {
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();
            int beforeRight        = ac.AuxiliaryRight;
            int beforeBottom       = ac.AuxiliaryBottom;
            int beforeTop          = ac.AuxiliaryTop;
            int beforeLeft         = ac.AuxiliaryLeft;

            // CancelせずにRedoを実行する
            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Left);
            ac.RedoEvent();

            Assert.AreEqual(beforeRight, ac.AuxiliaryRight);
            Assert.AreEqual(beforeBottom, ac.AuxiliaryBottom);
            Assert.AreEqual(beforeTop, ac.AuxiliaryTop);
            Assert.AreEqual(beforeLeft, ac.AuxiliaryLeft);
        }
Exemplo n.º 9
0
        public void TestNoProcessingAuxiliaryLineIfMouseDownOuterAuxiliaryLine()
        {
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();

            // 補助線を縮小して補助線外部のスペースを作り、そのスペースでテストする
            int sizeChangeWidth  = -100;
            int sizeChangeHeight = -5;

            ChangeAuxiliaryLineSizeWhereBottomRight(ac, sizeChangeWidth, sizeChangeHeight, true);

            double mouseDownX = ac.DisplayImageWidth + (sizeChangeWidth / 2);
            double mouseDownY = ac.DisplayImageHeight + (sizeChangeHeight / 2);

            System.Windows.Point mouseDown = new System.Windows.Point(mouseDownX, mouseDownY);
            System.Windows.Point mouseUp   = mouseDown;
            ac.SetEvent(mouseDown);
            ac.PublishEvent(mouseUp);
        }
Exemplo n.º 10
0
        public void TestAuxiliaryLineStayInImageAfterInputCursorKeyDownIfAuxiliaryLineBottomIsImageBottom()
        {
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();

            int enableDownRange = ac.DisplayImageHeight - ac.AuxiliaryBottom;

            Keys.EnableKeys down = Keys.EnableKeys.Down;
            ac.SetEvent();
            for (int i = 1; i <= enableDownRange; i++)
            {
                ac.PublishEvent(down);
                Assert.AreEqual(i, ac.AuxiliaryTop);
            }

            int maxDownRange = enableDownRange - Common.AuxiliaryLineThickness + 1;

            Assert.AreEqual(maxDownRange, ac.AuxiliaryTop);

            ac.PublishEvent(down);
            Assert.AreEqual(maxDownRange, ac.AuxiliaryTop);
        }
Exemplo n.º 11
0
        public void TestAuxiliaryLineStayInImageAfterInputCursorKeyRightIfAuxiliaryLineRightIsImageRight()
        {
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();

            int enableRightRange = ac.DisplayImageWidth - ac.AuxiliaryRight;

            Keys.EnableKeys right = Keys.EnableKeys.Right;
            ac.SetEvent();
            for (int i = 1; i <= enableRightRange; i++)
            {
                ac.PublishEvent(right);
                // 原点を右に移動させるので、原点位置=Leftと比較する
                Assert.AreEqual(i, ac.AuxiliaryLeft);
            }

            int maxRightRange = enableRightRange - Common.AuxiliaryLineThickness + 1;

            Assert.AreEqual(maxRightRange, ac.AuxiliaryLeft);

            ac.PublishEvent(right);
            Assert.AreEqual(maxRightRange, ac.AuxiliaryLeft);
        }
Exemplo n.º 12
0
        public void TestNoRedoIfNewOperationAfterUndo()
        {
            // 操作 → Undo → 別操作 → Redoしないことを確認する
            AuxiliaryController           ac   = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();
            List <AuxiliaryLineParameter> list = new List <AuxiliaryLineParameter>();

            list.Add(ac.CloneParameter());

            ac.SetEvent();
            ac.PublishEvent(Keys.EnableKeys.Down);
            list.Add(ac.CloneParameter());

            ac.CancelEvent();
            AreParameterEqual(list[0], ac);

            // 適当に別操作
            ChangeAuxiliaryLineSizeWhereTopRight(ac, -100, -5, true);
            list[1] = ac.CloneParameter();

            ac.RedoEvent();
            AreParameterEqual(list[1], ac);
        }
Exemplo n.º 13
0
        public void TestCorrectAuxiliaryLineLeftAndTopIfMoveByMouse()
        {
            AuxiliaryController ac = Common.GetAuxiliaryControllerImage001RatioTypeW16H9();

            // まず矩形を小さくして移動テストできるようにする(Width基準とする)
            int    mouseUpPixelX = -(ac.AuxiliaryRight / 2);
            int    mouseUpPixelY = -5;
            double mouseUpX      = (double)ac.AuxiliaryRight + (double)mouseUpPixelX;
            double mouseUpY      = (double)ac.AuxiliaryBottom + (double)mouseUpPixelY;

            System.Windows.Point mouseDown = new System.Windows.Point((double)ac.AuxiliaryRight, (double)ac.AuxiliaryBottom);
            System.Windows.Point mouseUp   = new System.Windows.Point(mouseUpX, mouseUpY);
            ac.SetEvent(mouseDown);
            ac.PublishEvent(mouseUp);

            // 右下方向テスト
            int moveX = 100;
            int moveY = 80;

            MoveAuxiliaryLine(ac, moveX, moveY);

            // 左上方向テスト
            moveX = -50;
            moveY = -70;
            MoveAuxiliaryLine(ac, moveX, moveY);

            // 左下方向テスト
            moveX = -20;
            moveY = 40;
            MoveAuxiliaryLine(ac, moveX, moveY);

            // 右上方向テスト
            moveX = 40;
            moveY = 20;
            MoveAuxiliaryLine(ac, moveX, moveY);
        }