1*b9b79128SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b9b79128SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b9b79128SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b9b79128SAndrew Rist * distributed with this work for additional information 6*b9b79128SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b9b79128SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b9b79128SAndrew Rist * "License"); you may not use this file except in compliance 9*b9b79128SAndrew Rist * with the License. You may obtain a copy of the License at 10*b9b79128SAndrew Rist * 11*b9b79128SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b9b79128SAndrew Rist * 13*b9b79128SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b9b79128SAndrew Rist * software distributed under the License is distributed on an 15*b9b79128SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b9b79128SAndrew Rist * KIND, either express or implied. See the License for the 17*b9b79128SAndrew Rist * specific language governing permissions and limitations 18*b9b79128SAndrew Rist * under the License. 19*b9b79128SAndrew Rist * 20*b9b79128SAndrew Rist *************************************************************/ 21*b9b79128SAndrew Rist 22*b9b79128SAndrew Rist 23cdf0e10cSrcweir package integration.forms; 24cdf0e10cSrcweir 25cdf0e10cSrcweir import com.sun.star.uno.*; 26cdf0e10cSrcweir import com.sun.star.util.*; 27cdf0e10cSrcweir import com.sun.star.lang.*; 28cdf0e10cSrcweir import com.sun.star.container.*; 29cdf0e10cSrcweir import com.sun.star.beans.*; 30cdf0e10cSrcweir import com.sun.star.awt.XRadioButton; 31cdf0e10cSrcweir 32cdf0e10cSrcweir import integration.forms.dbfTools; 33cdf0e10cSrcweir import integration.forms.DocumentHelper; 34cdf0e10cSrcweir import integration.forms.SpreadsheetDocument; 35cdf0e10cSrcweir 36cdf0e10cSrcweir import util.utils; 37cdf0e10cSrcweir import java.util.*; 38cdf0e10cSrcweir import java.io.*; 39cdf0e10cSrcweir import java.lang.*; 40cdf0e10cSrcweir 41cdf0e10cSrcweir /** 42cdf0e10cSrcweir * 43cdf0e10cSrcweir * @author fs@openoffice.org 44cdf0e10cSrcweir */ 45cdf0e10cSrcweir public class RadioButtons extends complexlib.ComplexTestCase 46cdf0e10cSrcweir { 47cdf0e10cSrcweir private DocumentHelper m_document; /// our current test document 48cdf0e10cSrcweir private FormLayer m_formLayer; /// quick access to the form layer 49cdf0e10cSrcweir private XMultiServiceFactory m_orb; /// our service factory 50cdf0e10cSrcweir private XPropertySet m_primaryForm; /// the primary form, to be used in text documents and in the first page of spreadsheets 51cdf0e10cSrcweir private XPropertySet m_secondaryForm; /// the secondary form, to be used in the second page of spreadsheets 52cdf0e10cSrcweir 53cdf0e10cSrcweir /* ------------------------------------------------------------------ */ RadioButtons()54cdf0e10cSrcweir public RadioButtons() 55cdf0e10cSrcweir { 56cdf0e10cSrcweir } 57cdf0e10cSrcweir 58cdf0e10cSrcweir /* ------------------------------------------------------------------ */ getTestMethodNames()59cdf0e10cSrcweir public String[] getTestMethodNames() 60cdf0e10cSrcweir { 61cdf0e10cSrcweir return new String[] { 62cdf0e10cSrcweir "checkSingleButtons", 63cdf0e10cSrcweir "checkThreeGroups", 64cdf0e10cSrcweir "checkMultipleForms", 65cdf0e10cSrcweir "checkCalcPageSwitch" 66cdf0e10cSrcweir }; 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir /* ------------------------------------------------------------------ */ getTestObjectName()70cdf0e10cSrcweir public String getTestObjectName() 71cdf0e10cSrcweir { 72cdf0e10cSrcweir return "Form Radio Buttons Test"; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir /* ------------------------------------------------------------------ */ before()76cdf0e10cSrcweir public void before() throws com.sun.star.uno.Exception, java.lang.Exception 77cdf0e10cSrcweir { 78cdf0e10cSrcweir m_orb = (XMultiServiceFactory)param.getMSF(); 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir /* ------------------------------------------------------------------ */ insertRadio( int nXPos, int nYPos, String label, String name, String refValue )82cdf0e10cSrcweir private XPropertySet insertRadio( int nXPos, int nYPos, String label, String name, String refValue ) throws com.sun.star.uno.Exception, java.lang.Exception 83cdf0e10cSrcweir { 84cdf0e10cSrcweir return insertRadio( nXPos, nYPos, label, name, refValue, null ); 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir /* ------------------------------------------------------------------ */ insertRadio( int nXPos, int nYPos, String label, String name, String refValue, XPropertySet parentForm )88cdf0e10cSrcweir private XPropertySet insertRadio( int nXPos, int nYPos, String label, String name, String refValue, XPropertySet parentForm ) throws com.sun.star.uno.Exception, java.lang.Exception 89cdf0e10cSrcweir { 90cdf0e10cSrcweir XIndexContainer parentContainer = dbfTools.queryIndexContainer( parentForm ); 91cdf0e10cSrcweir XPropertySet xRadio = m_formLayer.createControlAndShape( "DatabaseRadioButton", nXPos, nYPos, 25, 6, parentContainer ); 92cdf0e10cSrcweir xRadio.setPropertyValue( "Label", label ); 93cdf0e10cSrcweir xRadio.setPropertyValue( "RefValue", refValue ); 94cdf0e10cSrcweir xRadio.setPropertyValue( "Name", name ); 95cdf0e10cSrcweir 96cdf0e10cSrcweir if ( null == m_primaryForm ) 97cdf0e10cSrcweir m_primaryForm = (XPropertySet)dbfTools.getParent( xRadio, XPropertySet.class ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir return xRadio; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 103cdf0e10cSrcweir /** this checks whether n groups of radio buttons, consisting of only one button each, 104cdf0e10cSrcweir * behave properly 105cdf0e10cSrcweir */ checkSingleButtons()106cdf0e10cSrcweir public void checkSingleButtons() throws com.sun.star.uno.Exception, java.lang.Exception 107cdf0e10cSrcweir { 108cdf0e10cSrcweir prepareTestStep( false ); 109cdf0e10cSrcweir 110cdf0e10cSrcweir insertRadio( 20, 30, "group 1", "group 1", "" ); 111cdf0e10cSrcweir insertRadio( 20, 38, "group 2", "group 2", "" ); 112cdf0e10cSrcweir insertRadio( 20, 46, "group 3", "group 3", "" ); 113cdf0e10cSrcweir insertRadio( 20, 54, "group 4", "group 4", "" ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir // switch to alive mode 116cdf0e10cSrcweir m_document.getCurrentView( ).toggleFormDesignMode( ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir checkRadio( "group 1", "" ); 119cdf0e10cSrcweir verifySingleRadios( 1, 0, 0, 0 ); 120cdf0e10cSrcweir 121cdf0e10cSrcweir checkRadio( "group 4", "" ); 122cdf0e10cSrcweir verifySingleRadios( 1, 0, 0, 1 ); 123cdf0e10cSrcweir 124cdf0e10cSrcweir checkRadio( "group 2", "" ); 125cdf0e10cSrcweir verifySingleRadios( 1, 1, 0, 1 ); 126cdf0e10cSrcweir 127cdf0e10cSrcweir checkRadio( "group 3", "" ); 128cdf0e10cSrcweir verifySingleRadios( 1, 1, 1, 1 ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir cleanupTestStep(); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 134cdf0e10cSrcweir /** creates three groups of radio buttons in a sample document, and checks whether they're working 135cdf0e10cSrcweir */ checkThreeGroups( )136cdf0e10cSrcweir public void checkThreeGroups( ) throws com.sun.star.uno.Exception, java.lang.Exception 137cdf0e10cSrcweir { 138cdf0e10cSrcweir prepareTestStep( false ); 139cdf0e10cSrcweir 140cdf0e10cSrcweir insertRadio( 20, 30, "group 1 (a)", "group 1", "a" ); 141cdf0e10cSrcweir insertRadio( 20, 38, "group 1 (b)", "group 1", "b" ); 142cdf0e10cSrcweir 143cdf0e10cSrcweir insertRadio( 20, 50, "group 2 (a)", "group 2", "a" ); 144cdf0e10cSrcweir insertRadio( 20, 58, "group 2 (b)", "group 2", "b" ); 145cdf0e10cSrcweir 146cdf0e10cSrcweir insertRadio( 20, 70, "group 3 (a)", "group 3", "a" ); 147cdf0e10cSrcweir insertRadio( 20, 78, "group 3 (b)", "group 3", "b" ); 148cdf0e10cSrcweir 149cdf0e10cSrcweir // switch to alive mode 150cdf0e10cSrcweir m_document.getCurrentView( ).toggleFormDesignMode( ); 151cdf0e10cSrcweir 152cdf0e10cSrcweir // initially, after switching to alive mode, all buttons should be unchecked 153cdf0e10cSrcweir verifySixPack( 0, 0, 0, 0, 0, 0 ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir // check one button in every group 156cdf0e10cSrcweir checkRadio( "group 1", "a" ); 157cdf0e10cSrcweir checkRadio( "group 2", "b" ); 158cdf0e10cSrcweir checkRadio( "group 3", "a" ); 159cdf0e10cSrcweir // and verify that this worked 160cdf0e10cSrcweir verifySixPack( 1, 0, 0, 1, 1, 0 ); 161cdf0e10cSrcweir 162cdf0e10cSrcweir // check all buttons which are currently unchecked 163cdf0e10cSrcweir checkRadio( "group 1", "b" ); 164cdf0e10cSrcweir checkRadio( "group 2", "a" ); 165cdf0e10cSrcweir checkRadio( "group 3", "b" ); 166cdf0e10cSrcweir // this should have reset the previous checks in the respective groups 167cdf0e10cSrcweir verifySixPack( 0, 1, 1, 0, 0, 1 ); 168cdf0e10cSrcweir 169cdf0e10cSrcweir // and back to the previous check state 170cdf0e10cSrcweir checkRadio( "group 1", "a" ); 171cdf0e10cSrcweir checkRadio( "group 2", "b" ); 172cdf0e10cSrcweir checkRadio( "group 3", "a" ); 173cdf0e10cSrcweir verifySixPack( 1, 0, 0, 1, 1, 0 ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir cleanupTestStep(); 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 178cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 179cdf0e10cSrcweir /** tests whether radio buttons which belong to different forms behave properly 180cdf0e10cSrcweir */ checkMultipleForms( )181cdf0e10cSrcweir public void checkMultipleForms( ) throws com.sun.star.uno.Exception, java.lang.Exception 182cdf0e10cSrcweir { 183cdf0e10cSrcweir prepareTestStep( false ); 184cdf0e10cSrcweir 185cdf0e10cSrcweir insertRadio( 20, 30, "group 1 (a)", "group 1", "a" ); 186cdf0e10cSrcweir insertRadio( 20, 38, "group 1 (b)", "group 1", "b" ); 187cdf0e10cSrcweir insertRadio( 20, 46, "group 1 (c)", "group 1", "c" ); 188cdf0e10cSrcweir 189cdf0e10cSrcweir m_secondaryForm = dbfTools.queryPropertySet( m_document.createSiblingForm( m_primaryForm, "secondary" ) ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir insertRadio( 70, 30, "group 2 (a)", "group 2", "a", m_secondaryForm ); 192cdf0e10cSrcweir insertRadio( 70, 38, "group 2 (b)", "group 2", "b", m_secondaryForm ); 193cdf0e10cSrcweir insertRadio( 70, 46, "group 2 (c)", "group 2", "c", m_secondaryForm ); 194cdf0e10cSrcweir 195cdf0e10cSrcweir // switch to alive mode 196cdf0e10cSrcweir m_document.getCurrentView( ).toggleFormDesignMode( ); 197cdf0e10cSrcweir 198cdf0e10cSrcweir // play around with different check states 199cdf0e10cSrcweir checkRadio( "group 1", "b", m_primaryForm ); 200cdf0e10cSrcweir checkRadio( "group 2", "c", m_secondaryForm ); 201cdf0e10cSrcweir verifyTwoFormRadios( 0, 1, 0, 0, 0, 1 ); 202cdf0e10cSrcweir 203cdf0e10cSrcweir checkRadio( "group 1", "c", m_primaryForm ); 204cdf0e10cSrcweir verifyTwoFormRadios( 0, 0, 1, 0, 0, 1 ); 205cdf0e10cSrcweir 206cdf0e10cSrcweir checkRadio( "group 2", "a", m_secondaryForm ); 207cdf0e10cSrcweir verifyTwoFormRadios( 0, 0, 1, 1, 0, 0 ); 208cdf0e10cSrcweir 209cdf0e10cSrcweir checkRadio( "group 1", "a", m_primaryForm ); 210cdf0e10cSrcweir verifyTwoFormRadios( 1, 0, 0, 1, 0, 0 ); 211cdf0e10cSrcweir 212cdf0e10cSrcweir checkRadio( "group 2", "b", m_secondaryForm ); 213cdf0e10cSrcweir verifyTwoFormRadios( 1, 0, 0, 0, 1, 0 ); 214cdf0e10cSrcweir 215cdf0e10cSrcweir cleanupTestStep(); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 219cdf0e10cSrcweir /** tests for a special bug which we once had, where radio buttons lost their state after 220cdf0e10cSrcweir * switching spreadsheet pages 221cdf0e10cSrcweir */ checkCalcPageSwitch( )222cdf0e10cSrcweir public void checkCalcPageSwitch( ) throws com.sun.star.uno.Exception, java.lang.Exception 223cdf0e10cSrcweir { 224cdf0e10cSrcweir prepareTestStep( true ); 225cdf0e10cSrcweir 226cdf0e10cSrcweir m_formLayer.setInsertPage( 0 ); 227cdf0e10cSrcweir insertRadio( 15, 20, "group 1 (a)", "group 1", "a" ); 228cdf0e10cSrcweir insertRadio( 15, 26, "group 1 (b)", "group 1", "b" ); 229cdf0e10cSrcweir 230cdf0e10cSrcweir m_formLayer.setInsertPage( 1 ); 231cdf0e10cSrcweir XPropertySet xRadio = insertRadio( 15, 20, "group 2 (a)", "group 2", "a" ); 232cdf0e10cSrcweir insertRadio( 15, 26, "group 2 (b)", "group 2", "b" ); 233cdf0e10cSrcweir m_secondaryForm = (XPropertySet)dbfTools.getParent( xRadio, XPropertySet.class ); 234cdf0e10cSrcweir 235cdf0e10cSrcweir // switch to alive mode 236cdf0e10cSrcweir SpreadsheetView view = (SpreadsheetView)m_document.getCurrentView( ); 237cdf0e10cSrcweir view.toggleFormDesignMode( ); 238cdf0e10cSrcweir // and do initial checking 239cdf0e10cSrcweir checkRadio( "group 1", "a", m_primaryForm ); 240cdf0e10cSrcweir view.activateSheet( 1 ); 241cdf0e10cSrcweir checkRadio( "group 2", "b", m_secondaryForm ); 242cdf0e10cSrcweir 243cdf0e10cSrcweir // see whether the check states on the first page survived the page switch 244cdf0e10cSrcweir verifySheetRadios( 1, 0, 0, 1 ); 245cdf0e10cSrcweir // switch back to the first sheet, and see whether the check states survived 246cdf0e10cSrcweir view.activateSheet( 0 ); 247cdf0e10cSrcweir verifySheetRadios( 1, 0, 0, 1 ); 248cdf0e10cSrcweir // and for completely, check again after switching to third sheet and back to the first 249cdf0e10cSrcweir view.activateSheet( 2 ); 250cdf0e10cSrcweir view.activateSheet( 1 ); 251cdf0e10cSrcweir verifySheetRadios( 1, 0, 0, 1 ); 252cdf0e10cSrcweir 253cdf0e10cSrcweir cleanupTestStep(); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir 256cdf0e10cSrcweir /* ------------------------------------------------------------------ */ after()257cdf0e10cSrcweir public void after() 258cdf0e10cSrcweir { 259cdf0e10cSrcweir closeDocument(); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 263cdf0e10cSrcweir /** closes our document, if we have an open one 264cdf0e10cSrcweir */ closeDocument()265cdf0e10cSrcweir private void closeDocument() 266cdf0e10cSrcweir { 267cdf0e10cSrcweir try 268cdf0e10cSrcweir { 269cdf0e10cSrcweir // close our document 270cdf0e10cSrcweir if ( m_document != null ) 271cdf0e10cSrcweir { 272cdf0e10cSrcweir XCloseable closeDoc = (XCloseable)UnoRuntime.queryInterface( XCloseable.class, 273cdf0e10cSrcweir m_document.getDocument() ); 274cdf0e10cSrcweir closeDoc.close( true ); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir } 277cdf0e10cSrcweir catch ( com.sun.star.uno.Exception e ) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir } 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282cdf0e10cSrcweir /* ------------------------------------------------------------------ */ prepareTestStep( boolean useSpreadsheetDocument )283cdf0e10cSrcweir private void prepareTestStep( boolean useSpreadsheetDocument ) throws com.sun.star.uno.Exception, java.lang.Exception 284cdf0e10cSrcweir { 285cdf0e10cSrcweir m_primaryForm = null; 286cdf0e10cSrcweir 287cdf0e10cSrcweir m_document = useSpreadsheetDocument ? new SpreadsheetDocument( m_orb ) : DocumentHelper.blankTextDocument( m_orb ); 288cdf0e10cSrcweir m_formLayer = new FormLayer( m_document ); 289cdf0e10cSrcweir } 290cdf0e10cSrcweir 291cdf0e10cSrcweir /* ------------------------------------------------------------------ */ cleanupTestStep( )292cdf0e10cSrcweir private void cleanupTestStep( ) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir closeDocument(); 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 298cdf0e10cSrcweir /** checks or unchecks the radio button (in our primary form) with the given name and the given ref value 299cdf0e10cSrcweir */ checkRadio( String groupName, String refValue )300cdf0e10cSrcweir private void checkRadio( String groupName, String refValue ) throws com.sun.star.uno.Exception, java.lang.Exception 301cdf0e10cSrcweir { 302cdf0e10cSrcweir checkRadio( groupName, refValue, m_primaryForm ); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 306cdf0e10cSrcweir /** checks or unchecks the radio button with the given name and the given ref value 307cdf0e10cSrcweir */ checkRadio( String groupName, String refValue, XPropertySet form )308cdf0e10cSrcweir private void checkRadio( String groupName, String refValue, XPropertySet form ) throws com.sun.star.uno.Exception, java.lang.Exception 309cdf0e10cSrcweir { 310cdf0e10cSrcweir XPropertySet xRadio = getRadioModel( groupName, refValue, form ); 311cdf0e10cSrcweir 312cdf0e10cSrcweir XRadioButton radioButton = (XRadioButton)UnoRuntime.queryInterface( 313cdf0e10cSrcweir XRadioButton.class, m_document.getCurrentView().getControl( xRadio ) ); 314cdf0e10cSrcweir radioButton.setState( true ); 315cdf0e10cSrcweir } 316cdf0e10cSrcweir 317cdf0e10cSrcweir /* ------------------------------------------------------------------ */ getRadioModel( String name, String refValue )318cdf0e10cSrcweir private XPropertySet getRadioModel( String name, String refValue ) throws com.sun.star.uno.Exception, java.lang.Exception 319cdf0e10cSrcweir { 320cdf0e10cSrcweir return getRadioModel( name, refValue, m_primaryForm ); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir 323cdf0e10cSrcweir /* ------------------------------------------------------------------ */ getRadioModel( String name, String refValue, XPropertySet form )324cdf0e10cSrcweir private XPropertySet getRadioModel( String name, String refValue, XPropertySet form ) throws com.sun.star.uno.Exception, java.lang.Exception 325cdf0e10cSrcweir { 326cdf0e10cSrcweir return m_formLayer.getRadioModelByRefValue( form, name, refValue ); 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir /* ------------------------------------------------------------------ */ stateString( short[] states )330cdf0e10cSrcweir private String stateString( short[] states ) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir StringBuffer buf = new StringBuffer(); 333cdf0e10cSrcweir for ( int i=0; i<states.length; ++i ) 334cdf0e10cSrcweir buf.append( states[i] ); 335cdf0e10cSrcweir return buf.toString(); 336cdf0e10cSrcweir } 337cdf0e10cSrcweir 338cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 339cdf0e10cSrcweir /** verifies a number of radio buttons for their states 340cdf0e10cSrcweir */ verifyRadios( XPropertySet[] radios, short[] expectedStates, String errorMessage )341cdf0e10cSrcweir private boolean verifyRadios( XPropertySet[] radios, short[] expectedStates, String errorMessage ) throws com.sun.star.uno.Exception 342cdf0e10cSrcweir { 343cdf0e10cSrcweir short[] actualStates = new short[radios.length]; 344cdf0e10cSrcweir 345cdf0e10cSrcweir // collect all current states. This is just to be able to emit them, in case of a failure 346cdf0e10cSrcweir for ( int i = 0; i<radios.length; ++i ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir actualStates[i] = ((Short)radios[i].getPropertyValue( "State" )).shortValue(); 349cdf0e10cSrcweir } 350cdf0e10cSrcweir 351cdf0e10cSrcweir // now actually check the states 352cdf0e10cSrcweir for ( int i = 0; i<radios.length; ++i ) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir if ( actualStates[i] != expectedStates[i] ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir failed( errorMessage + " (expected: " + stateString( expectedStates ) + ", found: " + stateString( actualStates ) + ")" ); 357cdf0e10cSrcweir return false; 358cdf0e10cSrcweir } 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir return true; 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 365cdf0e10cSrcweir /** verifies the states of the 4 radio buttons from the checkSingleButtons test 366cdf0e10cSrcweir */ verifySingleRadios( int state1, int state2, int state3, int state4 )367cdf0e10cSrcweir private boolean verifySingleRadios( int state1, int state2, int state3, int state4 ) throws com.sun.star.uno.Exception, java.lang.Exception 368cdf0e10cSrcweir { 369cdf0e10cSrcweir XPropertySet[] radios = new XPropertySet[4]; 370cdf0e10cSrcweir radios[0] = getRadioModel( "group 1", "" ); 371cdf0e10cSrcweir radios[1] = getRadioModel( "group 2", "" ); 372cdf0e10cSrcweir radios[2] = getRadioModel( "group 3", "" ); 373cdf0e10cSrcweir radios[3] = getRadioModel( "group 4", "" ); 374cdf0e10cSrcweir 375cdf0e10cSrcweir short[] states = new short[4]; 376cdf0e10cSrcweir states[0] = (short)state1; 377cdf0e10cSrcweir states[1] = (short)state2; 378cdf0e10cSrcweir states[2] = (short)state3; 379cdf0e10cSrcweir states[3] = (short)state4; 380cdf0e10cSrcweir 381cdf0e10cSrcweir return verifyRadios( radios, states, "single-group radio buttons do not work!" ); 382cdf0e10cSrcweir } 383cdf0e10cSrcweir 384cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 385cdf0e10cSrcweir /** verifies the states of 6 radio buttons form the checkThreeGroups test 386cdf0e10cSrcweir */ verifySixPack( XPropertySet[] radios, String errorMessage, int state1, int state2, int state3, int state4, int state5, int state6 )387cdf0e10cSrcweir private boolean verifySixPack( XPropertySet[] radios, String errorMessage, 388cdf0e10cSrcweir int state1, int state2, int state3, int state4, int state5, int state6 ) throws com.sun.star.uno.Exception, java.lang.Exception 389cdf0e10cSrcweir { 390cdf0e10cSrcweir short[] states = new short[6]; 391cdf0e10cSrcweir states[0] = (short)state1; 392cdf0e10cSrcweir states[1] = (short)state2; 393cdf0e10cSrcweir states[2] = (short)state3; 394cdf0e10cSrcweir states[3] = (short)state4; 395cdf0e10cSrcweir states[4] = (short)state5; 396cdf0e10cSrcweir states[5] = (short)state6; 397cdf0e10cSrcweir 398cdf0e10cSrcweir return verifyRadios( radios, states, errorMessage ); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 402cdf0e10cSrcweir /** verifies the states of 6 radio buttons 403cdf0e10cSrcweir */ verifySixPack( int state1, int state2, int state3, int state4, int state5, int state6 )404cdf0e10cSrcweir private boolean verifySixPack( int state1, int state2, int state3, int state4, int state5, int state6 ) throws com.sun.star.uno.Exception, java.lang.Exception 405cdf0e10cSrcweir { 406cdf0e10cSrcweir XPropertySet[] radios = new XPropertySet[6]; 407cdf0e10cSrcweir radios[0] = getRadioModel( "group 1", "a" ); 408cdf0e10cSrcweir radios[1] = getRadioModel( "group 1", "b" ); 409cdf0e10cSrcweir radios[2] = getRadioModel( "group 2", "a" ); 410cdf0e10cSrcweir radios[3] = getRadioModel( "group 2", "b" ); 411cdf0e10cSrcweir radios[4] = getRadioModel( "group 3", "a" ); 412cdf0e10cSrcweir radios[5] = getRadioModel( "group 3", "b" ); 413cdf0e10cSrcweir 414cdf0e10cSrcweir return verifySixPack( radios, "six radio buttons, forming three different groups, do not properly work!", 415cdf0e10cSrcweir state1, state2, state3, state4, state5, state6 ); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 419cdf0e10cSrcweir /** verifies the states of the 6 radio buttons in our checkMultipleForms test 420cdf0e10cSrcweir */ verifyTwoFormRadios( int state1, int state2, int state3, int state4, int state5, int state6 )421cdf0e10cSrcweir private boolean verifyTwoFormRadios( int state1, int state2, int state3, int state4, int state5, int state6 ) throws com.sun.star.uno.Exception, java.lang.Exception 422cdf0e10cSrcweir { 423cdf0e10cSrcweir XPropertySet[] radios = new XPropertySet[6]; 424cdf0e10cSrcweir radios[0] = getRadioModel( "group 1", "a", m_primaryForm ); 425cdf0e10cSrcweir radios[1] = getRadioModel( "group 1", "b", m_primaryForm ); 426cdf0e10cSrcweir radios[2] = getRadioModel( "group 1", "c", m_primaryForm ); 427cdf0e10cSrcweir radios[3] = getRadioModel( "group 2", "a", m_secondaryForm ); 428cdf0e10cSrcweir radios[4] = getRadioModel( "group 2", "b", m_secondaryForm ); 429cdf0e10cSrcweir radios[5] = getRadioModel( "group 2", "c", m_secondaryForm ); 430cdf0e10cSrcweir 431cdf0e10cSrcweir return verifySixPack( radios, "radio buttons on different forms do not work properly!", 432cdf0e10cSrcweir state1, state2, state3, state4, state5, state6 ); 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 435cdf0e10cSrcweir /* ------------------------------------------------------------------ */ 436cdf0e10cSrcweir /** verifies the states of the 4 radio buttons in our spreadsheet document (checkCalcPageSwitch) 437cdf0e10cSrcweir */ verifySheetRadios( int state1, int state2, int state3, int state4 )438cdf0e10cSrcweir private boolean verifySheetRadios( int state1, int state2, int state3, int state4 ) throws com.sun.star.uno.Exception, java.lang.Exception 439cdf0e10cSrcweir { 440cdf0e10cSrcweir XPropertySet[] radios = new XPropertySet[4]; 441cdf0e10cSrcweir radios[0] = getRadioModel( "group 1", "a", m_primaryForm ); 442cdf0e10cSrcweir radios[1] = getRadioModel( "group 1", "b", m_primaryForm ); 443cdf0e10cSrcweir radios[2] = getRadioModel( "group 2", "a", m_secondaryForm ); 444cdf0e10cSrcweir radios[3] = getRadioModel( "group 2", "b", m_secondaryForm ); 445cdf0e10cSrcweir 446cdf0e10cSrcweir short[] states = new short[4]; 447cdf0e10cSrcweir states[0] = (short)state1; 448cdf0e10cSrcweir states[1] = (short)state2; 449cdf0e10cSrcweir states[2] = (short)state3; 450cdf0e10cSrcweir states[3] = (short)state4; 451cdf0e10cSrcweir 452cdf0e10cSrcweir return verifyRadios( radios, states, "seems some of the radio button check states didn't survive the page activation(s)!" ); 453cdf0e10cSrcweir } 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456