/**********************************************************************/
/**			  Microsoft Windows NT	 		     **/
/**		Copyright(c) Microsoft Corp., 1991		     **/
/**********************************************************************/

/*
    sharedlg.ut
    Share dialogs ( Create share, stop share, edit share ) unit tests

    There are three main dialogs in share subsystem: the "Share Properties"
    Dialog ( for changing properties of a share), the "Share Directory"
    Dialog ( for creating a new share) and the "Stop Sharing Directory"
    Dialog ( for stopping a share). The Share Properties dialog will
    be slightly different depending on whether the share is on a share-
    level server or a user-level server. If the share is on a user-level
    server, then additional properties of a share such as password and
    permissions are shown.

    The "Share Properties" dialog is invoked though the File Manager
    File Properties Dialog and then clicking the Share button. The
    other two dialogs are invoked through the Network Menu of the File
    Manager.


    FILE HISTORY:
	Yi-HsinS     17-Oct-1991     Created
	Yi-HsinS     18-Oct-1991     Added Platform and Code Work for NT machines

*/

Platforms
=========
Win3.1/ LM20c Client
OS2 1.21/ LM20c Server

Code Work ==>  We need to add the test for NT machines later


Unit Tests
===========

(1) Log on to the network.

(2) Do a net use  to two shares on different servers ( a user-level
    server and the other a share-level server ).
    Assume  you did a net use to the following:
    (a) net use x: \\foo1\bar1     ( \\foo1 is a user-level server )
    (b) net use y: \\foo2\bar2     ( \\foo2 is a share-level server )

(3) Bring up the File Manager.


Share Properties Dialogs  ( User-level and share-level )
========================
    Scenario 0
    ----------
    Click on a file ( not a directory ) in the any window:
    Expect:
	    There should not be a button call "Share".
	    There should be a "Files Opens..." button instead.

    Scenario 1
    -----------
    Assuming you are on a DOS machine which cannot be a server and
    hence, the directories could not possibly be shared.

    Click on a directory or file in the File window of local drive c:
    Click the File menu, Properties, Share
    Expect:
	    MsgPopup saying "This operation is not supported on workstations."


    Scenario 2
    ----------
    Click on a directory that you know is not shared in either the
    File window or Directory Tree window of x:, y: or c: if local
    is an NT server.
    Click the File menu, Properties, Share

    Expect:
	    MsgPopup saying "The directory you selected is not shared."


    Scenario 3  ( Assume you have admin privilege on user-level server \\foo1 )
    ----------
    Click on a directory that you know is shared in either the
    File window or Directory Tree window of x: ( \\foo1 , user-level server )
    or c: is local is an NT user-level server.
    Click the File menu, Properties, Share

    Expect:
	    Caption of the dialog = "Share Properties".
	    Focus on listbox "Share Name". There should be at least
	    one share name in the listbox and the first one is
	    highlighted.
	    The comment and magic group User Limit both displays info.
	    on the share name that is highlighted.

    Click any other share name besides the one highlighted in the listbox
    ( if there exists! )

    Expect:
	    Focus is now on the share name  selected.
	    The comment and the user limit is updated to reflect the info.
	    on the share name that is selected.

    Change the comment. Click on the spin button to change the user limit or
    click on the unlimited radio button.

    Click OK.

    Expect:
   	    Dialog should be dismissed and we return to the File Properties
	    dialog.

    Click on Share button again.
    Click on the share name that you have changed the comment and user limit
    earlier.

    Expect:
	    The comment and user limit should reflect the info. you  typed
	    in earlier.


    Scenario 4  ( Assume you don't have admin privilege on user-level server
    ------------
		  but you have another password that does have admin privilege
		  because maybe you are on a different domain)


    Click on a directory that you know is shared in either the
    File window or Directory Tree window of x: ( \\foo1, user-level server )
    or c: if local machine is a NT user-level server.
    Click the File menu, Properties, Share

    Expect:
	    A dialog with caption "Enter Password" shows up prompting
	    you for the password to the resource \\foo1\admin$.
	    ( This may change in the future where you may be able
	    to type in a different user name. )

    Type in your password with admin privilege.

    If the password you typed in indeed  gives you admin privilege, the
    rest of the scenario is the same as scenario 3.
    You should  verify that you indeed have a connection made to \\foo1\admin$
    when the "Share Properties" dialog still exists.
    The connection should be deleted once the "Share Properties" dialog is
    dismissed.

    Otherwise, there would be a MsgPopup saying "Insufficient privilege."


    Scenario 5   (Assume your password is the same as the share \\foo2\admin$
    ------------
		  on a share-level server )
		
    Click on a directory that you know is shared in either the
    File window or Directory Tree window of y: ( \\foo2, share-level server )
    or c: if local machine is a NT share-level server.
    Click the File menu, Properties, Share

    Same as scenario 3 except the dialog  has addition properties of the
    share that you can change, the password field and the magic group
    Permissions.


    Scenario 6  ( Assume your password is not the same as \\foo2\admin$ on
    ------------
		  on a share-level server )


    Click on a directory that you know is shared in either the
    File window or Directory Tree window of y: ( \\foo2, share-level server )
    or c: if local machine is a NT share-level server.
    Click the File menu, Properties, Share

    Expect:
	    A dialog with caption "Enter Password" shows up prompting
	    you for the password to the resource \\foo2\admin$.

    Type in the password for admin share.

    If the password you typed in is correct, the rest of the scenario
    is the same as scenario 5.
    You should  verify that you indeed have a connection made to \\foo2\admin$
    when the "Share Properties" dialog still exists.
    The connection should be deleted once the "Share Properties" dialog is
    dismissed.

    Otherwise, there would be a MsgPopup saying "Insufficient privilege."


    Scenario 7  ( with admin priv. either on a user or share level server )
    ----------

    Click on a directory that you know is shared in either the
    File window or Directory Tree window of x: or y:
    or c: if local machine is a NT share-level server.

    Click the File menu, Properties, Share

    Let's assume the listbox shows 3 share names
	 share1, share2, share3.
    The original focus is on the first share name assuming share1.

    Delete share3 on the server that you chose.

    If you clicked on share3 now, since it does not exist any more,
    there will be a
	  MsgPopup saying "This shared resource does not exist."

    And the focus will be on the first share name in the listbox
    that we can get info. on, and hence the comment, user limit,
    password, permissions will contain info. on the share that
    is highlighted.



