!------------------------------------------------------------------------------!
! Tests for LIST2 race conditions (BUG 2064)
!
!   Author : J. Bauer
!   Version: $Id: test_list2_race_cond.mm,v 1.1 2010/02/01 21:03:56 jwb Exp $
!------------------------------------------------------------------------------!

startmacro
  
  set l:origX 1
  set l:xVal  2
  set l:yVal  3

  pipe init
  
    panel/msgid=MAIN/controls=gc/setup
    
    list2/msgid=main/id=idlist template={_GLOBAL_={AUTOHIDE=FALSE},X={},Y={}}
    set reg.idlist.primarykey "X"
  
    gcontrol label  macro   "MACRO"
      gcontrol menu MAIN "Exit with Status = " "PASS,FAIL" /tleft
      set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}
      res instructions "Test for race conditions in LIST2. You should see a LIST2 with &
         a single row with X=^origX and y=^yVal. Press AddRow to add another row &
         of data. Press UpdateRow to update the Y Value in the first (initial) row."
      gcontrol text idtext "Instructions" "^instructions" 24 10 /title

    gcontrol button addRow "" "AddRow" none
    gcontrol button updateRow "" "UpdateRow" none
  
    call updateRow
   
  pipe off

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 "ADDROW" then
    call addRow
  elseif msg.name eqs "UPDATEROW" then
    call updateRow
  endif  
return
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
procedure addRow
  res t:row {X=^xVal,Y=^yVal}
  invoke ,, reg.idlist.addRow(row) 
  
  calc xVal xVal 1 +
  calc yVal yVal 1 +
return

procedure updateRow
  res t:tab {X=^origX,Y=^yVal}
  invoke ,, reg.idlist.updateRow(tab)
  
  calc yVal yVal 1 +
return
