/* 
 * Motif
 *
 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
 *
 * These libraries and programs are free software; you can
 * redistribute them and/or modify them under the terms of the GNU
 * Lesser General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * These libraries and programs are distributed in the hope that
 * they will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU Lesser General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with these librararies and programs; if not, write
 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA 02110-1301 USA
*/ 
/* 
 * HISTORY
*/ 
/*
static char rcsid[] = "$XConsortium: SharedTearM1a.dat /main/5 1995/07/13 18:38:43 drk $"
*/
@)     SHARED TEAR OFF MENU TEST

#) Two client windows will appear, each containing a menubar, option menu,
   popup menu and an array of pushbuttons to change menu item sensitivity.

#) A message should appear, specifying the tear off control.  It
   should verify that the tear off control's parent is the pane passed
   to XmGetTearOffControl().

#) A number of warnings should have been issued - something like,
   "Tear off enabled on a shared menupane: allowed but not recommended"

#) There should be no 'String" to 'TearOffModel' type converter warnings.

C)

@)     CHECKING VISUALS

#) Use Button1 to select and browse the MenuBar and OptionMenu menupanes.
   A separator should span the top of each menupane.
   All menu items should be sensitive.

#) Use Button3 to post and browse the popup menu.
   A separator should span the top of each menupane.
   All menu items should be sensitive.

C)

@)     TESTING TEARING METHODS

#) In either window, post the MenuBar [Colors] submenu with Button1Press
   (and hold).  
   Button1Dragging in and out of the tear off control should arm and disarm
   the button.
   Drag down to the tear off control and Button1Release.
   The submenu should tear off in place and receive the focus if 
   keyboardFocusPolicy is XmEXPLICIT, otherwise move the pointer into
   the tear off menu.
   The tear off menu should contain an mwm border (no resize handles),
   window system menu, and title (Colors).
   The tear off menu should not have a tear off control (separator visual).

#) KeyPress <Escape> to dismiss the tear off.

C)

#) In either window, post the MenuBar [Colors] submenu with Button1Click.
   Button2Press on the tear off control.
   If the screen resource, XmNmoveOpaque is True, the pane will begin to
   move opaquely.  Otherwise, an outline of the pane should appear.
   KeyPress <Escape> to dismiss the tear off action.

#) Button2Press on the tear off control, again.
   Button2Drag to a position outside of the test's windows.
   Button2Release to drop the tear off at the desired position.

#) KeyPress <Escape> to dismiss the tear off.

C)

#) In either window, post the MenuBar [Colors] submenu with Button1Click.
   Use <Up-Arrow> to traverse to the tear off control.  
   KeyPress <Return> or <Space> to select the tear off control.
   The submenu should tear off in place and receive the focus if 
   keyboardFocusPolicy is XmEXPLICIT, otherwise move the pointer into
   the tear off menu. 

#) Post the tear off menu's system window menu and select [Close] to dismiss
   the tear off.

C)

#) In either window, post the Popup Menu with Button3Press.  

#) Button3Release on [To More Colors] to post a cascading submenu.

#) Use any method to tear off the Popup Menu (not the cascading
   submenu).  The popup menu and cascading submenu should unpost.  The
   tear off menu should have a blank title that is indicative of all popup
   tear offs.

#) Repost the Popup Menu with Button3Press.
   Make sure the tear off control appears on the popup.

#) Button3Release on [To More Colors] to post a cascading submenu.

#) KeyPress <Escape> twice to unpost the Popup Menu.  When the popup
   unposts, the tear off menu should restore.  The tear off should not
   have a tear off control.

C)

#) In "(one of) the other window(s)", post the Popup Menu with Button3Press.

#) Use any method to tear off the Popup Menu.
   The old tear off menu should dismiss.

C)

#) In either window, post the Option Menu with Button1Press.  

#) Use any method to tear off the Option Menu. 
   The tear off menu should increase in width to accomadate the title
   which is the option menu's label.  The option menu label and cascade
   should NOT change in size.

#) Repost the Option Menu with Button1Press.
   The tear off should decrease in width to reflect the size of the largest 
   menu item.
   Make sure the tear off control appears on the menupane.

#) KeyPress <Escape> to unpost the Option Menu.  When the option menu
   unposts, the tear off menu should restore.  The width should once
   again grow to the width of the shell.  The tear off should not
   have a tear off control.

C)

@)     TESTING SHARED TEAR OFF SENSITIVITY
@)     Rerun this test with the "-tt1" command line argument on this section.

#) Use any method to tear off MenuBar [Colors] submenu from either 
   window.

#) Select the [Change Red Sensitivity] button in the same window.
   Menu item, [Red], in the tear off menupane should change to INsensitive.

#) In (one of) the other window(s), select the [Change Green Sensitivity] 
   button.
   Menu item [Green]'s sensitivity in the tear off menupane should NOT change.

