Changeset 1239

Show
Ignore:
Timestamp:
10/23/08 10:54:29 (3 months ago)
Author:
ojohner
Message:

Add units test for radio buton

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/camptocamp/MapFishAeai/client/mfbase/mapfish/tests/widgets/tree/test_LayerTree.html

    r917 r1239  
    214214                {text: "label-0-2", attr_checked: false} 
    215215            ]; 
     216            checkStatus(t, tree, expectedStatus); // 29 tests 
     217 
     218            reset(); 
     219        } 
     220 
     221        function test_RadioButton(t){ 
     222            t.plan(2 * 29); 
     223 
     224            var map = createMap(); 
     225 
     226            var model = [ 
     227                {text: "label-0", expanded: true, children: [ 
     228                    {text: "label-0-0", checked: true, radio: true, radioGrp: "group-0", layerName:"C2C Objects:parkings"}, 
     229                    {text: "label-0-1", checked: false, radio: true, radioGrp: "group-0", layerName:"C2C Objects:summits"}, 
     230                    {text: "label-0-2", checked: false, radio: true, radioGrp: "group-0", layerName:"World Map"} 
     231                ]}, 
     232                {text: "label-1", expanded: true, children: [ 
     233                    {text: "label-1-0", checked: true, radio: true, radioGrp: "group-1", layerName:"C2C Objects:refuges"}, 
     234                    {text: "label-1-1", checked: false, radio: true, radioGrp: "group-1", layerName:"C2C Objects:sites"}, 
     235                ]}, 
     236            ]; 
     237            c2cwmsLayers = ['parkings', 'summits', 'refuges', 'sites']; 
     238            c2cwms = new OpenLayers.Layer.WMS("C2C Objects", 
     239                "http://demo.mapfish.org/mapfishsample/trunk/wms?", 
     240                { 
     241                   singleTile: true, 
     242                   layers: c2cwmsLayers, 
     243                   format: 'image/png', 
     244                   transparent: true 
     245                } 
     246            ); 
     247            c2cwms.setVisibility(false); 
     248            map.addLayer(c2cwms); 
     249 
     250            var twms = new OpenLayers.Layer.WMS("World Map", 
     251                "http://world.freemap.in/cgi-bin/mapserv?", 
     252                { 
     253                    map: '/www/freemap.in/world/map/factbooktrans.map', 
     254                    transparent: true, 
     255                    layers: 'factbook', 
     256                    format: 'image/png' 
     257                } 
     258            ); 
     259 
     260            twms.setVisibility(false); 
     261            map.addLayer(twms); 
     262 
     263            var tree = createTree(map, model); 
     264            var expectedStatus, node; 
     265 
     266            expectedStatus = [ 
     267                {text: "Root"}, 
     268                {text: "label-0"}, 
     269                {text: "label-0-0", attr_checked: true, radio: true, attr_radio:true, attr_radioGrp: "group-0"}, 
     270                {text: "label-0-1", attr_checked: false, radio: true, attr_radio:true, attr_radioGrp: "group-0"}, 
     271                {text: "label-0-2", attr_checked: false, radio: true, attr_radio:true, attr_radioGrp: "group-0"}, 
     272                {text: "label-1"}, 
     273                {text: "label-1-0", attr_checked: true, radio: true, attr_radio:true, attr_radioGrp: "group-1"}, 
     274                {text: "label-1-1", attr_checked: false, radio: true, attr_radio:true, attr_radioGrp: "group-1"}, 
     275            ]; 
     276 
     277            checkStatus(t, tree, expectedStatus); // 29 tests 
     278 
     279            // Check 2 radio buttons in 2 different radio grp 
     280 
     281            node = getNodeByText(tree.getRootNode(), "label-0-2"); 
     282            tree.setNodeChecked(node, true); 
     283 
     284            node = getNodeByText(tree.getRootNode(), "label-1-1"); 
     285            tree.setNodeChecked(node, true); 
     286 
     287            expectedStatus = [ 
     288                {text: "Root"}, 
     289                {text: "label-0"}, 
     290                {text: "label-0-0", attr_checked: false, radio: true, attr_radio:true, attr_radioGrp: "group-0"}, 
     291                {text: "label-0-1", attr_checked: false, radio: true, attr_radio:true, attr_radioGrp: "group-0"}, 
     292                {text: "label-0-2", attr_checked: true, radio: true, attr_radio:true, attr_radioGrp: "group-0"}, 
     293                {text: "label-1"}, 
     294                {text: "label-1-0", attr_checked: false, radio: true, attr_radio:true, attr_radioGrp: "group-1"}, 
     295                {text: "label-1-1", attr_checked: true, radio: true, attr_radio:true, attr_radioGrp: "group-1"}, 
     296            ]; 
     297 
    216298            checkStatus(t, tree, expectedStatus); // 29 tests 
    217299