!******************************************************************************!
! Test that the plot renders correctly when resizing the plot and panning
!
! @bug      NXM-3413 Map maintains margins and moves Y axis on Lat/Lon and Lat/Lon Continuous views
! @since    3.9.2
! @author:  Kevin Esterheld
!******************************************************************************!
startmacro
  switch INTERACTIVE  interAct     GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch COREGRAPHICS coreGraphics GET DEF=FALSE SDEF=TRUE  ! for a quick check of graphics - more extreme tests

  if interAct or coreGraphics then
    set instructions "Click 'START TEST' to begin the automatic test \n\n&
                      If the plot is centered and looks good, pass the test."

    env set KEYMAP {PLOT={LEFT="L",RIGHT="R",in=i,down=d,up=u,out=o}}
    pipe on
      panel/msgid=MAIN/setup/controls=gc
      plot/id=plot1 world.shp view=latloncontinuous
      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 8 /title
      gcontrol Button boxtest "" "START TEST" ""
    pipe off
  endif
endmacro

!******************************************************************************!
! Main process message for this macro. Should be right after the ENDMACRO.
!******************************************************************************!
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 "BOXTEST" then
    invoke ,, nxm.sys.test.TestPlotZoomPixelSlamTop.shiftRight(reg, "PLOT1", "RIGHT", 10)
    invoke originalBox nxm.sys.test.TestPlotZoomPixelSlamTop.adjustFrameSize(reg, "{w=400,h=200}", "plot1")
    invoke ,, nxm.sys.test.TestPlotZoomPixelSlamTop.adjustFrameSize(reg, "{w=800,h=200}", "plot1")
    invoke ,, nxm.sys.test.TestPlotZoomPixelSlamTop.shiftRight(reg, "PLOT1", "LEFT", 10)
    invoke ,, nxm.sys.test.TestPlotZoomPixelSlamTop.adjustFrameSize(reg, originalBox, "plot1")
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^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
