!------------------------------------------------------------------------------!
! Tests for LIST2 command.
!
!   Author : J. Czechowski IV
!------------------------------------------------------------------------------!
startmacro/theme=gear4
  switch INTERACTIVE  interAct      GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch COREGRAPHICS coregraphics  GET DEF=FALSE SDEF=TRUE  ! for a quick check of graphics - more extreme tests - since 3.8.1

  if interAct OR coreGraphics then
    res s:dir "nxm.sys.test."
    
    set t:testTemplates {}
    set t:testTemplates.TYPES       {TITLE="Types",          MACRO="^{dir}test_list2_types.mm"}
    set t:testTemplates.TEMPLATES   {TITLE="Templates",      MACRO="^{dir}test_list2_templates.mm"}
    set t:testTemplates.TEMPLMODS   {TITLE="Template Mods",  MACRO="^{dir}test_list2_templates_mods.mm"}
    set t:testTemplates.TEMPLFONT   {TITLE="Template Fonts", MACRO="^{dir}test_list2_templates_fonts.mm"}
! Currently, the LEGACY tests are duplicated in TEMPLATES
!   set t:testTemplates.LEGACY      {TITLE="Legacy",         MACRO="^{dir}test_list2_legacy.mm"}
    set t:testTemplates.COLORS      {TITLE="Template Colors",MACRO="^{dir}test_list2_templates_colors.mm"}

    set t:testSelection {}
    set t:testSelection.SELLEGACY   {TITLE="Select Legacy",  MACRO="^{dir}test_list2_select_legacy.mm"}
    set t:testSelection.SELECT      {TITLE="Select",         MACRO="^{dir}test_list2_select.mm"}
    set t:testSelection.SELECTMODE  {TITLE="Select Mode",    MACRO="^{dir}test_list2_select_mode.mm"}
    set t:testSelection.CLICKACTION {TITLE="Click Action",   MACRO="^{dir}test_list2_clickaction.mm"}
    set t:testSelection.BUTTONS     {TITLE="Buttons",        MACRO="^{dir}test_list2_buttons.mm"}
    set t:testSelection.SELECTREM   {TITLE="Select Remove",  MACRO="^{dir}test_list2_select_remove.mm"}

    set t:testPolling {}
    set t:testPolling.PIPE          {TITLE="Pipe",           MACRO="^{dir}test_list2_pipe.mm"}
    set t:testPolling.POLL          {TITLE="Poll",           MACRO="^{dir}test_list2_poll.mm"}
    set t:testPolling.POLL2         {TITLE="Poll2",          MACRO="^{dir}test_list2_poll2.mm"}
    
    set t:testMisc {}
    set t:testMisc.ADDREMOVE        {TITLE="Add/Remove",     MACRO="^{dir}test_list2_add_remove.mm"}
    set t:testMisc.ADDSETUPDATE     {TITLE="Add/Set/Update", MACRO="^{dir}test_list2_add_set_update.mm"}
    set t:testMisc.ADDSETUPDATE     {TITLE="GetRow",         MACRO="^{dir}test_list2_getrow.mm"}
    set t:testMisc.RENDERER         {TITLE="Renderer",       MACRO="^{dir}test_list2_renderer.mm"}
    !set t:testMisc.EXIT             {TITLE="Exit",           MACRO="^{dir}test_list2_exit.mm"}
    
    call runTests testTemplates "templates"
    if interAct
      call runTests testSelection "selection"
      call runTests testPolling   "polling"
      call runTests testMisc      "misc"
      %test_list2_256ascii   ! NXM-3570 'Z' 256 ASCII DataType
    endif
    
    if /baseline then
	    %test_list2_col_resize
	    %test_list2_file_template
	    %test_list2_exit ret
	    %test_list2_exit menu
	    %test_list2_exit msg
	    %test_list2_exit win
	    %test_list2_updaterow
	    %test_list2_autohide     !Bug 2058
	    %test_list2_submacro     !Bug 2396
	    %test_list2_table
	    %test_list2_select_sort  ! Bug 2467
	    %test_list2_ramsize      ! Bug 2585,2168,1104
	    %test_list2_overwrite    ! Bug 2585
	    %test_list2_tbl_template ! Bug 2602
	    %test_list2_opentemplate ! Bug 2639
	    %test_list2_poll_now     ! Bug 2701
    endif
  endif
endmacro


! Runs a set of tests
procedure runTests t:tests S:testGroup[""]
  res setup {}
  call makeSetupTable tests setup 
  pipe on
    panel/msgid=MAIN/id=panel/tsetup=setup/controls=gc/OPTIONS=-RotateTabs|-PushPopX/EXIT=none

    gcontrol label macro "MACRO"
    gcontrol/tleft menu MAIN "Exit with Status = " "PASS,FAIL" table={ITEMCOLORS={PASS=GREEN,FAIL=RED}}
    gcontrol text idtext "INSTRUCTIONS" "^reg.main.name (^testGroup): Try the test cases &
                                         in each of the blue tabs on the top." 24 5 /title
    call startTests tests
  pipe off
return

! Procedure for handling all messages
procedure processMessage m:msg
  if msg.name EQS "MAIN" then
    call exitTests tests
    pause 1
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  else
    say "Unhandled messagename: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

include multi_test_template.mm
