1
- describe ( 'view' , function ( ) {
1
+ [ 'canvas' , 'webgl' , 'dom' ] . forEach ( function ( stageRenderType ) {
2
+
3
+ describe ( 'view:' + stageRenderType , function ( ) {
2
4
var stage , ticker ;
3
5
var stageElem = document . getElementById ( 'stage' ) ;
4
6
beforeEach ( 'init stage' , function ( ) {
5
7
stage = new Hilo . Stage ( {
6
8
container :stageElem ,
7
- renderType :'canvas' ,
9
+ renderType :stageRenderType ,
8
10
width :550 ,
9
11
height :400
10
12
} ) ;
@@ -43,16 +45,27 @@ describe('view', function() {
43
45
utils . diffWithScreenshot ( 'Bitmap-new' , done ) ;
44
46
} ) ;
45
47
46
- it ( 'transform & alpha ' , function ( done ) {
48
+ it ( 'transform' , function ( done ) {
47
49
bmp . x = stage . width * .5 ;
48
50
bmp . y = stage . height * .5 ;
49
51
bmp . pivotX = bmp . width * .4 ;
50
52
bmp . pivotY = bmp . height * .6 ;
51
53
bmp . scaleX = 0.5 ;
52
54
bmp . scaleY = - 2 ;
53
55
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 ;
54
67
bmp . alpha = 0.5 ;
55
- utils . diffWithScreenshot ( 'Bitmap-transform- alpha' , done ) ;
68
+ utils . diffWithScreenshot ( 'Bitmap-alpha' , done ) ;
56
69
} ) ;
57
70
58
71
it ( 'setImage' , function ( done ) {
@@ -427,34 +440,36 @@ describe('view', function() {
427
440
} ) ;
428
441
429
442
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
+ }
458
473
} ) ;
459
474
460
475
it ( 'canvasRenderer' , function ( ) {
@@ -628,4 +643,6 @@ describe('view', function() {
628
643
629
644
} ) ;
630
645
} ) ;
646
+ } ) ;
647
+
631
648
} ) ;
0 commit comments