!------------------------------------------------------------------------------!
! Tests for LIST2 command.
!
!   Author : J. Czechowski IV
!------------------------------------------------------------------------------!
startmacro/tsetup=nxm.sys.test.test_list2_setup.tbl
  switch INTERACTIVE  interAct     GET DEF=TRUE
  switch standalone   standalone   GET DEF=TRUE
  switch COREGRAPHICS coregraphics GET DEF=FALSE SDEF=TRUE  ! for a quick check of graphics - more extreme tests - since 3.8.1

  res instructions "The list should refresh the file with the current time &
                    following the SOD widget. (The value is initially set to &
                    99999 but this should change after the first poll interval. &
                    Clicking 'PollImmediately' should update the time immediately."
  set testfile "ram:temp_list_poll"
  waveform ^testfile elem=4k
  set FILE(^testfile).data(0) 99999
  set pollTime 2
  !res testfile

  timex now sod=sod

  if interAct OR coreGraphics then
    pipe init
      panel/msgid=MAIN/id=panel/controls=gc
      INFO "it is expected to see a warning about using the /POLL switch"
      list2/poll=2/msgid=MAIN/id=idlist ^testfile {F1={TYPE="NUMBER",FORMAT="#.000"}}
      if standalone isTrue then
        gcontrol label  macro   "MACRO"
        gcontrol menu MAIN "Exit with Status = " "PASS,FAIL" /tleft
        set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}
      endif

      gcontrol text   idtext "Instructions" "^instructions" 24 10 /title

      gcontrol button pollnow  "Task" "PollImmediately"
      gcontrol dval   secondofday "Seconds-of-day" 99999 0 1e9 /fmt="#.000" /msg=f
      gcontrol LVAL   polltime "Poll Time" pollTime 1 10 1

      set reg.panel.timer(0) 1
    pipe off
  endif
  erase/quiet/warn=no ^testfile
endmacro

!------------------------------------------------------------------------------!
! Procedure for handling all messages
procedure processMessage m:msg
  if msg.name EQS "MAIN" then
    if msg.data EQS "EXIT" then
      pipe stop
    else
      assert/text="LIST2 tests" "PASS" SUBS msg.data
      pipe stop
    endif
  elseif msg.name EQS "TIMER" then
    timex now sod=sod
    set FILE(^testfile).data(0) ^sod
    set gc.secondofday.value ^sod

  elseif msg.name EQS "POLLNOW" then
    invoke ,, reg.idlist.pollImmediately()

  elseif msg.name EQS "POLLTIME" then
    set reg.idlist.pollinterval    gc.POLLTIME.value

  endif
return
