Skip to content

Commit

Permalink
added testsuite for unify
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdit committed Jul 1, 2013
1 parent 4e08842 commit cc3ac19
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -13,6 +13,11 @@ application/coretest/source/script
application/coretest/test/script
application/coretest/api

unify/framework/external
unify/framework/test/external
unify/framework/test/.jasy
unify/framework/test/source/script

unify/application/flicky/log.txt
.DS_Store
.settings.xml
8 changes: 8 additions & 0 deletions unify/framework/test/jasyproject.json
@@ -0,0 +1,8 @@
{
"name": "test",

"requires" :
[
"../"
]
}
30 changes: 30 additions & 0 deletions unify/framework/test/jasyscript.py
@@ -0,0 +1,30 @@

@task
def source():
"""Generates source (development) version of test runner"""
core.test_source()

@task
def build():
"""Generates build (deployment) version of test runner"""
core.test_build()

@task
def clean():
"""Cleans up project environment"""

session.clean()
Repository.clean()

@task
def distclean():
"""Cleans up project environment with removing all non-repository files"""

session.clean()
Repository.distclean()

@task
def test(target="source", tool="phantom", browsers=None):
"""Automatically executes tests in either PhantomJS, NodeJS or Testem CI"""

core.test(target, tool, browsers)
6 changes: 6 additions & 0 deletions unify/framework/test/source/class/Kernel.js
@@ -0,0 +1,6 @@
core.Module("test.Kernel",
{
init : function() {
core.io.Script.load("script/test-" + jasy.Env.getId() + ".js");
}
});
2 changes: 2 additions & 0 deletions unify/framework/test/source/class/Main.js
@@ -0,0 +1,2 @@
/** #require(test.*) */
core.testrunner.Controller.run();
10 changes: 10 additions & 0 deletions unify/framework/test/source/class/bom/Uri.js
@@ -0,0 +1,10 @@

if (jasy.Env.isSet("runtime", "browser"))
{
var suite = new core.testrunner.Suite("bom/Uri");

suite.test("Basics", function()
{
this.isIdentical(typeof unify.bom.Uri, "object");
});
}
Empty file.
148 changes: 148 additions & 0 deletions unify/framework/test/source/class/theme/Theme.js
@@ -0,0 +1,148 @@

if (jasy.Env.isSet("runtime", "browser"))
{
var suite = new core.testrunner.Suite("theme/Theme");


suite.test("test for class", function()
{
this.isTrue(!!(new unify.theme.Theme({}) ), "Class is available" );
});

suite.test("theme name", function() {
var t = new unify.theme.Theme({
name: "Testname"
});
this.isEqual(t.name(), "Testname", "Theme has name Testname");
});

suite.test("colors", function() {
var t = new unify.theme.Theme({
colors: {
color1: "#ff0000",
color2: "green"
}
});
this.isEqual(t.resolveColor("color1"), "#ff0000", "Color1 is red");
this.isEqual(t.resolveColor("color2"), "green", "Color2 is green");
this.isEqual(t.resolveColor("color3"), null, "Color3 is not set");
});

suite.test("fonts", function() {
var t = new unify.theme.Theme({
fonts: {
font0: {},
font1: {
family: "sans-serif",
size: 12,
style: "italic",
weight: "bold",
decoration: "underline",
lineHeight: 1.5
},
font2: {
family: "Droid",
src: "Droid.ttf"
}
}
});
var font0 = t.resolveFont("font0");
this.isEqual(font0.fontSize, "16px", "Size of font0 is 16px per default");
this.isEqual(font0.fontStyle, "normal", "Style of font0 is normal per default");
this.isEqual(font0.fontWeight, "normal", "Weight of font0 is normal per default");
this.isEqual(font0.textDecoration, "none", "Text decoration of font0 is none per default");
this.isEqual(font0.lineHeight, 1.0, "Line height of font0 is 1.0 per default");
this.isEqual(font0.fontObject, null, "Font object of font0");

var font1 = t.resolveFont("font1");
this.isEqual(font1.fontFamily, "sans-serif", "Font family of font1");
this.isEqual(font1.fontSize, "12px", "Size of font1");
this.isEqual(font1.fontStyle, "italic", "Style of font1");
this.isEqual(font1.fontWeight, "bold", "Weight of font1");
this.isEqual(font1.textDecoration, "underline", "Text decoration of font1");
this.isEqual(font1.lineHeight, 1.5, "Line height of font1");

var font2 = t.resolveFont("font2");
this.isEqual(font2.fontFamily, "Droid", "Font family of font2");
this.isEqual(font0.fontSize, "16px", "Size of font2");
this.isEqual(font0.fontStyle, "normal", "Style of font2");
this.isEqual(font0.fontWeight, "normal", "Weight of font2");
this.isEqual(font0.textDecoration, "none", "Text decoration of font2");
this.isEqual(font0.lineHeight, 1.0, "Line height of font2");

this.isNull(t.resolveFont("font3"),"font3 is not set");
});

suite.test("styles", function() {
var t = new unify.theme.Theme({
styles: {
"a" : {
style : function(state) {
return {
a : true
};
}
},
"b" : {
include : "a"
},
"c" : {
include : "b",
style : function(state) {
return {
c : true
};
}
},
"d" : {
style : function(state) {
return {
d : true
};
}
},
"e": "a"
}
});

this.isEqual(t.resolveStyle("a").a, true, "Appearance a style a");
this.isEqual(t.resolveStyle("b").a, true, "Appearance b style a");
this.isEqual(t.resolveStyle("c").a, true, "Appearance c style a");
this.isEqual(t.resolveStyle("c").c, true, "Appearance c style c");
this.isEqual(t.resolveStyle("d").d, true, "Appearance d style d");
this.isEqual(t.resolveStyle("e").a, true, "Appearance e style a");
this.isEqual(t.resolveStyle("z"), null, "Appearance z is null");
});

suite.test("inherited styles", function() {
var t1 = new unify.theme.Theme({
styles: {
"a" : {
style : function(state) {
return {
a1 : true,
a3 : "1"
};
}
}
}
});
var t2 = new unify.theme.Theme({
include: t1,
styles: {
"a" : {
style : function(state) {
return {
a2 : true,
a3 : "2"
};
}
}
}
});

this.isEqual(t2.resolveStyle("a").a1, true, "Appearance a style a1");
this.isEqual(t2.resolveStyle("a").a2, true, "Appearance a style a2");
this.isEqual(t2.resolveStyle("a").a3, "2", "Appearance a style a3");
});
}
10 changes: 10 additions & 0 deletions unify/framework/test/source/index.html
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Core - Test Suite</title>
</head>
<body>
<script src="script/kernel.js"></script>
</body>
</html>
4 changes: 4 additions & 0 deletions unify/framework/test/source/node.js
@@ -0,0 +1,4 @@
#!/usr/bin/env node

eval(require("fs").readFileSync("script/kernel.js", "utf-8"));
core.io.Script.load("script/test-" + jasy.Env.CHECKSUM + ".js");
20 changes: 20 additions & 0 deletions unify/framework/test/source/phantom.js
@@ -0,0 +1,20 @@
#!/usr/bin/env phantomjs

var page = require("webpage").create();

page.onConsoleMessage = function(msg) {
console.log(msg);
};

page.onAlert = function(msg) {
console.warn("Alert: " + msg);
};

page.onCallback = function(data)
{
if (data.action == "finished") {
phantom.exit(data.status ? 0 : 1);
}
};

page.open("index.html");

0 comments on commit cc3ac19

Please sign in to comment.