#) In the original "same" window, post the MenuBar [Colors] submenu by 
   selecting with Button1.  
   Note that menu item [Red] is INsensitive and [Green] is sensitive.
   KeyPress <R> should have no affect.
   KeyPress <G> should activate menu item [Green] via its mnemonic.

#) In the original "same" window, post the Popup Menu with Button3Press.  
   Post the cascading pane [To More Colors] submenu.  
   Note that menu item [Red] is INsensitive and [Green] is sensitive.
   KeyPress <R> should have no affect.
   KeyPress <G> should activate menu item [Green] via its mnemonic.

C)

#) In "(one of) the other window(s)", post the MenuBar [Colors] submenu by
   selecting with Button1.  
   Note that menu item [Red] is sensitive and [Green] is INsensitive.
   KeyPress <G> should have no affect.
   KeyPress <R> should activate menu item [Red] via its mnemonic.

#) In the same "(one of) the other window(s)", post the Popup Menu by 
   selecting with Button3.  
   Post the cascading pane [To More Colors] submenu.  
   Note that menu item [Red] is sensitive and [Green] is INsensitive.
   KeyPress <G> should have no affect.
   KeyPress <R> should activate menu item [Red] via its mnemonic.

C)

#) In the same "(one of) the other window(s)", use any method to 
   tear off MenuBar [Colors] submenu.
   The old tear off menu should dismiss.
   Note that menu item [Red] is sensitive and [Green] is INsensitive.

#) Make sure that the tear off menu has the focus.
   KeyPress <G> should have no affect.

#) KeyPress <R> should activate menu item [Red] via its mnemonic.
   An activate callback message should be reported to the term window.

#) Select [Red] by traversing to it and KeyPressing <Return> or <Space>.

#) Select [Red] with Button1Press.

C)

#) Post and use any method to tear the Popup Menu from either window.

#) Select the [Change Pink Sensitivity] button in the same window.
   Menu item, [Pink], in the tear off menupane should change to INsensitive.

#) In (one of) the other window(s), select the [Change Baby Blue Sensitivity] 
   button.
   Menu item [Baby Blue]'s sensitivity in the tear off menupane should NOT 
   change.

#) In the original "same" window, post the Popup Menu by selecting with 
   Button3.  
   Note that menu item [Pink] is INsensitive and [Baby Blue] is sensitive.
   KeyPress <P> should have no affect.
   KeyPress <B> should activate menu item [Baby Blue] via its mnemonic.

C)

#) In the same "(one of) the other window(s)", post the Popup Menu by 
   selecting with Button3.  
   Note that menu item [Pink] is sensitive and [Baby Blue] is INsensitive.
   KeyPress <B> should have no affect.
   KeyPress <P> should activate menu item [Pink] via its mnemonic.
   In the popup tear off, [Pink] should still be INsensitive and [Baby Blue]
   should be sensitive.

#) In the same "(one of) the other window(s)", post the Popup Menu by 
   selecting with Button3.  

#) Use any method to tear off the Popup Menu.
   Note that menu item [Pink] is sensitive and [Baby Blue] is INsensitive.

C)

#) Button1Press [RESET MENUS] in each window.

#) Rerun this test with the "-tt1" command line argument on the previous 
   section.

C)

@)     TESTING SHARED TEAR OFF ACCELERATORS
@)     Note that this section takes advantage of an internal, unsupported
       entry point.
@)     Rerun this test with the "-tt1" command line argument on this section as well.

#) Use any method to tear off MenuBar [Colors] submenu from either
   window.

#) Make sure that the tear off menu has the focus.

#) Press <Ctrl-R>.  [Red] should ACTIVATE and report postFromWidget = mb;
Toplevel Shell = (same window).

#) Press <Ctrl-G>.  [Green] should ACTIVATE and report postFromWidget = mb;
Toplevel Shell = (same window).

#) Press <Ctrl-l>.  [Blue] should VALUE_CHANGED and report value and tracked
value = 1; postFromWidget = mb; Toplevel Shell = (same window).

#) Press <Ctrl-Y>.  [Yellow] should VALUE_CHANGED and report value and tracked
value = 1; postFromWidget = mb; Toplevel Shell = (same window).

C)

#) Move the focus to the original "same" window.

#) Press <Ctrl-R>.  [Red] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (same window).

#) Press <Ctrl-G>.  [Green] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (same window).

#) Press <Ctrl-l>.  [Blue] should VALUE_CHANGED and report value and tracked
value = 0; postFromWidget = mw; Toplevel Shell = (same window).  In the
tear off, [Blue] should change state.

#) Press <Ctrl-Y>.  [Yellow] should VALUE_CHANGED and report value and tracked
value = 0; postFromWidget = mw; Toplevel Shell = (same window).  In the
tear off, [Yellow] should change state.

