Skip to content

Commit c581678

Browse files
committed
test: add multi-renderTyoe test, fix #55
1 parent 386b7a1 commit c581678

File tree

6 files changed

+51
-34
lines changed

6 files changed

+51
-34
lines changed
8.02 KB
Loading
-9.85 KB
Binary file not shown.
10.9 KB
Loading
10.7 KB
Loading

test/html/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
<script>
3535
_macaca_uitest.setup({
3636
ui: 'bdd',
37-
timeout: 5000,
38-
slow: 2000
37+
timeout: 10000,
38+
slow: 5000
3939
});
4040
</script>
4141
<script src="../core.js"></script>

test/view.js

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
describe('view', function() {
1+
['canvas', 'webgl', 'dom'].forEach(function(stageRenderType){
2+
3+
describe('view:' + stageRenderType, function() {
24
var stage, ticker;
35
var stageElem = document.getElementById('stage');
46
beforeEach('init stage', function() {
57
stage = new Hilo.Stage({
68
container:stageElem,
7-
renderType:'canvas',
9+
renderType:stageRenderType,
810
width:550,
911
height:400
1012
});
@@ -43,16 +45,27 @@ describe('view', function() {
4345
utils.diffWithScreenshot('Bitmap-new', done);
4446
});
4547

46-
it('transform & alpha', function(done){
48+
it('transform', function(done){
4749
bmp.x = stage.width * .5;
4850
bmp.y = stage.height * .5;
4951
bmp.pivotX = bmp.width * .4;
5052
bmp.pivotY = bmp.height * .6;
5153
bmp.scaleX = 0.5;
5254
bmp.scaleY = -2;
5355
bmp.rotation = 30;
56+
if(stageRenderType === 'dom'){
57+
utils.diffWithScreenshot('Bitmap-transform-dom', done);
58+
}
59+
else{
60+
utils.diffWithScreenshot('Bitmap-transform', done);
61+
}
62+
});
63+
64+
it('alpha', function(done){
65+
bmp.x = stage.width * .5;
66+
bmp.y = stage.height * .5;
5467
bmp.alpha = 0.5;
55-
utils.diffWithScreenshot('Bitmap-transform-alpha', done);
68+
utils.diffWithScreenshot('Bitmap-alpha', done);
5669
});
5770

5871
it('setImage', function(done){
@@ -427,34 +440,36 @@ describe('view', function() {
427440
});
428441

429442
it('resize', function(){
430-
stage.canvas.width.should.equal(550);
431-
stage.canvas.height.should.equal(400);
432-
stage.canvas.style.width.should.equal('550px');
433-
stage.canvas.style.height.should.equal('400px');
434-
stage.viewport.should.eql({left:0, top:0, width:550, height:400});
435-
436-
stage.resize(400, 300);
437-
stage.canvas.width.should.equal(400);
438-
stage.canvas.height.should.equal(300);
439-
stage.canvas.style.width.should.equal('400px');
440-
stage.canvas.style.height.should.equal('300px');
441-
stage.viewport.should.eql({left:0, top:0, width:400, height:300});
442-
443-
stage.scaleX = 0.5;
444-
stage.scaleY = 2;
445-
stage.tick(0);
446-
stage.canvas.width.should.equal(400);
447-
stage.canvas.height.should.equal(300);
448-
stage.canvas.style.width.should.equal('200px');
449-
stage.canvas.style.height.should.equal('600px');
450-
stage.viewport.should.eql({left:0, top:0, width:200, height:600});
451-
452-
stage.resize(300, 200);
453-
stage.canvas.width.should.equal(300);
454-
stage.canvas.height.should.equal(200);
455-
stage.canvas.style.width.should.equal('150px');
456-
stage.canvas.style.height.should.equal('400px');
457-
stage.viewport.should.eql({left:0, top:0, width:150, height:400});
443+
if(stageRenderType !== 'dom'){
444+
stage.canvas.width.should.equal(550);
445+
stage.canvas.height.should.equal(400);
446+
stage.canvas.style.width.should.equal('550px');
447+
stage.canvas.style.height.should.equal('400px');
448+
stage.viewport.should.eql({left:0, top:0, width:550, height:400});
449+
450+
stage.resize(400, 300);
451+
stage.canvas.width.should.equal(400);
452+
stage.canvas.height.should.equal(300);
453+
stage.canvas.style.width.should.equal('400px');
454+
stage.canvas.style.height.should.equal('300px');
455+
stage.viewport.should.eql({left:0, top:0, width:400, height:300});
456+
457+
stage.scaleX = 0.5;
458+
stage.scaleY = 2;
459+
stage.tick(0);
460+
stage.canvas.width.should.equal(400);
461+
stage.canvas.height.should.equal(300);
462+
stage.canvas.style.width.should.equal('200px');
463+
stage.canvas.style.height.should.equal('600px');
464+
stage.viewport.should.eql({left:0, top:0, width:200, height:600});
465+
466+
stage.resize(300, 200);
467+
stage.canvas.width.should.equal(300);
468+
stage.canvas.height.should.equal(200);
469+
stage.canvas.style.width.should.equal('150px');
470+
stage.canvas.style.height.should.equal('400px');
471+
stage.viewport.should.eql({left:0, top:0, width:150, height:400});
472+
}
458473
});
459474

460475
it('canvasRenderer', function(){
@@ -628,4 +643,6 @@ describe('view', function() {
628643

629644
});
630645
});
646+
});
647+
631648
});

0 commit comments

Comments
 (0)