!******************************************************************************!
! test_gcontrol_swinglabel: An interactive test case designed to allow the user
! to test the GSwingLabel UCL/libg class, which can be used via the BEAN widget.
!
! Arguments: None
!
! @bug      2351  Add a "BEAN" widget class
! @author:  Chris Simons
! @version: $Id: test_gcontrol_swinglabel.mm,v 1.3 2012/10/08 20:23:46 ntn Exp $
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE  ! for defects or more obscure test case(s)

  ! Start Interactive test section
  if interAct then
    pipe init
      panel/msgid=MAIN/id=panel/setup/controls=gc

      set text "<html><body>Here is my <font color=white>pure</font>-<font color=#00ff00>Swing</font> <b>JLabel</b> control</body></html>"
      set instructions "You should see a pure-Swing JLabel with the text value of &
                        'Here is my pure-Swing JLabel control' with 'pure' in white, &
                        'Swing' in green, and 'JLabel' in bold."

      gcontrol label macro "Test MACRO"
      gcontrol menu  main "Exit with Status =" "PASS,FAIL" TABLE={ItemColors={PASS="GREEN",FAIL="RED"}} /tleft
      gcontrol text idtext "Instructions" instructions 24 7 /title

      gcontrol bean swingLabel1 "myJLabel" P1=nxm.ucl.libg.GSwingLabel TABLE={LabelText="^text"}
      gcontrol button mybtn "change label value" "OrigValue,NewValue" "OrigValue"

    pipe off
  endif

endmacro

!******************************************************************************!
! process messages for interactive tests
!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.name eqs "MYBTN" then
    if msg.data eqs "ORIGVALUE" then
      set gc.swingLabel1.value text
    elseif msg.data eqs "NEWVALUE" then
      set gc.swingLabel1.value "<html><body>This is the new <font color=#FFD700>golden</font> <i>value in italics</i>.</body></html>"
    endif
  else
    say "Unhandled Message: ^msg.name, ^msg.data"
  endif
return


!******************************************************************************!
! If an unexpected exception is caught, mark test as failed, unless it is expected
!******************************************************************************!
procedure processException m:emsg
  if expectedException REXISTS then
    assert/text="^reg.main.name: Expected ERROR starts with: ^{expectedException}" expectedException EQSS emsg.data.message
    remove expectedException
  else
    assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
    if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
  endif
return
