!******************************************************************************!
! test_widget_wrapper: Opens a JSETUP panel to test DR 2309 and DR 2310, which
! provides the user with additional qualifying information about the two messages
! sent from a comboBox selection (DESELECT/SELECT) (DR 2309).  For DR 2301,
! tests that a comboBox selection can be triggered without sending any messages.
! Arguments: None
!
!
! @bug      2309  WidgetWrapper: Need ability to block messages
! @bug      2310  PANEL/JSETUP: WidgetWrapper needs to qualify selects
! @author:  Chris Simons
! @version: $Id: test_widget_wrapper.mm,v 1.2 2011/01/28 15:38:43 crs 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
    set instructionsCase1 "Click the Invoke with Message button. &
                        You should see two messages, one with a qualifier of &
                        SELECTED and a second message with a qualifier of &
                        DESELECTED. The ComboBox should toggle between AAAA &
                        and BBBB."
    set instructionsCase2 "Click the Invoke without a Message &
                        button.  You should not see any messages, but the &
                        ComboBox should toggle between AAAA and BBBB."
    pipe on
      panel/msgid=MAIN/setup/controls=gc/jsetup=nxm.sys.test.test_widget_wrapper

      gcontrol label macro "Test MACRO"
      gcontrol menu  main "Exit with Status =" "PASS,FAIL" TABLE={ItemColors={PASS="GREEN",FAIL="RED"}} /tleft

      gcontrol text idtext "Instructions" "^instructionsCase1" 24 24 /title
      gcontrol text idtext2 "Instructions" "^instructionsCase2" 24 24 /title

      ! TODO: The JTextArea is not getting set when using the initial instruction value.
      set gc.idtext.value "^instructionsCase1"
      set gc.idtext2.value "^instructionsCase2"

      msglog/msgid=MAIN
    pipe off


  endif

endmacro

!****************************************************************************!
! process messages for this interactive test
!****************************************************************************!
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 "invokeWithMessage" then
    ! change value of MSGCOMBO1 and send messages
    if gc.MSGCOMBO1.val eqs "AAAA" then
      INFO "You should see two stateChange messages after this line."
      invoke gc.MSGCOMBO1.setValue("BBBB", true)
    else
      INFO "You should see two stateChange messages after this line."
      invoke gc.MSGCOMBO1.setValue("AAAA", true)
    endif

  elseif msg.name eqs "invokeWithoutMessage" then
    ! change value of MSGCOMBO1 and do not send messages
    if gc.MSGCOMBO1.val eqs "AAAA" then
      WARN "You should not see a stateChange message after this line."
      invoke gc.MSGCOMBO1.setValue("BBBB", false)
    else
      WARN "You should not see a stateChange message after this line."
      invoke gc.MSGCOMBO1.setValue("AAAA", false)
    endif

  elseif msg.name eqs "MSGCOMBO1" then
    ! Print stateChange values.
    SEDIT ^msg.quals stateQual KEY "stateChange"
    INFO "stateChange Qualifier is ^stateQual"

  elseif msg.name eqs "MSGCOMBO1" then
    ! Message should not be thrown, so the following WARN should never appear
    WARN "A message was thrown from Invoke Without a Message.  Test fails."

  elseif msg.name eqs "WINDOW" then
    ! Close macro
    pipe stop
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return