! Tests the HELP command.
!
! @author  J. Czechowski IV / Neon Ngo
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  if interAct then
    ! NXM-3845 since NeXtMidas 4.1.1
    if ^{env.NMROOT} EQS "classpath:" then
      info "SKIPPING ^reg.main.name since fails when running from a jar file - &
            the path to the help index can not be read from the build.props file &
            when running from a jar file"
    else
      pipe init
        panel/msgid=MAIN/setup/controls=gc
        textdisplay/id=tdisp/msgid=main text=""

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

        gcontrol text instr "instructions" "Follow the instructions on both panes to the right.  &
          Then in nM-Pipe> prompt, run 'help/gui'. Close the HELP/GUI when done." 12 7 /title
        gcontrol menu ShowHelp "OPTIONS" "1. Show Help"

        call setupTextDisplay
        shellgui/id=idshellgui/attach/bg
        say "Command-Line HELP Test:"
        say "-----------------------"
        say "Type 'help trimmers' below. You should see several paragraphs of output."

      pipe off
    endif
  endif

endmacro

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

  if msg.name eqs "MAIN" then
    assert/text="HELP/GUI tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.name eqs "SHOWHELP" then
    help/gui
  else
    ! do nothing
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid dats: ^msg.data"
  endif

return

!******************************************************************************!
procedure setupTextDisplay
  message send tdisp,,"APPENDL",,"Interactive HELP/GUI Tests"
  message send tdisp,,"APPENDL",,"--------------------------"
  message send tdisp,,"APPENDL",," -> 1. Click on [Show Help] to launch HELP/GUI."
  message send tdisp,,"APPENDL",,""
  message send tdisp,,"APPENDL",," -> In the left column of HELP/GUI enter a search for some"
  message send tdisp,,"APPENDL",,"    NeXtMidas commands or search terms (e.g. RMIF, EXPLAIN,"
  message send tdisp,,"APPENDL",,"    PLOT, webstart, etc.)"
  message send tdisp,,"APPENDL",,"    The explain file and API docs should be near"
  message send tdisp,,"APPENDL",,"    the top of the results list. Searches are case insensitive."
  message send tdisp,,"APPENDL",,""
  message send tdisp,,"APPENDL",," -> Click on some of the result hits in the list."
  message send tdisp,,"APPENDL",,"    Verify that the result's content are displayed on the"
  message send tdisp,,"APPENDL",,"    right side. Make sure explain files, Javadoc API, "
  message send tdisp,,"APPENDL",,"    and the 'User's Guide' render and test the hyper links."
  message send tdisp,,"APPENDL",,""
  message send tdisp,,"APPENDL",,"   NOTE: There is a known issue with rendering some HTML files"
  message send tdisp,,"APPENDL",,"   with advanced CSS usage; (it will be blank) along"
  message send tdisp,,"APPENDL",,"   with a RuntimeException in the terminal window."
  message send tdisp,,"APPENDL",,""
  message send tdisp,,"APPENDL",," -> Try some wildcard (*,?) and boolean (AND, OR, NOT, -)"
  message send tdisp,,"APPENDL",,"    searches. E.g. 'webst?rt app*', 'plot OR feature'"
  message send tdisp,,"APPENDL",,"    '*browser AND help' (make sure AND,OR,NOT are UPPERCASE)."
  message send tdisp,,"APPENDL",,""
  ! begin test case for BUG 2440 Generate: add support for TEXT directive in Operators.cnf
  message send tdisp,,"APPENDL",," -> [For BUG 2440] Search for ModuloEuclid, the class "
  message send tdisp,,"APPENDL",,"    description in the javadoc on the 2nd line should say:"
  message send tdisp,,"APPENDL",,"      Euclidean Modulo (the remainder of a/b) function (always"
  message send tdisp,,"APPENDL",,"      return positive)."
  ! end test case for BUG 2440 Generate: add support for TEXT directive in Operators.cnf
  message send tdisp,,"APPENDL",,""
  message send tdisp,,"APPENDL",," -> Close HELP/GUI by clicking on the 'X' in"
  message send tdisp,,"APPENDL",,"    the upper corner of the window."

return
