org.safs.rational
Class FlexUtil

java.lang.Object
  extended by org.safs.rational.FlexUtil

public class FlexUtil
extends java.lang.Object


Purpose: Support Flex applications providing common methods for calling. The format of the R-String for top Flex applicaiton: "Type=FlexApplication;Caption={***.swf}" ***.swf is flex applicaiton's file name.

Since:
OCT 07 2008 Original Release OCT 27 2008 (JunwuMa) Added getName(TestObject), getTextOfFlexMenuItem(TestObject). Added method getMatchingPathObject(TestObject,String) for identifying Flex menu object according to the Path information. DEC 12 2008 (JunwuMa) Modify method drillDownRealFlexObj to fit in the changes of Flex runtime classLoader that is built with RFT8. Flex support in RFT8 is better than in RFT7. Methods getObjectClassName and GetChildren are NO need to be used any more in RFT8. JAN 14 2009 (JunwuMa) Add method getMatchingMenuFromMenuBar(), dig in a Flex menu bar to find out the corresponding menu inside it. JAN 20 2009 (JunwuMa) Add method doSelectMenubar for being evoked from CFComponent and CFFlexMenuBar. MAY 31 2009 (JunwuMa) Update drillDownRealFlexObj() for finding out the FlexApplication not loaded by runtime loader. SEP 18 2009 (JunwuMa) Updates to adapt drillDownRealFlexObj() to more SWFLoaders including SAS-defined SWFLoader.
See Also:
and FlexUtil#getCaption

Field Summary
static java.lang.String FLEX_APP_NAME
           
static java.lang.String FLEX_MENU_CLASSNAME
           
static java.lang.String FLEX_MENUBAR_CLASSNAME
           
static java.lang.String FLEX_MENUITEMRENDERER_CLASSNAME
           
static java.lang.String FLEX_RUNTIMELOADER_PREFIX
           
static java.lang.String FLEX_RUNTIMELOADING_NAME
           
static java.lang.String FLEX_SWFLOADER_CLASSNAME
           
static java.lang.String FLEX_SWFLOADER_CLASSNAME_SUFFIX
           
static java.lang.String PROPERTY_TYPE_AUTOMATIONCLASSNAME
           
static java.lang.String PROPERTY_TYPE_AUTOMATIONNAME
           
static java.lang.String PROPERTY_TYPE_CLASSNAME
           
static java.lang.String PROPERTY_TYPE_NUMAUTOMATIONCHILDREN
           
 
Constructor Summary
FlexUtil()
           
 
Method Summary
static void doSelectMenubar(TestObject menuObj, java.lang.String menuItemPath)
          Purpose: Perform a select operation on Flex menu items.
static TestObject drillDownRealFlexObj(TestObject flexObj)
          Automated testing of Flex applications requires users to load supporting files in two different ways: 1) At compile-time for applications that are enabled for RFT 2) At run-time for applications that are not enabled for RFT For the second way, the top flex window returned by getTopObjects() on Flex domain object, is a Flex runtimeloading object not the real application loaded.
static java.lang.String getCaption(TestObject flexObj)
          Take property 'automationName' of the top Flex application (FlexApplicationTestObject) as Caption, although there is no caption for a flex application.
static TestObject[] getChildren(TestObject obj)
          Called by RGuiObjectVector#getChildren for solving duplicate object problem.
static FlexObjectTestObject getMatchingMenuFromMenuBar(TestObject flexmenuBar, java.lang.String menuItemPath)
          Purpose: Dig in a Flex menu bar to find out the corresponding menu inside it according menu path.
static FlexObjectTestObject getMatchingPathObject(java.lang.Object flexmenuBar, java.lang.String path)
          Retrieves the resulting object identified with the Path information applied to flexmenuBar.
static java.lang.String getName(TestObject flexObj)
           
static java.lang.String getObjectClassName(TestObject flexObj)
          returns the class name for FlexObjectTestObject.