Share Directory Dialog ( Create a new share dialog )
=======================

    Scenario 0  ( on a user-level server )
    -----------
    Click on a directory or file in either the File window or
    Directory Tree window of x:
    or c: if local machine is a NT user-level server.
    If a file is selected, the directory containing the file is
    used instead.

    Click the Network menu, Share Directory.

    Expect:
            The Share Directory has a default name which is
	    the UNC name of the directory that is selected in the
	    File Manager. If multiple dirs are selected, the UNC
	    name of the first directory is shown.

	    The Share Name has a default name which is  the name
	    of the selected directory. If multiple dirs are
	    selected, the name of the first directory is shown.

            You are free to type in the UNC name of any directory
	    you want to share or any share name. ( Assume the
	    Share Directory you typed in is a still on a user-level
	    server )

    Type the comment, change the user limit if you feel like it.
    Click OK.

    Assume the Share Directory you typed in name is a user-level server.

    Expect:
            If you don't have admin privilege, a dialog with caption
	    "Enter Password" popups and you will be prompted
	    for the password to the \\server\admin$. Type in the
	    password if this happens or hit cancel will return you
	    back to the Share Directory dialog.
	
	    If you type in the correct password, a connection will be
	    made to \\server\admin$. The connection should be deleted
	    once the share is created successfully. You should
	    verify that there is no connection to \\server\admin$ once
	    the dialog is dismissed.

            If no MsgPopup, the share should be created successfully.
	    You can use the Share Properties Dialog to view if
	    all the info. are set correctly.

            Otherwise, if some error occurs, the error is shown and
	    you can correct the info. on the  dialog and click OK
	    again. You can choose to cancel the dialog if it's not
	    possible to create the share.


    Scenario 1  ( on a share-level server )
    ------------

    Click on a directory or file in either the File window or
    Directory Tree window of y:
    or c: if local machine is a NT share-level server.
    If a file is selected, the directory containing the file is
    used instead.

    Click the Network menu, Share Directory.

    Expect:
            The Share Directory has a default name which is
	    the UNC name of the directory that is selected in the
	    File Manager. If multiple dirs are selected, the UNC
	    name of the first directory is shown.

	    The Share Name has a default name which is  the name
	    of the selected directory. If multiple dirs are
	    selected, the name of the first directory is shown.

            You are free to type in the UNC name of any directory
	    you want to share or any share name. ( Assume the
	    Share Directory you typed in is a still on a share-level
	    server )

    Type the comment, change the user limit if you feel like it.
    Click OK.

    Expect:
            If you don't have admin privilege, a dialog with caption
	    "Enter Password" popups and you will be prompted
	    for the password to the \\server\admin$. Type in the
	    password if this happens or hit cancel will return you
	    back to the Share Directory dialog.

	    If you type in the correct password, a connection will be
	    made to \\server\admin$. The connection should be deleted
	    once the share is created successfully. You should
	    verify that there is no connection to \\server\admin$ once
	    the dialog is dismissed.

	    Because you are on a share-level server, a dialog with
	    caption "Password for New Share" pops up prompting
	    for the password and permissions to the share you are
	    creating.


    Type in the password, set the permissions and Click OK.

    Expect:
	    If you type in an invalid password or an invalid permission,
	    the focus will be set on the field which is invalid. If
	    you type in the valid password or permissions, the dialog
	    will be dismissed and the share will be created if no error
	    occurs. If you choose to hit CANCEL, then you are returned
	    to the the Share Directory Dialog in which you may want to
	    change some fields.


    Scenario 2
    ----------

    Click on a directory in either the File window or
    Directory Tree window of x: or y:
    or c: if local machine is a DOS machine which is not a server.

    Click the Network menu, Share Directory.

    Expect:
	    If  some error occurs while the default Share Directory
	    or Share name is sought, a MsgPopup saying that
	    "The share directory of the selected directory could
	     not be shown. Error errno occurred: text of errno".
	
	    After clicking OK for the MsgPopup, the Share Directory
	    Dialog pops up and the Share directory SLE and Share Name
	    SLE will be  empty. You can type in any Share directory
	    and share name you want.


