-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement/17 write unit tests (#28)
- Refactored to improve testability - Wrote unit tests for getNormalisedCentrePointOf, getPupilDisplacement, and getTrackingTarget - Fixed fault in getPupilDisplacement - Changed FOV bound tuning variables to sensitivity, as this is more intuitive.
- Loading branch information
Adam McDevitt
authored
Jun 13, 2019
1 parent
74ef100
commit 6873624
Showing
12 changed files
with
284 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"name": "vscode-jest-tests", | ||
"request": "launch", | ||
"args": [ | ||
"--runInBand" | ||
], | ||
"cwd": "${workspaceFolder}", | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest" | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch Program", | ||
"program": "${workspaceFolder}\\tests\\framefeed.jest.js" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
:root { | ||
--main-background-colour: #222; | ||
--menu-background-colour: #111; | ||
--menu-text-colour: #818181; | ||
--menu-top-padding: 60px; | ||
--menu-z-index: 10; | ||
--canvas-z-index: 20; | ||
--canvas-width: 100%; | ||
} | ||
|
||
body { | ||
/* Position */ | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
|
||
/* View */ | ||
overflow: hidden; | ||
background: var(--main-background-colour); | ||
|
||
/* Font */ | ||
font-family: sans-serif; | ||
font-style: italic; | ||
font-size: calc(0.6em + 1vw); | ||
} | ||
|
||
.sidenav { | ||
/* Position */ | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
width: 0; | ||
position: fixed; | ||
|
||
/* View */ | ||
padding-top: var(--menu-top-padding); | ||
background-color: var(--menu-background-colour); | ||
overflow-x: hidden; | ||
z-index: var(--menu-z-index); | ||
display: inline-block; | ||
|
||
/* Font */ | ||
text-decoration: none; | ||
color: var(--menu-text-colour); | ||
} | ||
|
||
.sidenav a, | ||
.sidenav label, | ||
.sidenav input { | ||
padding: 0.4em; | ||
font-size: 1.2em; | ||
width: 8em; | ||
display: inline-block; | ||
} | ||
|
||
.sidenav input { | ||
width: 3em; | ||
} | ||
|
||
canvas { | ||
width: var(--canvas-width); | ||
position: relative; | ||
z-index: var(--canvas-z-index); | ||
} | ||
--main-background-colour: #222; | ||
--menu-background-colour: #111; | ||
--menu-text-colour: #818181; | ||
--menu-top-padding: 60px; | ||
--menu-z-index: 10; | ||
--canvas-z-index: 20; | ||
--canvas-width: 100%; | ||
} | ||
body { | ||
/* Position */ | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
/* View */ | ||
overflow: hidden; | ||
background: var(--main-background-colour); | ||
/* Font */ | ||
font-family: sans-serif; | ||
font-style: italic; | ||
font-size: calc(0.6em + 1vw); | ||
} | ||
.sidenav { | ||
/* Position */ | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
width: 0; | ||
position: fixed; | ||
/* View */ | ||
padding-top: var(--menu-top-padding); | ||
background-color: var(--menu-background-colour); | ||
overflow-x: hidden; | ||
z-index: var(--menu-z-index); | ||
display: inline-block; | ||
/* Font */ | ||
text-decoration: none; | ||
color: var(--menu-text-colour); | ||
} | ||
.sidenav a, | ||
.sidenav label, | ||
.sidenav input { | ||
padding: 0.4em; | ||
font-size: 1.2em; | ||
width: 8em; | ||
display: inline-block; | ||
} | ||
.sidenav input { | ||
width: 3em; | ||
} | ||
canvas { | ||
width: var(--canvas-width); | ||
position: relative; | ||
z-index: var(--canvas-z-index); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const getNormalisedCentrePointOf = require('../src/static/js/frame_feed').getNormalisedCentrePointOf; | ||
var video_1920_1080 = {width: 1920, height: 1080}; | ||
describe('getNormalisedCentrePointof', () => { | ||
it('bounding box is point in bottom left corner, so is centre point', () => { | ||
var coords = [0, 0, 0, 0]; | ||
point = getNormalisedCentrePointOf(coords, video_1920_1080); | ||
expect(point).toStrictEqual([-1,-1]); | ||
}); | ||
it('bounding box spans screen, so point is in centre of screen', () => { | ||
var coords = [0, 0, 1920, 1080]; | ||
point = getNormalisedCentrePointOf(coords, video_1920_1080); | ||
expect(point).toStrictEqual([0,0]); | ||
}); | ||
it('bounding box is point in exact middle of screen, so centre point is in centre of screen', () => { | ||
var coords = [960, 540, 0, 0]; | ||
point = getNormalisedCentrePointOf(coords, video_1920_1080); | ||
expect(point).toStrictEqual([0,0]); | ||
}); | ||
it('centre point does not have integer coordinates', () => { | ||
var coords = [500, 500, 1000, 20]; | ||
point = getNormalisedCentrePointOf(coords, video_1920_1080); | ||
expect(point[0]).toBeCloseTo(0.04167); | ||
expect(point[1]).toBeCloseTo(-0.05555555); | ||
}); | ||
}); |
Oops, something went wrong.