11var fs = require ( 'fs' ) ;
22var path = require ( 'path' ) ;
33var getPixels = require ( "get-pixels" ) ;
4- var assert = require ( 'assert' ) ;
54var images = require ( 'images' ) ;
65
76var commonTools = ( {
@@ -20,6 +19,7 @@ var commonTools = ({
2019 var baseDir = path . resolve ( __dirname , '../../' ) . replace ( / \\ / g, '/' ) ;
2120 var exampleUrl = baseDir + '/examples/' + type + '/' + exampleName + '.html' ;
2221 browser . url ( exampleUrl ) ;
22+ browser . pause ( 2000 ) ;
2323 browser . expect . element ( 'body' ) . to . be . present . before ( 2000 ) ;
2424 browser . expect . element ( '#map' ) . to . be . present . before ( 3000 ) ;
2525 browser . pause ( 1000 ) ;
@@ -83,7 +83,7 @@ var commonTools = ({
8383 } ) ;
8484 browser . pause ( 5000 , function ( ) {
8585 console . log ( 'start to compare two tiles' ) ;
86- commonTools . isTwoTilesEqual ( tileStandardPath , tileTestPath ) ;
86+ commonTools . isTwoTilesEqual ( browser , tileStandardPath , tileTestPath ) ;
8787 } ) ;
8888 } ,
8989
@@ -101,13 +101,13 @@ var commonTools = ({
101101 * function: compare two image by tilePath,
102102 * return : boolean
103103 * */
104- isTwoTilesEqual : function ( tilePath1 , tilePath2 ) {
104+ isTwoTilesEqual : function ( browser , tilePath1 , tilePath2 ) {
105105 var array1 = [ ] ;
106106 var array2 = [ ] ;
107107 console . log ( 'start to compare two tiles' ) ;
108108 getPixels ( tilePath1 , function ( err , pixels ) {
109109 if ( err ) {
110- assert . ok ( false , "path in tile1 not exist: " + tilePath1 ) ;
110+ browser . assert . ok ( false , "path in tile1 not exist: " + tilePath1 ) ;
111111 return ;
112112 }
113113 for ( var i = 0 ; i < pixels . data . length ; i ++ ) {
@@ -116,15 +116,19 @@ var commonTools = ({
116116 console . log ( 'tile1 ( ' + tilePath1 + ' ) has pixels : ' + ( array1 . length / 4 ) ) ;
117117 getPixels ( tilePath2 , function ( err , pixels ) {
118118 if ( err ) {
119- assert . ok ( false , "path in tile2 not exist: " + tilePath2 ) ;
119+ browser . assert . ok ( false , "path in tile2 not exist: " + tilePath2 ) ;
120120 return ;
121121 }
122122 for ( var i = 0 ; i < pixels . data . length ; i ++ ) {
123123 array2 . push ( pixels . data [ i ] ) ;
124124 }
125125 console . log ( 'tile2 ( ' + tilePath2 + ' ) has pixels : ' + ( array2 . length / 4 ) ) ;
126126 var isEqual = commonTools . judgeTwoTilesByRgbaArrays ( array1 , array2 ) ;
127- assert . ok ( isEqual , 'similarity of two tiles are too low' )
127+ if ( isEqual ) {
128+ browser . assert . ok ( isEqual , 'similarity of two pictures >= 0.94' ) ;
129+ } else {
130+ browser . assert . ok ( isEqual , 'similarity of two pictures < 0.94' ) ;
131+ }
128132 } ) ;
129133 } ) ;
130134 } ,
0 commit comments