! This tests the msglab2 macro for the Macro Messages Lab 2
!
! Author:  Neon Ngo
! Version: $Id: test_msglab2.mm,v 1.1 2007/07/24 22:51:29 ntn Exp $
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  if interAct then
    res inst "Should see a map of the world. Click somewhere inside map. The map should zoom 50% &
              into the spot where you clicked. A message with name=MARK and data=PosLonLatAlt &
              should be displayed in the Message Output."

    pipe on
      panel/msgid=MAIN/setup/controls=gc
      !panel/msgid=MAIN/setup/controls=gc
      gcontrol text idtext "Instructions" "^inst" 24 9 /title
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}

      msglab2/id=msglab2/bg

      shellgui/attach
    pipe off
  endif
endmacro

procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: Tests for MSGLAB2" msg.data eqss "PASS"

    ! Check for running msglab1 macro
    assert/text="^reg.main.name: REG.MSGLAB2 found" REG.msglab2 rexists

    ! Stop the macro
    set reg.msglab2.state FINISH
    pause 1

    ! Did the macro stop?
    assert/text="^reg.main.name: REG.MSGLAB2 removed" REG.msglab2 nrexists

    pipe stop
  else
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return
