Code example for ToggleButton

Methods: getVisibility, isChecked, isClickable, isEnabled, isFocusable, performClick

0
  { 
    toggleSSL(true); 
 
    // check the toggle is visible, checked, enabled and focusable.. 
 
    assertTrue(sslToggle.getVisibility() == View.VISIBLE);
 
    assertTrue(sslToggle.isChecked());
    assertTrue(sslToggle.isClickable());
    assertTrue(sslToggle.isEnabled());
    assertTrue(sslToggle.isFocusable());
 
    // check the port edit field is visible, enabled, focusable in all modes... 
     
    assertTrue(sslEditField.getVisibility() == View.VISIBLE);
    assertTrue(sslEditField.isEnabled());
    assertTrue(sslEditField.isFocusable());
    assertTrue(sslEditField.isFocusableInTouchMode());
 
 
    // click toggle... 
 
    sslToggle.performClick();
 
    // check the toggle is unchecked, but still visible, enabled and focusable.. 
 
    assertTrue(sslToggle.getVisibility() == View.VISIBLE);
 
    assertTrue(!sslToggle.isChecked());
    assertTrue(sslToggle.isClickable());
    assertTrue(sslToggle.isEnabled());
    assertTrue(sslToggle.isFocusable());
 
 
    // check the port edit field is visible, disabled, and not focusable in all modes... 
 
    assertTrue(sslEditField.getVisibility() == View.VISIBLE);