Stop Sharing Dialog
====================

    Scenario 0
    ----------

    Click on a directory or file in  any window of the File Manager.
    If a file is selected, the directory containing the file is
    used instead.

    Click the Network menu, Stop Sharing Directory.

    Expect:
            The Share Name has a default name which is
	    the UNC name of the directory that is selected in the
	    File Manager. If multiple dirs are selected, the UNC
	    name of the first directory is shown. If the directory
	    you selected have multiple share names, all the share
	    names are shown in the combobox. You are free to click
	    any name in the combobox or  type in the UNC share name
	    of any directory you want to stop share.

    Click OK.

    Expect:
            If you don't have admin privilege, a dialog with caption
	    "Enter Password" popups and you will be prompted
	    for the password to the \\server\admin$. Type in the
	    password if this happens or hit cancel will return you
	    back to the Share Directory dialog.

	    If you type in the correct password, a connection will be
	    made to \\server\admin$. The connection should be deleted
	    once the share is deleted successfully. You should
	    verify that there is no connection to \\server\admin$ once
	    the dialog is dismissed.

	    If any error occurs while deleting the share, there
	    will be a MsgPopup stating the error and you are returned
	    to the Stop Sharing dialog.

	    If there are any user using the share that you are  going
	    to delete, a warning dialog pops up showing all
	    the usernames, #file opens and the elapsed time since the user
	    connected to the share. Clicking OK will delete the
	    share and Cancel will return you back to the  Stop Sharing
	    Dialog.

    Scenario 1
    ----------

    Click on a directory in either the File window or
    Directory Tree window of x: or y:
    or c: if local machine is a DOS machine which is not a server.

    Click the Network menu, Share Directory.

    Expect:
	    If  some error occurs while the default Share Directory
	    or Share name is sought, a MsgPopup saying that
	    "The share directory of the selected directory could
	     not be shown. Error errno occurred: text of errno".
	
	    After clicking OK for the MsgPopup, the Stop Sharing
	    Dialog pops up and the Share Name combobox is empty.
	    You can type in any Share name you want to delete.