C)

#) Move the focus to the "other" window.

#) Press <Ctrl-R>.  [Red] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (other window).

#) Press <Ctrl-G>.  [Green] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (other window).

#) Press <Ctrl-l>.  [Blue] should VALUE_CHANGED and report value and tracked
value = 1; postFromWidget = mw; Toplevel Shell = (other window).  The tear
off should not change.

#) Press <Ctrl-Y>.  [Yellow] should VALUE_CHANGED and report value and tracked
value = 1; postFromWidget = mw; Toplevel Shell = (same window).  The tear
off should not change.

C)

#) Make sure the focus is in the "other" window.

#) Press <Ctrl-l>.  [Blue] should VALUE_CHANGED and report value = 1; tracked
value = 0; postFromWidget = mw; Toplevel Shell = (other window).  The tear
off should not change.

#) Move the focus to the original "same" window.

#) Press <Ctrl-l>.  [Blue] should VALUE_CHANGED and report value and tracked
value = 1; postFromWidget = mw; Toplevel Shell = (same window).  The tear
off should reflect the change.

#) Move the focus back to the "other" window.

#) Press <Ctrl-l>.  [Blue] should VALUE_CHANGED and report value = 0; tracked
value = 1; postFromWidget = mw; Toplevel Shell = (other window).  The tear
off should not change.

C)

#) Make sure the focus is in the "other" window.

#) Press <Ctrl-Y>.  [Yellow] should VALUE_CHANGED and report value = 1; tracked
value = 0; postFromWidget = mw; Toplevel Shell = (other window).  The tear
off should not change.

#) Move the focus to the original "same" window.

#) Press <Ctrl-Y>.  [Yellow] should VALUE_CHANGED and report value and tracked
value = 1; postFromWidget = mw; Toplevel Shell = (same window).  The tear
off should reflect the change.

#) Move the focus back to the "other" window.

#) Press <Ctrl-Y>.  [Yellow] should VALUE_CHANGED and report value = 0; tracked
value = 1; postFromWidget = mw; Toplevel Shell = (other window).  The tear
off should not change.

C)

#) Select the [Change Red Sensitivity] button in the original "same" window.
   Menu item, [Red], in the tear off menupane should change to INsensitive.

#) Select the [Change Blue Sensitivity] button in the original "same" window.
   Menu item, [Blue], in the tear off menupane should change to INsensitive.

#) In the "other" window, select the [Change Green Sensitivity] button.
   Menu item [Green]'s sensitivity in the tear off menupane should NOT change.

#) In the "other" window, select the [Change Yellow Sensitivity] button.
   Menu item [Yellow]'s sensitivity in the tear off menupane should NOT change.

#) Move the focus to the tear off menu.
   KeyPress <Ctrl-R> should have no affect.
   KeyPress <Ctrl-l> should have no affect.

#) Press <Ctrl-G>.  [Green] should ACTIVATE and report postFromWidget = mb;
   Toplevel Shell = (same window).

#) Press <Ctrl-Y>.  [Yellow] should VALUE_CHANGED and report 
   postFromWidget = mb; Toplevel Shell = (same window).

C)

#) Move the focus to the original "same" window.

#) Press <Ctrl-R>.  [Red] should "ignore activate" and report 
   postFromWidget = mw; Toplevel Shell = (same window).

#) Press <Ctrl-G>.  [Green] should ACTIVATE and report postFromWidget = mw;
   Toplevel Shell = (same window).

#) Press <Ctrl-l>.  [Blue] should "ignore value_changed" and report 
   postFromWidget = mw; Toplevel Shell = (same window).

#) Press <Ctrl-Y>.  [Yellow] should VALUE_CHANGED and report 
   postFromWidget = mw; Toplevel Shell = (same window).

C)

#) Move the focus to the "other" window.

#) Press <Ctrl-R>.  [Red] should ACTIVATE and report postFromWidget = mw;
   Toplevel Shell = (other window).

#) Press <Ctrl-G>.  [Green] should "ignore activate" and report 
   postFromWidget = mw; Toplevel Shell = (other window).

#) Press <Ctrl-l>.  [Blue] should VALUE_CHANGED and report 
   postFromWidget = mw; Toplevel Shell = (other window).

#) Press <Ctrl-Y>.  [Yellow] should "ignore value_changed" and report 
   postFromWidget = mw; Toplevel Shell = (other window).

C)

#) In original "same" window, post the MenuBar [Colors] submenu with 
   Button1Click.
   KeyPress <Ctrl-R> should have no affect.
   KeyPress <Ctrl-l> should have no affect.
   The menu should remain posted.

#) Press <Ctrl-G>.  [Green] should ACTIVATE and report postFromWidget = mb;
   Toplevel Shell = (same window).  The menu should unpost.

#) In original "same" window, repost the MenuBar [Colors] submenu with 
   Button1Click.

