!******************************************************************************!
! This tests the GProgressBar.  It requires that your WRITE AUX have A LOT of space
!
! @bug      NXM-3493 Need test for GProgressBar - Jeff uses it in snapper
! @since    3.9.2
! @author:  Jeanette McCall
!******************************************************************************!
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)
  switch COREGRAPHICS coreGraphics GET DEF=FALSE SDEF=TRUE  ! for a quick check of graphics - more extreme tests
  switch ALTTESTENV   alttestenv   GET DEF=FALSE SDEF=TRUE  ! alternate test environment

  res runningtest "NO"
  if interAct or coreGraphics then 
    popup/blocking=macro RESULT=runningtest FUNC=YESNO MESSAGE="Do you have your write aux set to handle a 800MB file?"
    if runningtest eqs "NO" then
      warn "^reg.main.name is being skipped, please run again later with large WRITE AUX"
    endif
    if alttestenv then
      popup/blocking=macro RESULT=runningtest FUNC=YESNO MESSAGE="Do you have hugefile.tmp in your read aux?"
      res fileToDownload "hugefile.tmp"
    else
      res fileToDownload "http://nextmidas.com/nmdownloads/test/hugefile.tmp"
    endif
  endif
  if runningtest EQS "YES" then
    set instructions "Click the button to start the NOOP with GPW of a large file from nextmidas\n\n&
                      Make sure the GProgressBar renders properly and shows percent of file NOOPed"

    pipe on
      panel/msgid=MAIN/setup/controls=gc
      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 startnoop "Click to start NOOP and Progress Bar" "START TEST"

    pipe off

    erase noophugefile3493.tmp

  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 "STARTNOOP" then
    noop/gpw "^{fileToDownload}" noophugefile3493.tmp
  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
