javauis/lcdui_qt/tsrc/src/com/nokia/openlcdui/mt_uirobot/form/FormItemTest.java
changeset 23 98ccebc37403
parent 21 2a9601315dfc
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: 
    14 * Description:
    15 *
    15 *
    16 */
    16 */
    17 package com.nokia.openlcdui.mt_uirobot.form;
    17 package com.nokia.openlcdui.mt_uirobot.form;
    18 
    18 
    19 import junit.framework.*;
    19 import junit.framework.*;
    31  * <li> UI-robot based test to test item-related form functionality,
    31  * <li> UI-robot based test to test item-related form functionality,
    32  * for example adding and removing items to form. <br>
    32  * for example adding and removing items to form. <br>
    33  * <br>
    33  * <br>
    34  * Created: 2008-11-12
    34  * Created: 2008-11-12
    35  */
    35  */
    36 public class FormItemTest extends ItemUITestBase {
    36 public class FormItemTest extends ItemUITestBase
       
    37 {
    37 
    38 
    38     /**
    39     /**
    39      * Constructor.
    40      * Constructor.
    40      */
    41      */
    41     public FormItemTest() {
    42     public FormItemTest()
    42     	super();
    43     {
       
    44         super();
    43     }
    45     }
    44 
    46 
    45     /**
    47     /**
    46      * Constructor.
    48      * Constructor.
    47      *
    49      *
    48      * @param sTestName Test name.
    50      * @param sTestName Test name.
    49      * @param rTestMethod Test method.
    51      * @param rTestMethod Test method.
    50      */
    52      */
    51     public FormItemTest(String sTestName) {
    53     public FormItemTest(String sTestName)
       
    54     {
    52         super(sTestName);
    55         super(sTestName);
    53     }
    56     }
    54 
    57 
    55     public static Test suite() {
    58     public static Test suite()
       
    59     {
    56         TestSuite suite = new TestSuite();
    60         TestSuite suite = new TestSuite();
    57 
    61 
    58         java.util.Vector methodNames;
    62         java.util.Vector methodNames;
    59 	    java.util.Enumeration e;
    63         java.util.Enumeration e;
    60 
    64 
    61 	    // Add widget tests
    65         // Add widget tests
    62 	    methodNames = FormItemTest.methodNames();
    66         methodNames = FormItemTest.methodNames();
    63 	    e = methodNames.elements();
    67         e = methodNames.elements();
    64 	    while (e.hasMoreElements()) {
    68         while(e.hasMoreElements())
    65 	        suite.addTest(new FormItemTest((String)e.nextElement()));
    69         {
    66 	    }
    70             suite.addTest(new FormItemTest((String)e.nextElement()));
    67         
    71         }
       
    72 
    68         return suite;
    73         return suite;
    69     }
    74     }
    70 
    75 
    71     public static java.util.Vector methodNames() {
    76     public static java.util.Vector methodNames()
       
    77     {
    72         java.util.Vector methodNames = new java.util.Vector();
    78         java.util.Vector methodNames = new java.util.Vector();
    73         methodNames.addElement("testAppendItemAfterSetCurrent");
    79         methodNames.addElement("testAppendItemAfterSetCurrent");
    74         methodNames.addElement("testRemoveCommandFromLabeledFocusedItem");
    80         methodNames.addElement("testRemoveCommandFromLabeledFocusedItem");
    75         methodNames.addElement("testAddRemoveItems");
    81         methodNames.addElement("testAddRemoveItems");
    76         methodNames.addElement("testRemoveItemsWhenBackground");
    82         methodNames.addElement("testRemoveItemsWhenBackground");
    77         return methodNames;
    83         return methodNames;
    78     }
    84     }
    79     
    85 
    80     public void runTest() throws Throwable {
    86     public void runTest() throws Throwable
    81         if (getName().equals("testAppendItemAfterSetCurrent")) testAppendItemAfterSetCurrent();
    87     {
    82         else if (getName().equals("testRemoveCommandFromLabeledFocusedItem")) testRemoveCommandFromLabeledFocusedItem();
    88         if(getName().equals("testAppendItemAfterSetCurrent")) testAppendItemAfterSetCurrent();
    83         else if (getName().equals("testAddRemoveItems")) testAddRemoveItems();
    89         else if(getName().equals("testRemoveCommandFromLabeledFocusedItem")) testRemoveCommandFromLabeledFocusedItem();
    84         else if (getName().equals("testRemoveItemsWhenBackground")) testRemoveItemsWhenBackground();
    90         else if(getName().equals("testAddRemoveItems")) testAddRemoveItems();
       
    91         else if(getName().equals("testRemoveItemsWhenBackground")) testRemoveItemsWhenBackground();
    85         else super.runTest();
    92         else super.runTest();
    86     }    
    93     }
    87     
    94 
    88 
    95 
    89     /**
    96     /**
    90      * Tests to remove command from focused item which has label and
    97      * Tests to remove command from focused item which has label and
    91      * verifies that focus is moved to next/previous focusable item.
    98      * verifies that focus is moved to next/previous focusable item.
    92      */
    99      */
    93     public void testRemoveCommandFromLabeledFocusedItem() {
   100     public void testRemoveCommandFromLabeledFocusedItem()
       
   101     {
    94         StringItem button1 = new StringItem("label", "click!", Item.BUTTON);
   102         StringItem button1 = new StringItem("label", "click!", Item.BUTTON);
    95         StringItem button2 = new StringItem("label", "click2!", Item.BUTTON);
   103         StringItem button2 = new StringItem("label", "click2!", Item.BUTTON);
    96 
   104 
    97         Command c1 = new Command("Ok1", "", Command.ITEM, 0);
   105         Command c1 = new Command("Ok1", "", Command.ITEM, 0);
    98         Command c2 = new Command("Ok2", "", Command.ITEM, 0);
   106         Command c2 = new Command("Ok2", "", Command.ITEM, 0);
   127     }
   135     }
   128 
   136 
   129     /**
   137     /**
   130      * Tests to add and remove items to/from form.
   138      * Tests to add and remove items to/from form.
   131      */
   139      */
   132     public void testAddRemoveItems() {
   140     public void testAddRemoveItems()
       
   141     {
   133         Command ok1 = new Command("Ok1", "", Command.ITEM, 0);
   142         Command ok1 = new Command("Ok1", "", Command.ITEM, 0);
   134         Command ok2 = new Command("Ok2", "", Command.ITEM, 0);
   143         Command ok2 = new Command("Ok2", "", Command.ITEM, 0);
   135 
   144 
   136         Form form2 = new Form("form2");
   145         Form form2 = new Form("form2");
   137         StringItem button1 = new StringItem(null, "button1", StringItem.BUTTON);
   146         StringItem button1 = new StringItem(null, "button1", StringItem.BUTTON);
   169 
   178 
   170     /**
   179     /**
   171      * Tests to append item to form after form is set current. Then
   180      * Tests to append item to form after form is set current. Then
   172      * verifies the focus transfer works.
   181      * verifies the focus transfer works.
   173      */
   182      */
   174     public void testAppendItemAfterSetCurrent() {
   183     public void testAppendItemAfterSetCurrent()
       
   184     {
   175         StringItem hyperlink = new StringItem("label", "url",
   185         StringItem hyperlink = new StringItem("label", "url",
   176                 StringItem.HYPERLINK);
   186                                               StringItem.HYPERLINK);
   177         StringItem button1 = new StringItem(null, "button1",
   187         StringItem button1 = new StringItem(null, "button1",
   178                 StringItem.BUTTON);
   188                                             StringItem.BUTTON);
   179 
   189 
   180         Command dummyCommand = new Command("dummy", "", Command.ITEM, 0);
   190         Command dummyCommand = new Command("dummy", "", Command.ITEM, 0);
   181         button1.addCommand(dummyCommand);
   191         button1.addCommand(dummyCommand);
   182 
   192 
   183         Command ok = new Command("Ok", "", Command.ITEM, 0);
   193         Command ok = new Command("Ok", "", Command.ITEM, 0);
   205     }
   215     }
   206 
   216 
   207     /**
   217     /**
   208      * Test that command are working properly in case of
   218      * Test that command are working properly in case of
   209      */
   219      */
   210     public void testRemoveItemsWhenBackground() {
   220     public void testRemoveItemsWhenBackground()
   211         Form forma = new Form ("Form A");
   221     {
   212         Form formb = new Form ("Form B");
   222         Form forma = new Form("Form A");
       
   223         Form formb = new Form("Form B");
   213         Command dummyCommand1 = new Command("dummy1", "", Command.ITEM, 0);
   224         Command dummyCommand1 = new Command("dummy1", "", Command.ITEM, 0);
   214         Command dummyCommand2 = new Command("dummy2", "", Command.ITEM, 0);
   225         Command dummyCommand2 = new Command("dummy2", "", Command.ITEM, 0);
   215         Command dummyCommand3 = new Command("dummy3", "", Command.ITEM, 0);
   226         Command dummyCommand3 = new Command("dummy3", "", Command.ITEM, 0);
   216         Command dummyCommand4 = new Command("dummy4", "", Command.ITEM, 0);
   227         Command dummyCommand4 = new Command("dummy4", "", Command.ITEM, 0);
   217         Gauge g1 = new Gauge("Gauge1", true, 10, 0);
   228         Gauge g1 = new Gauge("Gauge1", true, 10, 0);