""" GUI Automated Testing This module contains base class of all components. """ __author__ = "Lukas Cenovsky (lukas.cenovsky@bakalari.cz)" __version__ = "0.1" __date__ = "July 2008" __copyright__ = "Copyright (c) 2008 Lukas Cenovsky" class BaseComponent(object): """ base class holding common properties and methods for all components """ # the following methods are considered private def __init__(self, aControl, aGUIAT): """ BaseComponent constructor @aControl - .NET component object @aGUIAT - GUIAT main object """ # component name try: self._name = aControl.Name except Exception: # some components do not have Name self._name = '-' # .NET component object self._control = aControl # GUIAT main object self._guiat = aGUIAT # dictionary of all child objects {'GUIAT object name': } self._guiatComponents = {} def _GetComponentByName(self, aName): """ return the GUIAT object with the given name or None @aName - name of the component """ if self._name == aName: return self for c in self._guiatComponents.values(): res = c._GetComponentByName(aName) if res: return res return None def _GetLocation(self): """ return location of the component (left, top, width, height) """ cr = self._control.RectangleToScreen(self._control.ClientRectangle) return (cr.Left, cr.Top, cr.Width, cr.Height) # properties location = property(_GetLocation, doc="location of the component: (left, top, width, height) {R}")