|
| 1 | +// Copyright (C) 2021 Intel Corporation |
| 2 | +// |
| 3 | +// SPDX-License-Identifier: MIT |
| 4 | + |
| 5 | +/// <reference types="cypress" /> |
| 6 | + |
| 7 | +import { taskName, labelName } from '../../support/const'; |
| 8 | +import { generateString } from '../../support/utils'; |
| 9 | + |
| 10 | +context('OpenCV. Intelligent cissors. Histogram Equalization.', () => { |
| 11 | + const caseId = '101'; |
| 12 | + const newLabel = `Case ${caseId}` |
| 13 | + const createOpencvShape = { |
| 14 | + labelName: labelName, |
| 15 | + pointsMap: [ |
| 16 | + { x: 200, y: 200 }, |
| 17 | + { x: 250, y: 200 }, |
| 18 | + { x: 300, y: 250 }, |
| 19 | + { x: 350, y: 300 }, |
| 20 | + { x: 300, y: 350 }, |
| 21 | + ], |
| 22 | + }; |
| 23 | + const createOpencvShapeSecondLabel = { |
| 24 | + labelName: newLabel, |
| 25 | + pointsMap: [ |
| 26 | + { x: 300, y: 200 }, |
| 27 | + { x: 350, y: 200 }, |
| 28 | + { x: 400, y: 250 }, |
| 29 | + { x: 450, y: 300 }, |
| 30 | + { x: 400, y: 350 }, |
| 31 | + ], |
| 32 | + finishWithButton: true, |
| 33 | + }; |
| 34 | + const keyCodeN = 78; |
| 35 | + const pointsMap = [ |
| 36 | + { x: 300, y: 400 }, |
| 37 | + { x: 350, y: 500 }, |
| 38 | + { x: 400, y: 450 }, |
| 39 | + { x: 450, y: 500 }, |
| 40 | + { x: 400, y: 550 }, |
| 41 | + ]; |
| 42 | + |
| 43 | + function openOpencvControlPopover() { |
| 44 | + cy.get('body').focus(); |
| 45 | + cy.get('.cvat-tools-control').trigger('mouseleave').trigger('mouseout').trigger('mouseover'); |
| 46 | + } |
| 47 | + |
| 48 | + before(() => { |
| 49 | + cy.openTask(taskName); |
| 50 | + cy.addNewLabel(newLabel); |
| 51 | + cy.openJob(); |
| 52 | + }); |
| 53 | + |
| 54 | + describe(`Testing case "${caseId}"`, () => { |
| 55 | + it('Load OpenCV.', () => { |
| 56 | + openOpencvControlPopover(); |
| 57 | + cy.get('.cvat-opencv-control-popover-visible').find('.cvat-opencv-initialization-button').click(); |
| 58 | + // Intelligent cissors button be visible |
| 59 | + cy.get('.cvat-opencv-drawing-tool').should('exist').and('be.visible'); |
| 60 | + }); |
| 61 | + |
| 62 | + it('Create a shape with "Intelligent cissors". Create the second shape with the label change and "Done" button.', () => { |
| 63 | + cy.opencvCreateShape(createOpencvShape); |
| 64 | + cy.opencvCreateShape(createOpencvShapeSecondLabel); |
| 65 | + }); |
| 66 | + |
| 67 | + it('Change the number of points when the shape is drawn. Cancel drawing.', () => { |
| 68 | + openOpencvControlPopover(); |
| 69 | + cy.get('.cvat-opencv-drawing-tool').click(); |
| 70 | + pointsMap.forEach((element) => { |
| 71 | + cy.get('.cvat-canvas-container').click(element.x, element.y); |
| 72 | + }); |
| 73 | + cy.get('.cvat_canvas_interact_intermediate_shape').then((intermediateShape) => { |
| 74 | + // Get count of points |
| 75 | + const intermediateShapeNumberPointsBeforeChange = intermediateShape.attr('points').split(' ').length; |
| 76 | + // Change number of points |
| 77 | + cy.get('.cvat-approx-poly-threshold-wrapper') |
| 78 | + .find('[role="slider"]') |
| 79 | + .type(generateString(4, 'rightarrow')); |
| 80 | + cy.get('.cvat_canvas_interact_intermediate_shape').then((intermediateShape) => { |
| 81 | + // Get count of points againe |
| 82 | + const intermediateShapeNumberPointsAfterChange = intermediateShape.attr('points').split(' ').length; |
| 83 | + // expected 7 to be below 10 |
| 84 | + expect(intermediateShapeNumberPointsBeforeChange).to.be.lt(intermediateShapeNumberPointsAfterChange); |
| 85 | + }); |
| 86 | + }); |
| 87 | + cy.get('body').type('{Esc}'); // Cancel drawing |
| 88 | + cy.get('.cvat_canvas_interact_intermediate_shape').should('not.exist'); |
| 89 | + cy.get('.cvat_canvas_shape').should('have.length', 2); |
| 90 | + }); |
| 91 | + |
| 92 | + it('Check "Histogram Equalization" feature.', () => { |
| 93 | + openOpencvControlPopover(); |
| 94 | + cy.get('.cvat-opencv-control-popover-visible').contains('[role="tab"]', 'Image').click(); |
| 95 | + cy.get('.cvat-opencv-image-tool').click().should('have.class', 'cvat-opencv-image-tool-active').trigger('mouseout'); |
| 96 | + cy.get('.cvat-notification-notice-opencv-processing-error').should('not.exist'); |
| 97 | + cy.get('.cvat-opencv-image-tool').click().should('not.have.class', 'cvat-opencv-image-tool-active').trigger('mouseout'); |
| 98 | + }); |
| 99 | + |
| 100 | + // Waiting for fix https://github.com/openvinotoolkit/cvat/issues/3474 |
| 101 | + it.skip('Redraw the shape created with "Intelligent cissors".', () => { |
| 102 | + cy.get('.cvat-canvas-container').click(); |
| 103 | + cy.get('.cvat-opencv-control-popover').should('be.hidden'); |
| 104 | + cy.get('#cvat_canvas_shape_1') |
| 105 | + .trigger('mousemove') |
| 106 | + .trigger('mouseover') |
| 107 | + .should('have.class', 'cvat_canvas_shape_activated'); |
| 108 | + cy.get('body').trigger('keydown', { keyCode: keyCodeN, shiftKey: true }).trigger('keyup'); |
| 109 | + cy.get('.cvat-tools-control').should('have.attr', 'tabindex'); |
| 110 | + createOpencvShape.pointsMap.forEach((el) => { |
| 111 | + cy.get('.cvat-canvas-container') |
| 112 | + .click(el.x + 150, el.y + 50) |
| 113 | + }); |
| 114 | + cy.get('body').trigger('keydown', { keyCode: keyCodeN }).trigger('keyup'); |
| 115 | + }); |
| 116 | + }); |
| 117 | +}); |
0 commit comments