From ac97df834399716813e0b7a7ff5fffdbbaf15490 Mon Sep 17 00:00:00 2001 From: Boris Sekachev <40690378+bsekachev@users.noreply.github.com> Date: Tue, 25 Dec 2018 14:05:18 +0300 Subject: [PATCH] Unit tests have been fixed (#249) * Fixed unit tests * Added copyright --- cvat/apps/engine/static/engine/js/base.js | 26 - .../engine/static/engine/js/idGenerator.js | 36 + .../engine/static/engine/js/qunitTests.js | 837 ++++++++++-------- cvat/apps/engine/templates/engine/base.html | 1 + tests/eslintrc.conf.js | 1 + tests/karma.conf.js | 1 + 6 files changed, 522 insertions(+), 380 deletions(-) create mode 100644 cvat/apps/engine/static/engine/js/idGenerator.js diff --git a/cvat/apps/engine/static/engine/js/base.js b/cvat/apps/engine/static/engine/js/base.js index 14b66331da6..35590355034 100644 --- a/cvat/apps/engine/static/engine/js/base.js +++ b/cvat/apps/engine/static/engine/js/base.js @@ -6,8 +6,6 @@ /* exported ExportType - IncrementIdGenerator - ConstIdGenerator confirm createExportContainer dumpAnnotationRequest @@ -245,30 +243,6 @@ function getExportTargetContainer(export_type, shape_type, container) { return shape_container_target; } -class IncrementIdGenerator { - constructor(startId=0) { - this._startId = startId; - } - - next() { - return this._startId++; - } - - reset(startId=0) { - this._startId = startId; - } -} - -class ConstIdGenerator { - constructor(startId=-1) { - this._startId = startId; - } - - next() { - return this._startId; - } -} - /* These HTTP methods do not require CSRF protection */ function csrfSafeMethod(method) { return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); diff --git a/cvat/apps/engine/static/engine/js/idGenerator.js b/cvat/apps/engine/static/engine/js/idGenerator.js new file mode 100644 index 00000000000..d9b4a3faeae --- /dev/null +++ b/cvat/apps/engine/static/engine/js/idGenerator.js @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + + /* exported + IncrementIdGenerator + ConstIdGenerator +*/ + +"use strict"; + +class IncrementIdGenerator { + constructor(startId=0) { + this._startId = startId; + } + + next() { + return this._startId++; + } + + reset(startId=0) { + this._startId = startId; + } +} + +class ConstIdGenerator { + constructor(startId=-1) { + this._startId = startId; + } + + next() { + return this._startId; + } +} diff --git a/cvat/apps/engine/static/engine/js/qunitTests.js b/cvat/apps/engine/static/engine/js/qunitTests.js index 78216e740fb..4b7bf2bb174 100644 --- a/cvat/apps/engine/static/engine/js/qunitTests.js +++ b/cvat/apps/engine/static/engine/js/qunitTests.js @@ -6,136 +6,129 @@ "use strict"; -let qunit_tests = []; +let qUnitTests = []; +window.cvat = { + translate: {} +}; -// RUN ALL TESTS +// Run all tests window.addEventListener('DOMContentLoaded', function() { - for (let qunit_test of qunit_tests) { - qunit_test(); + for (let qUnitTest of qUnitTests) { + qUnitTest(); } }); +qUnitTests.push(function() { + let labelsInfo = null; -// labels info unit tests -qunit_tests.push(function() { - let labels_info = null; - - QUnit.module('labels_info_class', { + QUnit.module('LabelsInfo_class', { before: function() { - labels_info = make_labels_info(); + labelsInfo = makeLabelsInfo(); } }); QUnit.test('labelIdOf', function(assert) { - assert.equal(labels_info.labelIdOf('person'), 1, 'Id of "car" must be 1'); - assert.equal(labels_info.labelIdOf('face'), 2, 'Id of "bicycle" must be 2'); - assert.equal(labels_info.labelIdOf('car'), 3, 'Id of "person" must be 3'); - assert.equal(labels_info.labelIdOf('bicycle'), 4, 'Id of "motorcycle" must be 4'); - assert.equal(labels_info.labelIdOf('motorcycle'), 5, 'Id of "unknown" must be 5'); - assert.equal(labels_info.labelIdOf('road'), 6, 'Id of "unknown" must be 6'); - assert.equal(labels_info.labelIdOf('unknown'), null, 'Id of "unknown" must be null'); + assert.equal(labelsInfo.labelIdOf('person'), 13, 'Id of "person" must be 13'); + assert.equal(labelsInfo.labelIdOf('face'), 14, 'Id of "face" must be 14'); + assert.equal(labelsInfo.labelIdOf('car'), 15, 'Id of "car" must be 15'); + assert.equal(labelsInfo.labelIdOf('bicycle'), 16, 'Id of "bicycle" must be 16'); + assert.equal(labelsInfo.labelIdOf('motorcycle'), 17, 'Id of "motorcycle" must be 17'); + assert.equal(labelsInfo.labelIdOf('road'), 18, 'Id of "road" must be 18'); + assert.equal(labelsInfo.labelIdOf('unknown'), null, 'Id of "unknown" must be null'); }); - QUnit.test('attrIdOf', function(assert) { - assert.equal(labels_info.attrIdOf('2','beard'), 8, 'Attribute id must be equal 8'); - assert.equal(labels_info.attrIdOf('3','parked'), 12, 'Attribute id must be equal 12'); - assert.equal(labels_info.attrIdOf('unknown','driver'), null, 'Attribute id must be equal null'); - assert.equal(labels_info.attrIdOf('1','unknown'), null, 'Attribute id must be equal null'); + assert.equal(labelsInfo.attrIdOf('14','beard'), 38, 'Attribute id must be equal 38'); + assert.equal(labelsInfo.attrIdOf('15','parked'), 42, 'Attribute id must be equal 42'); + assert.equal(labelsInfo.attrIdOf('unknown','driver'), null, 'Attribute id must be equal null'); + assert.equal(labelsInfo.attrIdOf('15','unknown'), null, 'Attribute id must be equal null'); }); - QUnit.test('strToValues', function(assert) { - assert.deepEqual(labels_info.strToValues('checkbox', 'false'), [false]); - assert.deepEqual(labels_info.strToValues('checkbox', 'false,true'), [true]); - assert.deepEqual(labels_info.strToValues('checkbox', '0'), [false]); - assert.deepEqual(labels_info.strToValues('checkbox', false), [false]); - assert.deepEqual(labels_info.strToValues('checkbox', 'abrakadabra'), [true]); - assert.deepEqual(labels_info.strToValues('select', 'value1,value2,value3'), ['value1', 'value2', 'value3']); - assert.deepEqual(labels_info.strToValues('select', 'value1'), ['value1']); - assert.deepEqual(labels_info.strToValues('text', 'value1,together value2 and 3'), ['value1,together value2 and 3']); - assert.deepEqual(labels_info.strToValues('radio', 'value'), ['value']); - assert.deepEqual(labels_info.strToValues('number', '1,2,3'), ['1','2','3']); - assert.deepEqual(labels_info.strToValues('number', 1), ['1']); + assert.deepEqual(labelsInfo.strToValues('checkbox', 'false'), [false]); + assert.deepEqual(labelsInfo.strToValues('checkbox', 'false,true'), [true]); + assert.deepEqual(labelsInfo.strToValues('checkbox', '0'), [false]); + assert.deepEqual(labelsInfo.strToValues('checkbox', false), [false]); + assert.deepEqual(labelsInfo.strToValues('checkbox', 'abrakadabra'), [true]); + assert.deepEqual(labelsInfo.strToValues('select', 'value1,value2,value3'), ['value1', 'value2', 'value3']); + assert.deepEqual(labelsInfo.strToValues('select', 'value1'), ['value1']); + assert.deepEqual(labelsInfo.strToValues('text', 'value1,together value2 and 3'), ['value1,together value2 and 3']); + assert.deepEqual(labelsInfo.strToValues('radio', 'value'), ['value']); + assert.deepEqual(labelsInfo.strToValues('number', '1,2,3'), ['1','2','3']); + assert.deepEqual(labelsInfo.strToValues('number', 1), ['1']); }); - QUnit.test('labels', function(assert) { let expected = { - 1:"person", - 2:"face", - 3:"car", - 4:"bicycle", - 5:"motorcycle", - 6:"road" + 13:"person", + 14:"face", + 15:"car", + 16:"bicycle", + 17:"motorcycle", + 18:"road" }; - assert.deepEqual(labels_info.labels(), expected, 'Return value must be like expected'); - }); + assert.deepEqual(labelsInfo.labels(), expected, 'Return value must be like expected'); + }); QUnit.test('attributes', function(assert) { let expected = { - 1:"action", - 2:"age", - 3:"gender", - 4:"false_positive", - 5:"clother", - 6:"age", - 7:"glass", - 8:"beard", - 9:"race", - 10:"model", - 11:"driver", - 12:"parked", - 13:"driver", - 14:"sport", - 15:"model" + 35:"action", + 32:"age", + 33:"gender", + 31:"false_positive", + 34:"clother", + 37:"age", + 36:"glass", + 38:"beard", + 39:"race", + 40:"model", + 41:"driver", + 42:"parked", + 44:"driver", + 43:"sport", + 45:"model" }; - assert.deepEqual(labels_info.attributes(), expected, 'Return value must be like expected'); - }); + assert.deepEqual(labelsInfo.attributes(), expected, 'Return value must be like expected'); + }); QUnit.test('labelAttributes', function(assert) { - let expected_1 = { - 1:"action", - 2:"age", - 3:"gender", - 4:"false_positive", - 5:"clother" - }; - - let expected_2 = { - 6:"age", - 7:"glass", - 8:"beard", - 9:"race" - }; - - let expected_3 = { - 10:"model", - 11:"driver", - 12:"parked" - }; - - let expected_4 = { - 13:"driver", - 14:"sport" - }; - - assert.deepEqual(labels_info.labelAttributes(1), labels_info.labelAttributes("1"), 'Return values must be equal'); - assert.deepEqual(labels_info.labelAttributes(1), expected_1, 'Return value must be like expected'); - assert.deepEqual(labels_info.labelAttributes("2"), expected_2, 'Return value must be like expected'); - assert.deepEqual(labels_info.labelAttributes(3), expected_3, 'Return value must be like expected'); - assert.deepEqual(labels_info.labelAttributes(4), expected_4, 'Return value must be like expected'); - assert.deepEqual(labels_info.labelAttributes(45), {}, 'Return value must be empty object'); - assert.deepEqual(labels_info.labelAttributes(), {}, 'Return value must be empty object'); - assert.deepEqual(labels_info.labelAttributes(null), {}, 'Return value must be empty object'); - assert.deepEqual(labels_info.labelAttributes("road"), {}, 'Return value must be empty object'); + assert.deepEqual(labelsInfo.labelAttributes(13), { + 35:"action", + 32:"age", + 33:"gender", + 31:"false_positive", + 34:"clother" + }, 'Return value must be like expected'); + + assert.deepEqual(labelsInfo.labelAttributes("14"), { + 37:"age", + 36:"glass", + 38:"beard", + 39:"race" + }, 'Return value must be like expected'); + + assert.deepEqual(labelsInfo.labelAttributes(15), { + 40:"model", + 41:"driver", + 42:"parked" + }, 'Return value must be like expected'); + + assert.deepEqual(labelsInfo.labelAttributes(16), { + 44:"driver", + 43:"sport" + }, 'Return value must be like expected'); + + assert.deepEqual(labelsInfo.labelAttributes(13), labelsInfo.labelAttributes("13"), 'Return values must be equal'); + assert.deepEqual(labelsInfo.labelAttributes(100), {}, 'Return value must be empty object'); + assert.deepEqual(labelsInfo.labelAttributes(), {}, 'Return value must be empty object'); + assert.deepEqual(labelsInfo.labelAttributes(null), {}, 'Return value must be empty object'); + assert.deepEqual(labelsInfo.labelAttributes("road"), {}, 'Return value must be empty object'); }); - QUnit.test('attrInfo', function(assert) { - let expected_1 = { + assert.deepEqual(labelsInfo.attrInfo(35), { name:"action", type:"select", mutable:true, @@ -145,148 +138,225 @@ qunit_tests.push(function() { "raising_hand", "standing" ] - }; + }, 'Return value must be like expected'); - let expected_5 = { + assert.deepEqual(labelsInfo.attrInfo(34), { name:"clother", type:"text", mutable:true, values: [ "non-initialized" ] - }; + }, 'Return value must be like expected'); - let expected_13 = { + assert.deepEqual(labelsInfo.attrInfo(41), { name:"driver", - type:"radio", + type:"select", mutable:false, values: [ + "__undefined__", "man", "woman" ] - }; + }, 'Return value must be like expected'); - assert.deepEqual(labels_info.attrInfo(4), labels_info.attrInfo("4"), 'Return values must be equal'); - assert.deepEqual(labels_info.attrInfo(1), expected_1, 'Return value must be like expected'); - assert.deepEqual(labels_info.attrInfo(5), expected_5, 'Return value must be like expected'); - assert.deepEqual(labels_info.attrInfo(13), expected_13, 'Return value must be like expected'); - assert.deepEqual(labels_info.attrInfo(45), {}, 'Return value must be empty object'); - assert.deepEqual(labels_info.attrInfo(), {}, 'Return value must be empty object'); - assert.deepEqual(labels_info.attrInfo("clother"), {}, 'Return value must be empty object'); - assert.deepEqual(labels_info.attrInfo(null), {}, 'Return value must be empty object'); + assert.deepEqual(labelsInfo.attrInfo(37), labelsInfo.attrInfo("37"), 'Return values must be equal'); + assert.deepEqual(labelsInfo.attrInfo(100), {}, 'Return value must be empty object'); + assert.deepEqual(labelsInfo.attrInfo(), {}, 'Return value must be empty object'); + assert.deepEqual(labelsInfo.attrInfo("clother"), {}, 'Return value must be empty object'); + assert.deepEqual(labelsInfo.attrInfo(null), {}, 'Return value must be empty object'); }); }); // annotation parser unit tests -qunit_tests.push(function() { - let labels_info = null; - let annotation_parser = null; +qUnitTests.push(function() { + let annotationParser = null; - QUnit.module('annotation_parser_class', { + QUnit.module('AnnotatinParser_class', { before: function() { - labels_info = make_labels_info(); - annotation_parser = make_annotation_parser(labels_info); + annotationParser = makeAnnotationParser(); } }); - let correct_xml = + let metaBlock = + ` + + 5 + QUnitTests + 16 + annotation + 0 + + False + 2018-12-24 16:43:33.275376+03:00 + 2018-12-24 16:52:19.644934+03:00 + 16 images: 12642-1.jpg, 24443-ycfych.jpeg, ... + + + + + + + + + + + 3 + 0 + 15 + http://localhost:8081/?id=3 + + + + admin + + + + 2018-12-25 11:58:50.400406+03:00 + + `; + + let correctXml = ` - 1.0 - - - adult (20-45) + 1.1 + ${metaBlock} + + no + adult (20-45) no asian - - __undefined__ + no + __undefined__ no asian - + + false 25 female - false - standing non-initialized + standing - + + false 25 female - false - standing non-initialized + standing - + - + `; - let incorrect_xml = + let incorrectXml = ` - 1.0 - - - adult (20- + 1.1 + ${metaBlock} + + + no + adult (20- `; - let unknown_label = + let unknownLabel = ` - 1.0 - - - adult (20-45) + 1.1 + ${metaBlock} + + no + adult (20-45) no asian - - - - `; - let unknown_attribute = + let unknownAttribute = ` - 1.0 - - - adult (20-45) + 1.1 + ${metaBlock} + + no + adult (20-45) no asian `; - let bad_attr_values = + let badAttributeValues = ` - 1.0 - - - adult (20-45) + 1.1 + ${metaBlock} + + some bad value + adult (20-45) no asian `; - let empty_xml = + let emptyXml = ` - `; + + 1.1 + `; let empty = { "boxes": [], @@ -300,318 +370,377 @@ qunit_tests.push(function() { }; QUnit.test('parse', function(assert) { - assert.deepEqual(annotation_parser.parse(correct_xml), window.job_data, 'Return value must be like expected.'); - assert.deepEqual(annotation_parser.parse(empty_xml), empty, 'Return value must be like expected.'); - assert.throws(annotation_parser.parse.bind(annotation_parser, bad_attr_values), 'This function must throw exception. Bad attribute values into XML.'); - assert.throws(annotation_parser.parse.bind(annotation_parser, incorrect_xml),'This function must throw exception. Bad input xml.'); - assert.throws(annotation_parser.parse.bind(annotation_parser, unknown_label),'This function must throw exception. Unknown label in input xml.'); - assert.throws(annotation_parser.parse.bind(annotation_parser, unknown_attribute),'This function must throw exception. Unknown attribute in input xml.'); + assert.deepEqual(annotationParser.parse(correctXml), window.jobData, 'Return value must be like expected.'); + assert.deepEqual(annotationParser.parse(emptyXml), empty, 'Return value must be like expected.'); + assert.throws(annotationParser.parse.bind(annotationParser, badAttributeValues), 'This function must throw exception. Bad attribute values into XML.'); + assert.throws(annotationParser.parse.bind(annotationParser, incorrectXml),'This function must throw exception. Bad input xml.'); + assert.throws(annotationParser.parse.bind(annotationParser, unknownLabel),'This function must throw exception. Unknown label in input xml.'); + assert.throws(annotationParser.parse.bind(annotationParser, unknownAttribute),'This function must throw exception. Unknown attribute in input xml.'); }); }); + // listener interface -qunit_tests.push(function() { - QUnit.module('listener_interface'); +qUnitTests.push(function() { + QUnit.module('Listener_interface'); QUnit.test('subscribe', function(assert) { - let listener_interface = new Listener('onUpdate', () => {return {};}); + let listenerInterface = new Listener('onUpdate', () => {return {};}); - let fake_listener_1 = { + let dummyListener1 = { onUpdate: function() {} }; - let fake_listener_2 = { + let dummyListener2 = { onUpdate: 'someProp' }; - let fake_listener_3 = { + let dummyListener3 = { // no onUpdate property }; - let fake_listener_4 = { + let dummyListener4 = { onUpdate: function() {} }; - let fake_listener_5 = { + let dummyListener5 = { onUpdate: function() {} }; - listener_interface.subscribe(fake_listener_1); // no exceptions, listener added - assert.throws(listener_interface.subscribe.bind(listener_interface, fake_listener_2), 'Function must be throw exception. Fake listener does not have onUpdate function'); - assert.throws(listener_interface.subscribe.bind(listener_interface, fake_listener_3), 'Function must be throw exception. Fake listener does not have onUpdate function'); - assert.deepEqual(listener_interface._listeners, [fake_listener_1], 'One listener must be added'); // check internal state - listener_interface.subscribe(fake_listener_4); // no exceptions, listener added - listener_interface.subscribe(fake_listener_5); // no exceptions, listener added - assert.deepEqual(listener_interface._listeners, [fake_listener_1, fake_listener_4, fake_listener_5], 'Three listener must be added'); // check internal state + listenerInterface.subscribe(dummyListener1); // no exceptions, listener added + assert.throws(listenerInterface.subscribe.bind(listenerInterface, dummyListener2), 'Function must be throw exception. Fake listener does not have onUpdate function'); + assert.throws(listenerInterface.subscribe.bind(listenerInterface, dummyListener3), 'Function must be throw exception. Fake listener does not have onUpdate function'); + assert.deepEqual(listenerInterface._listeners, [dummyListener1], 'One listener must be added'); // check internal state + listenerInterface.subscribe(dummyListener4); // no exceptions, listener added + listenerInterface.subscribe(dummyListener5); // no exceptions, listener added + assert.deepEqual(listenerInterface._listeners, [dummyListener1, dummyListener4, dummyListener5], 'Three listener must be added'); // check internal state }); QUnit.test('unsubscribe', function(assert) { - let listener_interface = new Listener('onUpdate', () => {return {};}); + let listenerInterface = new Listener('onUpdate', () => {return {};}); - let fake_listener_1 = { + let dummyListener1 = { onUpdate: function() {} }; - let fake_listener_2 = { + let dummyListener2 = { onUpdate: function() {} }; - let fake_listener_3 = { + let dummyListener3 = { onUpdate: function() {} }; - let fake_listener_4 = { + let dummyListener4 = { onUpdate: function() {} }; - listener_interface.subscribe(fake_listener_1); - listener_interface.subscribe(fake_listener_2); - listener_interface.subscribe(fake_listener_3); - listener_interface.subscribe(fake_listener_4); + listenerInterface.subscribe(dummyListener1); + listenerInterface.subscribe(dummyListener2); + listenerInterface.subscribe(dummyListener3); + listenerInterface.subscribe(dummyListener4); - listener_interface.unsubscribe(fake_listener_2); - listener_interface.unsubscribe(fake_listener_4); + listenerInterface.unsubscribe(dummyListener2); + listenerInterface.unsubscribe(dummyListener4); - assert.throws(listener_interface.unsubscribe.bind(listener_interface, null), 'Function must throw exception. Listener is not an object.'); - assert.throws(listener_interface.unsubscribe.bind(listener_interface), 'Function must throw exception. Listener is not an object.'); - assert.deepEqual(listener_interface._listeners, [fake_listener_1, fake_listener_3], 'Two listeners must be added'); + assert.throws(listenerInterface.unsubscribe.bind(listenerInterface, null), 'Function must throw exception. Listener is not an object.'); + assert.throws(listenerInterface.unsubscribe.bind(listenerInterface), 'Function must throw exception. Listener is not an object.'); + assert.deepEqual(listenerInterface._listeners, [dummyListener1, dummyListener3], 'Two listeners must be added'); - listener_interface.unsubscribe(fake_listener_1); - listener_interface.unsubscribe(fake_listener_3); + listenerInterface.unsubscribe(dummyListener1); + listenerInterface.unsubscribe(dummyListener3); - assert.deepEqual(listener_interface._listeners, [], 'Listener state must be empty'); + assert.deepEqual(listenerInterface._listeners, [], 'Listener state must be empty'); }); QUnit.test('unsubscribeAll', function(assert) { - let listener_interface = new Listener('onUpdate', () => {return {};}); - let fake_listener_1 = { onUpdate: function() {} }; - let fake_listener_2 = { onUpdate: function() {} }; + let listenerInterface = new Listener('onUpdate', () => {return {};}); + let dummyListener1 = { onUpdate: function() {} }; + let dummyListener2 = { onUpdate: function() {} }; - listener_interface.subscribe(fake_listener_1); - listener_interface.subscribe(fake_listener_2); + listenerInterface.subscribe(dummyListener1); + listenerInterface.subscribe(dummyListener2); - listener_interface.unsubscribeAll(); - assert.deepEqual(listener_interface._listeners, [], 'Listener state must be empty'); + listenerInterface.unsubscribeAll(); + assert.deepEqual(listenerInterface._listeners, [], 'Listener state must be empty'); }); }); + // player model unit tests -qunit_tests.push(function() { - let player_model = null; - QUnit.module('player_model_class', { +qUnitTests.push(function() { + let playerModel = null; + QUnit.module('PlayerModel_class', { before: function() { - player_model = make_player_model(); + playerModel = makePlayerModel(); } }); QUnit.test('scale', function(assert) { // Scale when player is not ready assert.expect(0); - player_model.scale(20,20,1); + playerModel.scale(20,20,1); }); QUnit.test('fit', function(assert) { // Fit when player is not ready assert.expect(0); - player_model.fit(); + playerModel.fit(); }); }); -function make_labels_info() { +function makeLabelsInfo() { return new LabelsInfo(window.job); } -function make_annotation_parser() { - return new AnnotationParser(window.job, make_labels_info()); +function makeAnnotationParser() { + return new AnnotationParser(window.job, makeLabelsInfo(), makeIncrementIdGenerator()); } -function make_player_model() { - let fake_player_geometry = { +function makeIncrementIdGenerator() { + return new IncrementIdGenerator(window.job.max_shape_id + 1); +} + +function makePlayerModel() { + let dummyPlayerGeometry = { width: 800, height: 600, left: 10, top: 10 }; - return new PlayerModel(window.job, fake_player_geometry); + return new PlayerModel(window.job, dummyPlayerGeometry); } + // stub data window.job = { - "jobid":1, - "labels":{ - "1":"person", - "2":"face", - "3":"car", - "4":"bicycle", - "5":"motorcycle", - "6":"road" - }, - "taskid":1, - "stop":12, - "z_order":true, - "overlap":0, - "slug":"QUnitTests", - "status":"Annotate", - "attributes":{ - "1":{ - "1":"~select=action:__undefined__,sitting,raising_hand,standing", - "2":"@number=age:1,100,1", - "3":"@select=gender:male,female", - "4":"@checkbox=false_positive:false", - "5":"~text=clother:non-initialized" - }, - "2":{ - "8":"@select=beard:__undefined__,skip,no,yes", - "9":"@select=race:__undefined__,skip,asian,black,caucasian,other", - "6":"@select=age:__undefined__,skip,baby (0-5),child (6-12),adolescent (13-19),adult (20-45),middle-age (46-64),old (65-)", - "7":"@select=glass:__undefined__,skip,no,sunglass,transparent,other" - }, - "3":{ - "10":"@select=model:__undefined__,bmw,mazda,suzuki,kia", - "11":"@select=driver:__undefined__,man,woman", - "12":"~checkbox=parked:true" - }, - "4":{ - "13":"@radio=driver:man,woman", - "14":"~checkbox=sport:false" - }, - "5":{ - "15":"@text=model:unknown" - }, - "6":{ - - } - }, - "flipped": false, "image_meta_data": { "original_size": [{ - "width": 3240, - "height": 2000 - }] - }, - "mode":"annotation", - "start":0 -}; - -window.job_data = { - "boxes": [{ - "label_id": 2, - "frame": 0, - "group_id": 0, - "occluded": 0, - "xtl": 1045.98, - "ytl": 403.64, - "xbr": 1127.48, - "ybr": 498.08, - "z_order": 8, - "attributes": [{ - "id": "6", - "value": "adult (20-45)" + "height": 1280, + "width": 1920 }, { - "id": "7", - "value": "no" + "height": 1280, + "width": 1920 }, { - "id": "8", - "value": "no" + "height": 1280, + "width": 1920 }, { - "id": "9", - "value": "asian" - }] - }, { - "label_id": 2, - "frame": 0, - "group_id": 0, - "occluded": 0, - "xtl": 766.53, - "ytl": 426.93, - "xbr": 858.39, - "ybr": 534.31, - "z_order": 9, - "attributes": [{ - "id": "6", - "value": "__undefined__" + "height": 1280, + "width": 1920 }, { - "id": "7", - "value": "no" + "height": 1280, + "width": 1920 }, { - "id": "8", - "value": "no" + "height": 1024, + "width": 962 }, { - "id": "9", - "value": "asian" + "height": 1280, + "width": 1920 + }, { + "height": 200, + "width": 200 + }, { + "height": 256, + "width": 128 + }, { + "height": 1280, + "width": 1920 + }, { + "height": 1280, + "width": 1920 + }, { + "height": 1280, + "width": 1920 + }, { + "height": 1280, + "width": 1920 + }, { + "height": 1280, + "width": 1920 + }, { + "height": 1280, + "width": 1920 + }, { + "height": 1280, + "width": 1920 }] - }], + }, + "z_order": true, + "start": 0, + "slug": "QUnitTests", + "mode": "annotation", + "labels": { + "18": "road", + "17": "motorcycle", + "16": "bicycle", + "15": "car", + "14": "face", + "13": "person" + }, + "status": "annotation", + "flipped": false, + "taskid": 5, + "overlap": 0, + "max_shape_id": 6, + "stop": 15, + "jobid": 3, + "attributes": { + "16": { + "43": "~checkbox=sport:false", + "44": "@radio=driver:man,woman" + }, + "17": { + "45": "@text=model:unknown" + }, + "18": { + + }, + "13": { + "32": "@number=age:1,100,1", + "33": "@select=gender:male,female", + "34": "~text=clother:non-initialized", + "35": "~select=action:__undefined__,sitting,raising_hand,standing", + "31": "@checkbox=false_positive:false" + }, + "14": { + "36": "@select=glass:__undefined__,skip,no,sunglass,transparent,other", + "37": "@select=age:__undefined__,skip,baby (0-5),child (6-12),adolescent (13-19),adult (20-45),middle-age (46-64),old (65-)", + "38": "@select=beard:__undefined__,skip,no,yes", + "39": "@select=race:__undefined__,skip,asian,black,caucasian,other" + }, + "15": { + "40": "@select=model:__undefined__,bmw,mazda,suzuki,kia", + "41": "@select=driver:__undefined__,man,woman", + "42": "~checkbox=parked:true" + } + } +}; + +window.jobData = { + "polyline_paths": [], + "points_paths": [], + "box_paths": [], + "polygon_paths": [], "polygons": [{ - "label_id": 1, - "frame": 0, - "group_id": 0, - "points": "1014.31,1043.74 1024.71,1053.62 1041.87,1061.93 1052.78,1067.13 1060.58,1069.21 1076.18,1070.25 1079.3,1068.69 1077.74,1057.26 1077.22,1048.94 1076.7,1041.14 1078.26,1031.26 1081.9,1016.7 1091.78,995.91 1101.14,975.11 1108.42,950.67 1118.81,967.31 1130.77,992.27 1132.33,1004.22 1127.13,1009.94 1120.89,1017.74 1115.69,1025.54 1104.26,1030.74 1096.46,1039.58 1096.46,1046.34 1104.26,1047.38 1125.05,1048.94 1141.69,1045.82 1144.29,1040.1 1158.85,1036.46 1171.33,1030.22 1172.89,1026.58 1167.69,1012.02 1157.81,993.31 1152.09,986.03 1152.09,977.19 1148.45,967.31 1142.21,944.95 1138.05,930.92 1138.05,922.08 1134.41,911.68 1128.17,897.64 1122.45,883.6 1120.37,856.57 1137.01,812.37 1256.07,783.78 1245.67,737.51 1240.99,701.11 1230.6,654.84 1216.56,609.09 1204.6,610.64 1198.36,608.57 1197.32,603.89 1192.1,598.9 1187.44,597.65 1185.36,581.53 1182.76,571.65 1177.56,553.45 1167.17,535.78 1164.57,525.38 1157.29,519.66 1145.33,513.42 1145.33,509.26 1139.09,505.62 1144.29,475.99 1139.09,449.99 1126.09,437.51 1124.53,436.99 1121.93,422.43 1113.61,414.12 1099.58,410.48 1079.82,410.48 1065.78,416.2 1055.38,419.83 1054.34,433.87 1052.78,445.83 1053.3,453.63 1051.74,462.99 1053.82,472.87 1056.94,484.82 1059.02,495.22 1062.66,498.86 1054.86,508.74 1041.87,514.98 1033.55,519.14 1028.35,529.02 1022.63,550.33 1020.55,563.85 1014.83,585.17 1009.63,602.33 1005.99,618.44 1006.51,630.4 1015.35,641.32 1019.51,643.92 1020.55,659.52 1018.99,677.71 1014.31,694.35 1012.75,706.31 1012.75,719.31 1010.15,728.67 1012.23,737.51 1012.23,752.06 1010.15,769.74 1007.03,794.18 1007.55,809.25 1021.59,810.29 1023.67,785.34 1025.75,760.9 1034.59,759.86 1041.87,758.82 1046.55,781.7 1053.82,800.94 1062.14,820.69 1067.34,839.41 1073.06,853.45 1071.5,873.2 1073.06,884.12 1075.14,891.92 1074.1,921.04 1069.94,945.99 1066.82,968.87 1063.18,996.42 1060.06,1012.54 1055.38,1017.22 1046.55,1016.7 1039.79,1016.18 1036.67,1019.3 1038.75,1025.02 1032.51,1026.58 1024.19,1025.02 1014.83,1029.18", "occluded": 0, - "z_order": 6, + "group_id": 0, "attributes": [{ - "id": "1", - "value": "standing" + "id": "31", + "value": false }, { - "id": "2", + "id": "32", "value": "25" }, { - "id": "3", + "id": "33", "value": "female" }, { - "id": "4", - "value": false - }, { - "id": "5", + "id": "34", "value": "non-initialized" - }] + }, { + "id": "35", + "value": "standing" + }], + "label_id": 13, + "z_order": 10, + "id": 9, + "points": "328.74,1031.61 633.3,1219.68 1010.84,1106 641.72,929.16", + "frame": 0 }, { - "label_id": 1, - "frame": 0, - "group_id": 0, - "points": "860.26,1048.76 871.05,1049.52 885.84,1047.76 896.87,1043.75 901.38,1034.47 904.39,1023.19 908.15,1013.91 906.9,1008.4 904.14,1006.64 901.63,991.35 897.62,990.34 897.12,985.58 893.61,983.82 892.61,976.55 899.38,969.78 902.14,964.02 900.13,957.5 898.63,951.48 898.12,940.7 896.37,930.17 893.86,924.4 892.11,909.11 888.09,894.56 881.58,879.77 874.56,870.24 871.05,861.47 871.3,854.2 871.3,835.89 873.05,817.34 876.31,801.29 880.32,786.75 889.6,786.75 905.4,783.99 922.45,782.24 930.47,780.48 934.23,778.22 939.5,776.47 944.01,771.45 944.76,764.18 942.25,750.14 937.49,734.09 932.47,714.54 927.96,705.76 924.2,682.69 914.42,641.07 909.66,623.27 905.65,608.48 903.39,598.45 900.13,599.2 924.2,707.02 914.67,710.02 895.87,711.28 889.1,711.28 884.33,708.52 877.06,706.26 876.06,701.25 878.57,701.25 879.82,700.25 880.82,698.74 885.59,698.24 890.35,698.24 890.1,695.73 889.35,692.72 888.85,688.71 882.58,690.47 877.06,690.47 874.81,685.45 875.81,681.44 876.31,675.92 874.56,671.16 873.55,668.65 873.3,663.14 874.3,655.87 876.31,651.6 877.56,644.83 878.07,639.32 882.83,633.3 885.34,623.27 891.35,611.99 892.86,603.46 894.36,595.94 895.87,591.93 897.87,593.68 897.87,595.94 898.88,598.45 900.63,598.95 903.64,598.95 901.63,588.17 898.12,575.38 897.12,571.37 897.62,553.57 894.61,548.8 890.35,544.79 889.35,538.02 884.84,536.52 880.57,537.27 878.57,537.52 877.06,535.77 872.8,535.01 870.29,535.01 868.04,533.76 869.54,526.74 867.28,516.96 866.03,510.19 861.52,505.18 857.76,501.42 854,492.14 852.49,482.36 851.99,475.34 848.23,458.79 841.71,440.24 831.43,432.46 821.4,428.2 808.86,426.45 797.33,427.95 787.55,431.46 778.02,438.23 771,446.76 772.76,457.79 775.27,471.08 778.02,476.34 779.03,482.61 778.27,488.88 778.02,493.89 781.03,499.91 784.04,506.18 789.81,515.71 793.07,519.97 795.83,524.73 796.08,527.74 790.56,531.25 784.54,534.76 774.01,536.02 765.74,537.52 757.96,542.28 754.71,548.8 749.44,559.59 745.93,569.87 741.42,585.16 737.4,599.95 733.39,610.48 729.63,619.51 725.62,629.54 723.61,637.81 724.62,646.59 725.12,656.87 725.87,663.89 727.38,669.16 731.14,672.16 735.65,673.92 745.93,675.17 755.71,678.18 751.45,689.21 747.18,701 745.68,714.04 754.71,718.8 751.45,725.32 748.44,735.85 745.68,745.38 742.42,755.41 740.16,769.45 739.41,784.49 737.66,800.79 738.16,842.41 737.25,863.17 736.35,880.92 733.64,896.57 731.54,910.11 731.84,924.25 729.73,935.68 727.63,950.13 726.42,966.98 724.32,982.62 721.61,1004.59 718.3,1013.61 708.37,1022.04 702.05,1026.55 691.22,1025.95 680.69,1024.44 673.77,1028.96 673.47,1041.89 682.49,1051.82 698.14,1057.24 709.87,1063.56 721.91,1068.07 732.14,1071.38 738.76,1071.98 743.57,1067.77 743.57,1056.64 745.08,1046.11 747.78,1036.18 746.28,1031.06 745.98,1019.93 749.89,1006.69 751.7,1000.67 756.21,999.77 764.03,995.86 764.33,983.52 768.24,973.29 770.35,955.84 773.66,938.99 777.27,921.84 779.98,904.99 781.18,895.07 789.31,860.77 791.11,845.42 798.33,831.88 807.66,815.63 810.97,805.1 815.18,823.16 821.5,840 825.41,861.07 830.23,877.31 832.93,893.26 840.76,907.4 850.38,919.14 853.09,929.06 857,944.11 859.11,957.35 861.52,965.77 865.43,977.51 869.04,982.92 868.74,991.35 868.14,999.77 868.14,1008.2 868.14,1013.91 865.43,1022.64 862.12,1029.26 858.21,1037.08 857.61,1043.1", "occluded": 0, - "z_order": 7, + "group_id": 0, "attributes": [{ - "id": "1", - "value": "standing" + "id": "31", + "value": false }, { - "id": "2", + "id": "32", "value": "25" }, { - "id": "3", + "id": "33", "value": "female" }, { - "id": "4", - "value": false - }, { - "id": "5", + "id": "34", "value": "non-initialized" - }] + }, { + "id": "35", + "value": "standing" + }], + "label_id": 13, + "z_order": 11, + "id": 10, + "points": "1064.14,997.18 1368.7,1185.26 1746.24,1071.57 1377.12,894.73", + "frame": 0 }], "polylines": [{ - "label_id": 6, - "frame": 0, - "group_id": 0, - "points": "1917.9,1060.2 1813.7,1033.4 1696,1007.7 1570.48,980.03 1428.17,952.86 1316.91,932.16 1217.29,916.64 1134.5,903.7 1063.34,890.77 976.66,880.42 889.98,870.07 816.24,862.3 724.38,854.54 649.35,845.49 541.97,836.04 437.05,826.73 329.15,819.87 246.87,816.64 139.23,811.46 34.18,806.93", "occluded": 1, - "z_order": 5, - "attributes": [] + "group_id": 0, + "attributes": [], + "label_id": 18, + "z_order": 13, + "id": 11, + "points": "108.39,1021.79 275.4,329.86", + "frame": 0 }], "points": [{ - "label_id": 6, - "frame": 0, + "occluded": 0, + "group_id": 0, + "attributes": [], + "label_id": 18, + "z_order": 14, + "id": 12, + "points": "1304.18,345.3 1544.18,317.23 1643.82,196.53 1309.79,190.91", + "frame": 0 + }], + "boxes": [{ + "xtl": 438.21, + "group_id": 0, + "xbr": 1043.12, + "ytl": 291.96, + "label_id": 14, + "z_order": 8, + "id": 7, + "attributes": [{ + "id": "36", + "value": "no" + }, { + "id": "37", + "value": "adult (20-45)" + }, { + "id": "38", + "value": "no" + }, { + "id": "39", + "value": "asian" + }], + "ybr": 764.95, + "occluded": 0, + "frame": 0 + }, { + "xtl": 1077.47, "group_id": 0, - "points": "1334.48,1137.18 511.5,1134.4 515.55,706.37 1334.48,707.67", + "xbr": 1682.38, + "ytl": 489.11, + "label_id": 14, + "z_order": 9, + "id": 8, + "attributes": [{ + "id": "36", + "value": "no" + }, { + "id": "37", + "value": "__undefined__" + }, { + "id": "38", + "value": "no" + }, { + "id": "39", + "value": "asian" + }], + "ybr": 962.1, "occluded": 0, - "z_order": 10, - "attributes": [] + "frame": 0 }], - "box_paths": [], - "polygon_paths": [], - "polyline_paths": [], - "points_paths": [] -}; \ No newline at end of file +}; diff --git a/cvat/apps/engine/templates/engine/base.html b/cvat/apps/engine/templates/engine/base.html index 6df91bf64bc..beb3778369a 100644 --- a/cvat/apps/engine/templates/engine/base.html +++ b/cvat/apps/engine/templates/engine/base.html @@ -37,6 +37,7 @@ {% compress js file cvat %} {% block head_js_cvat %} + {% endblock %} {% endcompress %} diff --git a/tests/eslintrc.conf.js b/tests/eslintrc.conf.js index fe822dee0f3..cd04f937236 100644 --- a/tests/eslintrc.conf.js +++ b/tests/eslintrc.conf.js @@ -52,6 +52,7 @@ module.exports = { 'createExportContainer': true, 'ExportType': true, 'getExportTargetContainer': true, + // from idGenerator.js 'IncrementIdGenerator': true, 'ConstIdGenerator': true, // from shapeCollection.js diff --git a/tests/karma.conf.js b/tests/karma.conf.js index cf681a58b23..c123c08741d 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -10,6 +10,7 @@ module.exports = function(config) { basePath: path.join(process.env.HOME, 'cvat/apps/'), frameworks: ['qunit'], files: [ + 'engine/static/engine/js/idGenerator.js', 'engine/static/engine/js/labelsInfo.js', 'engine/static/engine/js/annotationParser.js', 'engine/static/engine/js/listener.js',