SPONSORS:






User Tag List

Results 1 to 6 of 6
  1. #1
    Guest

    HOW to extend 4test base classes ???

    Hi folks,
    I'm attempting to create a base class from which all invocable windows in my applications can inherit from, that is, all JavaMainWin's, JavaDialogBox's, etc., etc. Basically I need to extend the MoveableWin class in 4test. The reason for doing this is to give all my windows some common set of methods (exception handling, etc.)

    I have already attempted the below implementation though it does not seem to work. Let me explain ....

    1] I have the following windows for which I need to give them a data member called lsInvokedWindows and a set of methods to handle this list of windows.

    [window declarations]
    window JavaMainWin wMyMainAppWindow
    window JavaDialogBox wSomeDialogWindow

    2] So as these window classes inherit from MoveableWin class I decided to extend this class as follows

    [winclass extension]
    winclass MoveableWin : MoveableWin
    {
    list of window lsInvokedWindows

    void PushInvokedWindow(window wWnd)
    window PopInvokedWindow()
    etc.
    etc.
    }

    3] Now when this is compiled all seems fine, no compiler errors and the methods even appear extended to the MoveableWin class in the Library Browser. If you show inherited methods for the JavaMainWin class they also appear there too. So one would think that performing the following command would work ...

    [Call to inherited methods]
    wMyMainAppWindow.PushInvokedWindow(wSomeWindow)

    When compiled this will give th error ... PushInvokedWindow is not defined for window wMyMainAppWindow. I'm confessed ...

    4] Other attempt ... From this I attempted to play with the sequence in which the files got compiled, ensuring my extended class got compiled first, though no joy. Finally I lifted the methods from my extension and dropped them in the winclass.inc file, of course it worked then.

    [Question]
    Am I doing something wrong or can this even be done?

    Currently I've just created a class MyJavaMainWinClass (which inherits from JavaMainWin) and added the required methods. Of course this will only work for JavaMainWin objects. I can't keep creating a class for each class type?

    Can anyone Help?

    Thanks in advance
    Simon


  2. #2
    Junior Member
    Join Date
    Nov 2001
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HOW to extend 4test base classes ???

    Try calling your new method against each window class from MoveableWin to the one you want and see where the inheritence ends. Perhaps that will give you a clue. Also, double check the declarations (look for typos), and try closing and restarting silk after making your extensions one of the files that compiled when the product first loads.

    I know this works (or at least it used to for straight windows classes).

    JLm

  3. #3
    Senior Member
    Join Date
    Jul 1999
    Location
    Burlingame CA 94010
    Posts
    502
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HOW to extend 4test base classes ???

    Simon,

    If you create a class in your frame such as
    winclass MoveableWin : MoveableWin

    you are not really extending the class. What's actually happening is that you are creating a new class derived from MoveableableWin with the same name. Other classes which derive from MoveableWin derive from the base class in winclass.inc, not from your class. All MoveableWin objects in your frame, however, become instances of your derived class.

    In order to do what you want, you have to edit winclass.inc. This is not something Segue will recommend, and you need to rememeber that you will lose your modifications if you upgrade, but if you extend the class in winclass.inc, all derived classes will inherit your methods.

    Hope this helps

    John Green
    johnwgreen@hotmail.com

  4. #4
    Junior Member
    Join Date
    Jul 1999
    Location
    Austin, TX. USA
    Posts
    8
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HOW to extend 4test base classes ???

    This can be done without modifying the SilkTest 'Kernel' code (i.e modifing winclass.inc).

    You basically have to create a 'pseudo' parent class for JavaMainWin/JavaDialogBox, instantiate on object of the 'pseudo' class in your MainWin/DialogBox extended class (note you can not directly extend JavaMainWin/JavaDialogBox) and provide thin veneer methods in the extended classes that pass thru to the parent 'pseudo' class where the implementation lives.

    It is not a perfect solution, as you need to provide the thin veneers, but it does keep the implementation in 1 place.

    If you want the gorey details of how SilkTest compiles in the "code libraries" and why you can't extend MoveableWin class, send me email.

    ------------------
    Kendall Schmidt
    Vignette Corporation
    kschmidt@vignette.com
    Kendall Schmidt
    Vignette Corporation
    kschmidt@vignette.com

  5. #5
    Member
    Join Date
    Dec 1999
    Location
    Rochester, NY, USA
    Posts
    52
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HOW to extend 4test base classes ???

    I have used John Green's implementation. The way to get around the difficulty mentioned by John (modifying the core include files from Segue is dangerous in the least) is to establish a library that customizations can be drawn from. Then add the drive path to that library to the Options->Runtime->Use Path settings. After restarting Silk, the customizations will be in place, but Segue's code will be safe. Silk uses the Use Path for files FIRST, so winclass.inc in the library will be in effect and the Silk directory winclass.inc will be ignored.


    ------------------
    Andy Bachman
    Andy Bachman

  6. #6
    Senior Member
    Join Date
    Sep 1999
    Location
    San Jose,CA,USA
    Posts
    340
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: HOW to extend 4test base classes ???

    Simon
    I have also had my own problems in this area.
    When I called tech support they informed me that the Top two layers (AnyWin and Movable Win) do NOT lend themselves to inheritence the way you described. (As I do not need to do this too frequently I did not check on the other lower classes)


    As I wanted to extend the Movable window class myself I adapted precisely what
    Kendall Schmidt described.

    I think that this is the best technique and it took me a lot of thought to come up with it. I had a major parent class in a file called
    qamovablewindow.inc with something like this:

    winclass MoveableWin : MoveableWin
    {

    void _PushInvokedWindow(window self,window wWnd)
    window _PopInvokedWindow(window self)
    etc.
    etc.
    }

    You will note that your member variable
    "list of window lsInvokedWindows" is missing. You have to make this variable an instance of the classes that inherit from the Movable Window Class itself. That means that for each inherited class you have to create the member variables and method wrappers .. which is the drawback of this technique.

    Also notice that the FIRST parm is the "window self", this is always used to pass the "this" pointer of the Object that calls this class ( a self refferential pointer .. hence the term self).

    Now for the tricky bit, in order for your subclasses ChildWin,DialogBox and of course MainWin to inherit you have to do one kind of cheezy trick and instantiate a MoveableWin
    object like so (lets use MainWin as the example)

    file qamainwin.inc:
    // qamovablewindow.inc better be in your path
    use "qamovablewindow.inc"

    // instantiate a MovableWin Object
    window MoveableWin MW_MainWin

    winclass MainWin : MainWin
    {

    // actual member variables stuck here
    list of window lsInvokedWindows

    void PushInvokedWindow(window wWnd)
    MW_MainWin._PushInvokedWindow(this,wWnd)

    window PopInvokedWindow()
    return MW_MainWin._PopInvokedWindow(this)

    etc.
    etc.
    }

    As you can see the methods simply "wrap" your methods that are declared in the Main instance of the parent class MW_MainWin. Also note even methods that take no parms require the self parameter (as the first argument). This is a very important convention .. it will help you call the appropriate method of the Object you call from (if you need to) as well as member, and state variables such as your:
    "list of window lsInvokedWindows"

    Speaking of which
    Any referace to your member variable
    list of window lsInvokedWindows
    MUST be made via the passed this object which is parm self (i.e):
    _PopInvokedWindow(window self)
    :
    print(self.lsInvokedWindows[inx])


    I know this is tricky and horribly OOP .. but it does work. Also you don't deal with going into winclass.inc and hacking it up .. which in my opionion is an awfull thing to do.


    Try it I think you will like it.
    ------------------
    "Smoke me a kipper, I'll be back for breakfast!"
    Sincerely
    Richard Weth
    Sr. QA Engineer
    mailto:rick_weth@yahoo.com
    phone(408) 487-3846



    [This message has been edited by rick_weth (edited 12-19-1999).]
    Smoke me a kipper, I'll be back for breakfast!
    Sincerely
    Richard Weth
    Sr. QA Engineer

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 11:01 PM.

Copyright BetaSoft Inc.