!******************************************************************************!
! Test the plotting of a bad KML (.kml) file.
!
! This macro attempt to plot the world.shp file and a large KML sample file. There
! is a KML (XML) error at the top of the KML file (mis-matched tags)
!
! Author:  J. Bauer
!******************************************************************************!
startmacro/auto

  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  call setDatDir

  set defaultInstructions &
      "Should see popup informing you that bad kml has been encountered. Select &
      CANCEL. The panel should either go blank or display an empty grid. There &
      should also be a stack trace at the command prompt"

  set popuptext "The following test case tests the ability for a user to &
      exit a plot if there is bad KML. Click 'Cancel' on the next popup."

  if interAct then
    pipe init
    panel/msgid=MAIN/setup/controls=gc

    gcontrol label mainLabel "Main"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}

    gcontrol text idtext "Instructions" "^defaultInstructions" 40 10 /title

    popup/blocking=macro xxx FUNC="OK" "^popupText" "INFO"
    say "INFO: You should see a stack trace below for bad KML tags"
    plot/id=idplot/READOUT="+OnAxis"   ^{datDir}.world.shp|&
                                       nxm.sys.test.kmlTest_bad.kml&
                                       {LAYER={ICONSIZE=10,ICONZOOMSIZE=48,COLORBLENDRATIO=0.8}} &
                                       view=latlon

    pipe off
  endif
endmacro

!******************************************************************************!
procedure processMessage m:msg

  !say "msg.name ^msg.name, data ^msg.data"

  if msg.name eqs "MAIN" then
    assert/text="Plot files tests" msg.data eqss "PASS"
    pipe stop
  else
    ! do nothing
    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
