!
! Test case for a bad .mmp file.
!
! Author:  J. Czechowski IV
!
startmacro s:setup["good"]
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  call setDatDir

  set t:tests {}
  !------------------------------------------------------------
  set t:tests.good              {}
  set s:tests.good.instructions "Should see a plot of a penny on the top and a line &
                                 plot below it."
  set z:tests.good.popup        ""
  set s:tests.good.wpos         ""
  !------------------------------------------------------------
  set t:tests.bad               {}
  set s:tests.bad.instructions  "Should see a panel with the default layout and the two &
                                 plots outside of the panel. A warning about an 'Error &
                                 loading setup file...' should be printed in the &
                                 terminal. You may need to drag the column to the right &
                                 of these instructions in order to see PASS/FAIL buttons."
  set z:tests.bad.popup         "This next test tests handling of a case where the setup for &
                                 the panel is bad."
  set s:tests.bad.wpos          "(40,40)"
  set s:tests.bad.info          "Expect to see a warning about a Malformed Table and an &
                                 Error loading setup from mmp file"
  !------------------------------------------------------------
  set t:tests.off               {}
  set s:tests.off.instructions  "You should see the entire macro gui on the bottom &
                                 right corner of your screen(s)."
  set z:tests.off.popup         ""
  set s:tests.off.wpos          ""
  !------------------------------------------------------------
  set t:tests.big               {}
  set s:tests.big.instructions  "The macro gui should take up your entire screen(s)."
  set z:tests.big.popup         ""
  set s:tests.big.wpos          ""
  !------------------------------------------------------------



  if interAct then
    set test tests.^{setup}
    if setup EQS "bad" then
      info ^{test.info}
    endif

    if test.popup neqs "" then
      popup/blocking="Mouse|Macro" ,, OK "^reg.main.name: ^test.popup" WARN
    endif
  
    pipe on
      if test.wpos eqs "" then
        panel/setup=^{setup}/controls=gc
      else
        panel/setup=^{setup}/controls=gc/wpos=^{test.wpos}
      endif
 
      plot/id=fft  ^{datDir}.fftdemo.prm
      plot/id=cent ^{datDir}.apenny.prm
 
      gcontrol label macro "MACRO"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}
      gcontrol text idtext "Instructions" "^test.instructions" 24 20 /title
    pipe off
  endif
endmacro

!******************************************************************************!
procedure processMessage m:msg
  !say "msg.name ^msg.name, data ^msg.data"

  if msg.name eqs "MAIN" then
    assert/text="Panel files tests" msg.data eqss "PASS"
    pipe stop
  else
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! Set the dat directory
!******************************************************************************!
procedure setDatDir
  invoke nxmMajor env.nmversion.subString(0,1)
  invoke major java.lang.Integer.valueOf(nxmMajor)
  if major GE 4 then
    invoke s:datDir           nxm.sys.test.DatLocator.getDatDirLocation()
    invoke s:datDirSlash      nxm.sys.test.DatLocator.getDatDirSlashLocation()
    invoke z:sysDatFull       nxm.sys.test.DatLocator.sysDatFull()
    invoke z:sysTestDatExists nxm.sys.test.DatLocator.sysTestDatExists()
  else
    set s:datDir           "nxm.sys.dat"
    set s:datDirSlash      "nxm/sys/dat"
    set z:sysDatFull       true
    set z:sysTestDatExists false
  endif
return