#) Press <Ctrl-Y>.  [Yellow] should VALUE_CHANGED and report 
   postFromWidget = mb; Toplevel Shell = (same window).  The tear off's
   [Yellow] toggle button should change state.  The menu should unpost.

C)

#) In "other" window, post the MenuBar [Colors] submenu with 
   Button1Click.
   KeyPress <Ctrl-G> should have no affect.
   KeyPress <Ctrl-Y> should have no affect.
   The menu should remain posted.

#) Press <Ctrl-R>.  [Red] should ACTIVATE and report postFromWidget = mb;
   Toplevel Shell = (other window).  The menu should unpost.

#) In "other" window, repost the MenuBar [Colors] submenu with 
   Button1Click.

#) Press <Ctrl-l>.  [Blue] should VALUE_CHANGED and report 
   postFromWidget = mb; Toplevel Shell = (other window).  The tear off
   should not change.  The menu should unpost.

C)

#) Post and use any method to tear the Popup Menu from either window.

#) Make sure that the tear off menu has the focus.

#) Press <Ctrl-P>.  [Pink] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (same window).

C)

#) Move the focus to the original "same" window.

#) Press <Ctrl-P>.  [Pink] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (same window).

C)

#) Move the focus to (one of) the "other" window(s).

#) Press <Ctrl-P>.  [Pink] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (other window).

C)

#) Post and use any method to tear the Popup Menu from the (same)
   "other" window.

#) Make sure that the tear off menu has the focus.

#) Press <Ctrl-P>.  [Pink] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (other window).

C)

#) Move the focus to the (same) "other" window.

#) Press <Ctrl-P>.  [Pink] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (other window).

C)

#) Move the focus to the original "same" window.

#) Press <Ctrl-P>.  [Pink] should ACTIVATE and report postFromWidget = mw;
Toplevel Shell = (same window).

C)

#) Button1Press [RESET MENUS] in each window.

#) Rerun this test with the "-tt1" command line argument on the previous 
   section.

C)

@)     TESTING TEAR OFF CASCADING SUBMENUS AND HIGHLIGHTING

#) Use any method to tear off MenuBar [Colors] submenu from either
   window.

#) In the tear off, Btn1Press [More Colors] to post a cascading submenu.

#) Button1Drag through each of the tear off's menu-items.

#) Button1Drag back to [More Colors] and hold.

#) Button1Release on [Black] to select and activate.  An activate callback
   message should be reported to the term window.  The submenu should unpost.

#) Restore focus to the tear off.  [More Colors] should highlight.

#) Button1Click on [Still More Colors] to post a cascading submenu.

#) KeyPress <e> to select and activate [Grey] via its mnemonic.  The submenu
   should unpost.

#) Restore focus to the tear off.  [Still More Colors] should highlight.

#) Repost MenuBar [Colors] from either window using Button1.  Red should be 
   highlighted.

#) KeyPress <Escape> to unpost the MenuBar.

#) Restore focus to the tear off.  [Still More Colors] should be highlighted.

C)

#) Use any method to tear off the Popup Menu from either window.

#) Make sure that the Popup tear off has the focus.

#) KeyPress <M> to post [To More Colors]'s cascading submenu.

#) KeyPress <Escape> to unpost the cascading submenu.

#) Restore focus to the [Colors] tear off.  [Still More Colors] should 
   be highlighted.

C)

#) In the tear off, Btn1Press on [Green] (and hold).  The cursor should change 
   to the menu cursor.  Moving in and out of [Green] should arm and disarm it.

#) Button1Release on [Green] to activate it.  [Green] should remain
   highlighted.  The cursor should return to normal.

#) Button1Press [RESET MENUS] in each window.

C)

@)     TESTING FOR ORPHAN TEAR OFFS

#) Uniconify (Double Click) one of the "Dup" toplevel windows.

#) Use any method to tear off the Popup Menu from the new "Dup" window.

#) Use any method to tear off MenuBar [Colors] submenu from new "Dup" window.

#) Post the "Dup" window's system window menu and select [Close] to dismiss
   it.  The two tear offs should dismiss as well.

C)

#) Uniconify (Double Click) another new "Dup" toplevel window.

#) Use any method to tear off the Popup Menu from the new "Dup" window.

#) Use any method to tear off MenuBar [Colors] submenu from new "Dup" window.

#) Move the focus to the [Colors] tear off menu.  
   KeyPress <Escape> to dismiss the tear off menu.

#) Move the focus to (one of) the other window(s).

#) Use any method to tear off the Popup Menu.  
   The old tear off menu should dismiss.

#) In the same "(one of) the other window(s)", use any method to tear off 
   MenuBar [Colors] submenu. 

#) Post the original new "Dup" window's system window menu and select [Close] 
   to dismiss it.  The two tear offs should remain posted.

E)
