! Tests that attempting to attach a second shellgui is not allowed and results in an poppup error
!
! @author  J. McCall
! @bug     NXM-2872 SHELLGUI: NPE when multiple shellguis attached
! @since   NeXtMidas 3.7.1
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=^interAct SDEF=TRUE  ! for defects or more obscure test case(s)

  res btnText "Attach another shellgui"

  if interAct then
    set instr "Should see two SHELLGUIs, one that is attached and one that is not.\n&
               1) The attached shellgui should have the text 'Hi! I am attached'.\n&
               2) There should not be any popup with an error message.\n&
               3) Click the button '^{btnText}' and a popup warning about attaching too many SHELLGUIs should appear.\n&
               4) Click OK.\n&
               5) Next, run %test_shellgui_attach in the top shellgui\n&
               6) Move the extra overlapping panel to the side, so you can see both\n&
               7) There should not be an error popup on either panel\n&
               7) Click the button '^{btnText}' on the new panel (one that was on top)'\n&
               8) A popup warning about attaching too many SHELLGUIs should appear.\n&
               9) Click PASS on both panels if everything worked as described"

    pipe on
      panel/msgid=MAIN/id=panel/setup/controls=gc
      gcontrol label macro  "MACRO"
      gcontrol menu   MAIN   "Exit with Status = " "PASS,FAIL" /tleft
      gcontrol text   idtext "Instructions" "^instr" 30 30 /title
      gcontrol button name=btnAttach P1=^btnText
      set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}

     
      shellgui/id=shell1/attach
      say "Hi!  I am attached"
      
      shellgui/id=shell2

    pipe off
  endif

endmacro

!*****************************************************************************
! Procedure for handling all messages
!****************************************************************************
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 "BTNATTACH" then 
    shellgui/id=shell3/attach

  else
    say "Unhandled messagename: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

