!******************************************************************************!
! This test will test the FLAGS for GOTOLOCATION on the PLOT primitive. This 
! corresponds with NXM-2890 and tests for the inputs to be non case sensitive.
!
! Arguments: None
!
!
! @bug      NXM-2890 MarkLocation and Zoom in FLAGS for GOTOLOCATION message should not be case-sensitive
! @since    NXM-3.7.1
! @author:  Gregory Harris
!******************************************************************************!
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)

  call setDatDir

    res normalTests "None,ZoomUpper,ZoomLower,ZoomMixed,MarkLocationUpper,MarkLocationLower,MarkLocationMixed"

    pipe init
      panel/msgid=MAIN/setup/controls=gc/options=-RotateTabs
      ! NTN: added options=+BSTORE|+DBUFFER on PLOT to reduce flickering
      plot/id=idplot ^{datDir}.apenny.prm options=+BSTORE|+DBUFFER

      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" "Select the 'Add Penny Feature' options below. \n\n1) Zoom buttons &
      will show a zoomed screen of a full yellow circle. \n\n2) MarkLocation buttons will show a cross hair &
      crossing over a yellow full circle. \n\nNote: The \"None\" button will reset the plot in between tests." 24 11 /title
      gcontrol/nc=3 button nextpenny "Add Penny Feature" ^normalTests none
    pipe off

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 eqss "NEXTPENNY" then
    invoke xxx reg.win.idplot.makeVisibleTab()

    if msg.data EQS "NONE" then
      set reg.idplot.removeFeature "*"
      invoke ,, reg.idplot.unzoom()
      
    elseif msg.data EQS "ZoomUpper" then
      set flag "ZOOM"
      call test_dr2890
      
    elseif msg.data EQS "ZoomLower" then
      set flag "zoom"
      call test_dr2890
      
    elseif msg.data EQS "ZoomMixed" then
      set flag "zOoM"
      call test_dr2890
      
    elseif msg.data EQS "MarkLocationUpper" then
      set flag "MARKLOCATION"
      call test_dr2890
      
    elseif msg.data EQS "MarkLocationLower" then
      set flag "marklocation"
      call test_dr2890
      
    elseif msg.data EQS "MarkLocationMixed" then
      set flag "MaRkLoCaTiOn"
      call test_dr2890

    else
      warning "Do not know ^msg.data feature"
    endif
  else
    ! do nothing
    say "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

!******************************************************************************!
! Main process message for this macro. Should be right after the ENDMACRO.
!******************************************************************************!
! test zooming into circle feature to make sure it still displays
procedure test_dr2890 S:color["YELLOW"]
  set x 60.0  ! x-coordinate center point
  set y 75.0  ! y-coordinate center point
  set d 5.0   ! diameter
  set r (d/2) ! radius
  set x1 (x - r)
  set x2 (x + r)
  set y1 (y - r)
  set y2 (y + r)

  !!! DX controls size of CIRCLE !!!
  feature label=fcirc3 table={NAME="CIRC3",TYPE="CIRC|FILLED",X=^x,Y=^y,DX=^d,COLOR=^color} plot=idplot
  message send ID=idplot NAME="GOTOLOCATION" DATA={XVAL=^x,YVAL=^y,RADIUS=^r,FLAGS=^flag}
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
