!******************************************************************************!
! Test VNCVIEWER;VNC command
!
! Arguments: port
!
! @author:  Neon Ngo
!******************************************************************************!
startmacro port[2]
  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)

  if interAct then
    set instructions "Start a VNC server on display number :^{port} on local machine, e.g.\n  &
                      $ vncserver :^{port}\n\n&
                      Enter appropriate password in the VNCVIEWER's VNC Authentication pane &
                      and you should see the VNC desktop session in the pane."

    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 11 /title
      shellgui/id=idshellgui/attach
      vncviewer localhost:^{port}

    pipe off

  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
  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
!******************************************************************************!
procedure processException m:emsg
  assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
  if "Trace" SUBS ENV.DEBUG invoke ,, emsg.data.printStackTrace()
return