static java.lang.String getTextOfFlexMenuItem(TestObject flexObj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLEX_APP_NAME

public static final java.lang.String FLEX_APP_NAME
See Also:
Constant Field Values

FLEX_RUNTIMELOADING_NAME

public static final java.lang.String FLEX_RUNTIMELOADING_NAME
See Also:
Constant Field Values

FLEX_RUNTIMELOADER_PREFIX

public static final java.lang.String FLEX_RUNTIMELOADER_PREFIX
See Also:
Constant Field Values

FLEX_SWFLOADER_CLASSNAME_SUFFIX

public static final java.lang.String FLEX_SWFLOADER_CLASSNAME_SUFFIX
See Also:
Constant Field Values

FLEX_SWFLOADER_CLASSNAME

public static final java.lang.String FLEX_SWFLOADER_CLASSNAME
See Also:
Constant Field Values

FLEX_MENUBAR_CLASSNAME

public static final java.lang.String FLEX_MENUBAR_CLASSNAME
See Also:
Constant Field Values

FLEX_MENU_CLASSNAME

public static final java.lang.String FLEX_MENU_CLASSNAME
See Also:
Constant Field Values

FLEX_MENUITEMRENDERER_CLASSNAME

public static final java.lang.String FLEX_MENUITEMRENDERER_CLASSNAME
See Also:
Constant Field Values

PROPERTY_TYPE_AUTOMATIONCLASSNAME

public static final java.lang.String PROPERTY_TYPE_AUTOMATIONCLASSNAME
See Also:
Constant Field Values

PROPERTY_TYPE_CLASSNAME

public static final java.lang.String PROPERTY_TYPE_CLASSNAME
See Also:
Constant Field Values

PROPERTY_TYPE_AUTOMATIONNAME

public static final java.lang.String PROPERTY_TYPE_AUTOMATIONNAME
See Also:
Constant Field Values

PROPERTY_TYPE_NUMAUTOMATIONCHILDREN

public static final java.lang.String PROPERTY_TYPE_NUMAUTOMATIONCHILDREN
See Also:
Constant Field Values
Constructor Detail

FlexUtil

public FlexUtil()
Method Detail

drillDownRealFlexObj

public static TestObject drillDownRealFlexObj(TestObject flexObj)
Automated testing of Flex applications requires users to load supporting files in two different ways: 1) At compile-time for applications that are enabled for RFT 2) At run-time for applications that are not enabled for RFT For the second way, the top flex window returned by getTopObjects() on Flex domain object, is a Flex runtimeloading object not the real application loaded. See the hierarchy of a Flex application loaded by Flex runtime-loading. Flex runtimeloading object ----- top flex window returned by RFT / \ / \ FlexLoader Flex object ----- the Real Flex object loaded in RFT8 / / Flex object ------ no this object in RFT8 (different from in RFT7) Purpose: Drill down a top FlexApplicationTestObject finding out the real Flex application loaded. Only the second loading way is considered. The first loading way will be considered later...

Parameters:
flexObj, - top FlexApplicationTestObject
Returns:
an object(FlexApplicationTestObject) that is the real Flex application

getCaption

public static java.lang.String getCaption(TestObject flexObj)
Take property 'automationName' of the top Flex application (FlexApplicationTestObject) as Caption, although there is no caption for a flex application. See a top flex window's R-String: "Type=FlexApplcaiton;Caption={FlexWebDemo.swf}" The unique file name is taken as caption to identify different Flex application. This caption format is consistent with it used to be in Java, DotNet, Html...

Parameters:
flexObj, - a FlexObjectTestObject
Returns:
its caption

getName

public static java.lang.String getName(TestObject flexObj)

getTextOfFlexMenuItem

public static java.lang.String getTextOfFlexMenuItem(TestObject flexObj)

getObjectClassName

public static java.lang.String getObjectClassName(TestObject flexObj)
returns the class name for FlexObjectTestObject. For top Flex application whatever its file name is, its automationClassName is 'FlexApplication'. it can be taken as the UNIQUE class type for identifying top flex window. See a R-String for a top flex window like "Type=FlexApplication;Caption=...."

Parameters:
flexObj, - a FlexObjectTestObject
Returns:
class name

getChildren

public static TestObject[] getChildren(TestObject obj)
Called by RGuiObjectVector#getChildren for solving duplicate object problem. In the hierarchy of Flex software under test, a container's child objects can be unexpectedly listed by calling getChildren on the container's parent. These child objects are duplicated. The duplicate can be solved by using property numAutomationChildren and method getAutomationChildAt(int), which returns the real child objects that belong to the Flex container.

Parameters:
obj, - FlexObjectTestObject
Returns:
array of TestObjects or an empty array of new TestObject[0].

getMatchingPathObject

public static FlexObjectTestObject getMatchingPathObject(java.lang.Object flexmenuBar,
                                                         java.lang.String path)
Retrieves the resulting object identified with the Path information applied to flexmenuBar. Called by RGuiObjectRecognition.getMatchingPathObject(Object, String). In R-String "Type=FlexMenuBar;index=1;Path=File->Exit", mx.controls.Menu matches 'File'; mx.controls.menuClasses.MenuItemRenderer matches 'Exit'.

Parameters:
flexmenuBar, - a FlexMenuBarTestObject (not considering FlexTreeTestObject)
path -
Returns:
a FlexObjectTestObject that matches the path.

getMatchingMenuFromMenuBar

public static FlexObjectTestObject getMatchingMenuFromMenuBar(TestObject flexmenuBar,
                                                              java.lang.String menuItemPath)
Purpose: Dig in a Flex menu bar to find out the corresponding menu inside it according menu path.

Parameters:
flexmenuBar -
menuItemPath -
Returns:
a FlexMenuTestObject (the corresponding menu)

doSelectMenubar

public static void doSelectMenubar(TestObject menuObj,
                                   java.lang.String menuItemPath)
                            throws SAFSException
Purpose: Perform a select operation on Flex menu items.

Parameters:
menuObj, - a FlexMenuBarTestObject
menuItemPath, - menu path like "File->Open"
Throws:
SAFSException, - thrown while the operation failed
SAFSException