! This tests the graphicslab1 macro for the Macro Graphics Lab 1
!
! Author:  Neon Ngo
! Version: $Id: test_graphicslab1.mm,v 1.2 2008/02/18 23:16:01 ntn Exp $
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  if interAct then
    res inst "Click on calendar and a message with should be displayed in the Message Output and &
              the year, month, and day widgets should match the date selected. Update year, month, &
              and day widgets and the calendar should match them. Finally, click the stop button &
              and the macro should close."

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

      graphicslab1/id=lab/bg

      shellgui/attach
    pipe off
  endif
endmacro

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

    ! Check for running lab macro
    if REG.LAB rexists then
      ! Stop the macro
      set reg.lab.state FINISH
      pause 1

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

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