@@ -184,8 +184,6 @@ const noop = () => {
184
184
// no operation
185
185
} ;
186
186
187
- // TODO: Order tests!
188
-
189
187
function test < U extends { root : View } > ( ui : ( ) => U , setup : ( ui : U ) => void , test : ( ui : U ) => void ) : ( ) => void {
190
188
return ( ) => {
191
189
let i = ui ( ) ;
@@ -1607,6 +1605,72 @@ export const testFlexBasisPercent_nowrap_flexDirection_column = test(
1607
1605
}
1608
1606
) ;
1609
1607
1608
+ let activity_order_test = ( ) => getViews (
1609
+ `<FlexboxLayout id="flexbox" width="360" height="300" backgroundColor="gray">
1610
+ <Label id="text1" order="2" width="160" height="120" text="1" backgroundColor="red" />
1611
+ <Label id="text2" order="3" width="160" height="120" text="2" backgroundColor="green" />
1612
+ <Label id="text3" order="1" width="160" height="120" text="3" backgroundColor="blue" />
1613
+ </FlexboxLayout>`
1614
+ ) ;
1615
+
1616
+ export const testOrder = test (
1617
+ activity_order_test ,
1618
+ noop ,
1619
+ ( { root, flexbox, text1, text2, text3} ) => {
1620
+ equal ( FlexboxLayout . getOrder ( text1 ) , 2 ) ;
1621
+ equal ( FlexboxLayout . getOrder ( text2 ) , 3 ) ;
1622
+ equal ( FlexboxLayout . getOrder ( text3 ) , 1 ) ;
1623
+ }
1624
+ ) ;
1625
+
1626
+ let activity_order_set_runtime_test = ( ) => getViews (
1627
+ `<FlexboxLayout id="flexbox" width="360" height="300" backgroundColor="gray">
1628
+ <Label id="text1" width="160" height="120" text="1" backgroundColor="red" />
1629
+ <Label id="text2" width="160" height="120" text="2" backgroundColor="green" />
1630
+ <Label id="text3" width="160" height="120" text="3" backgroundColor="blue" />
1631
+ </FlexboxLayout>`
1632
+ ) ;
1633
+
1634
+ export const testOrder_set_runtime = test (
1635
+ activity_order_set_runtime_test ,
1636
+ ( { flexbox, text1, text2, text3} ) => {
1637
+ FlexboxLayout . setOrder ( text1 , 3 ) ;
1638
+ FlexboxLayout . setOrder ( text2 , 1 ) ;
1639
+ FlexboxLayout . setOrder ( text3 , 2 ) ;
1640
+ } ,
1641
+ ( { root, flexbox, text1, text2, text3} ) => {
1642
+ equal ( FlexboxLayout . getOrder ( text1 ) , 3 ) ;
1643
+ equal ( FlexboxLayout . getOrder ( text2 ) , 1 ) ;
1644
+ equal ( FlexboxLayout . getOrder ( text3 ) , 2 ) ;
1645
+ }
1646
+ ) ;
1647
+
1648
+ export const testOrder_changed_runtime = test (
1649
+ activity_order_set_runtime_test ,
1650
+ ( { flexbox, text1, text2, text3} ) => {
1651
+ FlexboxLayout . setOrder ( text1 , 3 ) ;
1652
+ FlexboxLayout . setOrder ( text2 , 1 ) ;
1653
+ FlexboxLayout . setOrder ( text3 , 2 ) ;
1654
+
1655
+ helper . buildUIAndRunTest ( flexbox , ( ) => {
1656
+ waitUntilTestElementLayoutIsValid ( flexbox ) ;
1657
+ FlexboxLayout . setOrder ( text1 , 1 ) ;
1658
+ FlexboxLayout . setOrder ( text2 , 2 ) ;
1659
+ FlexboxLayout . setOrder ( text3 , 3 ) ;
1660
+ } ) ;
1661
+ } ,
1662
+ ( { root, flexbox, text1, text2, text3} ) => {
1663
+ equal ( FlexboxLayout . getOrder ( text1 ) , 1 ) ;
1664
+ equal ( FlexboxLayout . getOrder ( text2 ) , 2 ) ;
1665
+ equal ( FlexboxLayout . getOrder ( text3 ) , 3 ) ;
1666
+
1667
+ // verify views are visually displayed at the right position, not only that their order property is correct.
1668
+ equal ( text1 , flexbox . getChildAt ( 0 ) ) ;
1669
+ equal ( text2 , flexbox . getChildAt ( 1 ) ) ;
1670
+ equal ( text3 , flexbox . getChildAt ( 2 ) ) ;
1671
+ }
1672
+ ) ;
1673
+
1610
1674
let activity_minwidth_test = ( ) => getViews (
1611
1675
`<FlexboxLayout id="flexbox" width="400" height="400" backgroundColor="gray">
1612
1676
<Label id="text1" horizontalAlignment="left" verticalAlignment="top" text="1" minWidth="100" backgroundColor="red" />
0 commit comments