99 ListView ,
1010 Image ,
1111 TouchableOpacity ,
12+ Dimensions ,
1213 RecyclerViewBackedScrollView ,
1314} from 'react-native' ;
1415
@@ -20,9 +21,11 @@ export default class Reporter extends Component {
2021 constructor ( props :any ) {
2122 super ( props )
2223 this . tests = {
23- summary : [ { } ] ,
2424 common : [ ]
2525 }
26+ this . state = {
27+ listHeight : 0
28+ }
2629 this . testGroups = [ 'summary' , 'common' ]
2730 this . ds = null
2831 this . updateDataSource ( )
@@ -35,20 +38,49 @@ export default class Reporter extends Component {
3538
3639 render ( ) {
3740
41+ let tests = RNTEST . TestContext . getTests ( )
42+
43+ let passed = 0
44+ let executed = 0
45+ let count = 0
46+ for ( let i in tests ) {
47+ if ( tests [ i ] . status !== 'skipped' )
48+ count ++
49+ if ( tests [ i ] . status !== 'waiting' && tests [ i ] . status !== 'skipped' )
50+ executed ++
51+ passed += tests [ i ] . status === 'pass' ? 1 : 0
52+ }
53+ let percent = passed / count
54+ let color = `rgb(${ Math . floor ( ( 1 - percent ) * 255 ) } ,${ Math . floor ( percent * 255 ) } , 0)`
55+
3856 return (
39- < ListView
40- style = { styles . container }
41- dataSource = { this . ds }
42- renderRow = { this . renderTest . bind ( this ) }
43- renderScrollComponent = { props => < RecyclerViewBackedScrollView { ...props } /> }
44- renderSectionHeader = { ( data , id ) => {
45- return (
46- < View style = { styles . sectionHeader } >
47- < Text style = { styles . sectionText } > { id } </ Text >
48- </ View >
49- )
50- } }
51- /> )
57+ < View style = { { flex : 1 } } >
58+ < View style = { { margin : 20 } } onLayout = { ( e ) => {
59+ this . setState ( {
60+ headerHeight : e . nativeEvent . layout . height ,
61+ listHeight : Dimensions . get ( 'window' ) . height - e . nativeEvent . layout . height
62+ } )
63+ } } >
64+ < Text > { `${ executed } tests executed` } </ Text >
65+ < Text > { `${ passed } test cases passed` } </ Text >
66+ < Text > { `${ count } test cases` } </ Text >
67+ < Text style = { { color, fontSize : 120 , textAlign : 'center' } } > { `${ Math . floor ( percent * 100 ) } ` } </ Text >
68+ < Text style = { { color, fontSize : 30 , textAlign :'right' , marginTop : - 54 , marginRight : 40 , backgroundColor : 'transparent' } } > { `%` } </ Text >
69+ </ View >
70+ < ListView
71+ style = { [ styles . container ] }
72+ dataSource = { this . ds }
73+ renderRow = { this . renderTest . bind ( this ) }
74+ renderScrollComponent = { props => < RecyclerViewBackedScrollView { ...props } /> }
75+ renderSectionHeader = { ( data , id ) => {
76+ return (
77+ < View style = { styles . sectionHeader } >
78+ < Text style = { styles . sectionText } > { id } </ Text >
79+ </ View >
80+ )
81+ } }
82+ />
83+ </ View > )
5284 }
5385
5486 renderTest ( t , group ) {
@@ -57,23 +89,6 @@ export default class Reporter extends Component {
5789 let foundActions = false
5890 let tests = RNTEST . TestContext . getTests ( )
5991
60- if ( group === 'summary' )
61- {
62- let passed = 0
63- let executed = 0
64- let count = 0
65- for ( let i in tests ) {
66- count ++
67- if ( tests [ i ] . executed )
68- passed += tests [ i ] . status === 'pass' ? 1 : 0
69- }
70- return ( < View style = { { flex : 1 } } >
71- < Text > { `${ count } test cases` } </ Text >
72- < Text > { `${ executed } tests executed` } </ Text >
73- < Text > { `${ ParseFloat ( pass / count ) . toFixed ( 2 ) } % tests passed` } </ Text >
74- </ View > )
75- }
76-
7792 if ( Array . isArray ( t . result ) && ! t . expired ) {
7893 t . result = t . result . map ( ( r ) => {
7994 if ( r . type . name === 'Assert' || r . type . name === 'Info' ) {
@@ -94,9 +109,9 @@ export default class Reporter extends Component {
94109 t . status = 'waiting'
95110
96111 return (
97- < TouchableOpacity onPress = { ( ) => {
98- t . start ( t . sn )
99- } } >
112+ // <TouchableOpacity onPress={()=>{
113+ // t.start(t.sn)
114+ // }}>
100115 < View key = { 'rn-test-' + t . desc } style = { {
101116 borderBottomWidth : 1.5 ,
102117 borderColor : '#DDD' ,
@@ -111,8 +126,8 @@ export default class Reporter extends Component {
111126 < View key = { t . desc + '-result' } style = { { backgroundColor : '#F4F4F4' } } >
112127 { t . expand ? t . result : ( t . status === 'pass' ? null : t . result ) }
113128 </ View >
114- </ View >
115- </ TouchableOpacity > )
129+ </ View > )
130+ { /* </TouchableOpacity>)*/ }
116131 }
117132
118133 updateDataSource ( ) {
0 commit comments