-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
136 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default function (test) { | ||
const namespace = 'Area' | ||
const methods = [ | ||
'projectTo', | ||
'transitRaw' | ||
] | ||
|
||
let i, m | ||
for (i = 0; i < methods.length; i += 1) { | ||
m = methods[i] | ||
test(namespace + ':' + m, import.meta.dirname, m + '.html') | ||
} | ||
} |
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,59 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Area:projectTo - Tapspace Test</title> | ||
<style> | ||
html, body { | ||
margin: 0; | ||
padding: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
#container { | ||
background: gray; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
#testspace { | ||
width: 800px; | ||
height: 600px; | ||
} | ||
</style> | ||
<script src="../../../../dist/tapspace.min.js"></script> | ||
<script src="../../testlib.js"></script> | ||
</head> | ||
<body> | ||
<div id="container"> | ||
<div id="testspace"></div> | ||
</div> | ||
<script> | ||
const t = test | ||
t.plan(1) | ||
|
||
// Setup | ||
const view = tapspace.createView('#testspace') | ||
const space = tapspace.createSpace() | ||
view.addChild(space) | ||
|
||
// Virtual camera | ||
const camDist = 300 | ||
const camera = view.atCenter().offset(0, 0, -camDist) | ||
|
||
// Create an element | ||
const hello = tapspace.createItem('hello') | ||
hello.setSize({ w: 20, h: 20 }) | ||
space.addChild(hello, space.at(10, 10, camDist)) | ||
|
||
// Create area | ||
const area = hello.getArea() | ||
|
||
// Original area: 400 | ||
t.equal( | ||
area.projectTo(view, camera).getNumber(), | ||
100, | ||
'should have quarter of original area' | ||
) | ||
</script> | ||
</body> | ||
</html> |
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,52 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Area:transitRaw - Tapspace Test</title> | ||
<style> | ||
html, body { | ||
margin: 0; | ||
padding: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
#container { | ||
background: gray; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
#testspace { | ||
width: 800px; | ||
height: 600px; | ||
} | ||
</style> | ||
<script src="../../../../dist/tapspace.min.js"></script> | ||
<script src="../../testlib.js"></script> | ||
</head> | ||
<body> | ||
<div id="container"> | ||
<div id="testspace"></div> | ||
</div> | ||
<script> | ||
const t = test | ||
t.plan(2) | ||
|
||
// Setup | ||
const view = tapspace.createView('#testspace') | ||
const space = tapspace.createSpace() | ||
view.addChild(space) | ||
space.scaleBy(2, space.at(0, 0)) | ||
|
||
// Create an element | ||
const hello = tapspace.createItem('hello') | ||
hello.setSize({ w: 20, h: 20 }) | ||
space.addChild(hello, space.at(10, 10, 10)) | ||
|
||
// Create area | ||
const area = hello.getArea() | ||
|
||
t.equal(area.getRaw(), 400, 'should have correct area') | ||
t.equal(area.transitRaw(view), 1600, 'should scale as area') | ||
</script> | ||
</body> | ||
</html> |
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,10 @@ | ||
import testArea from './Area/index.mjs' | ||
import { makeTestAllOk } from '../utils.mjs' | ||
|
||
export default function (test, browser) { | ||
// Custom test runner to reduce boilerplate code. | ||
// Opens the test page and evaluates the test results. | ||
const testAllOk = makeTestAllOk(test, browser) | ||
|
||
testArea(testAllOk) | ||
} |
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,7 +1,9 @@ | ||
import testComponents from './components/index.mjs' | ||
import testGeometry from './geometry/index.mjs' | ||
import testVersion from './version/index.mjs' | ||
|
||
export default function (test, browser) { | ||
testComponents(test, browser) | ||
testGeometry(test, browser) | ||
testVersion(test, browser) | ||
} |