diff -r 2a9601315dfc -r 98ccebc37403 javauis/lcdui_qt/tsrc/src/com/nokia/openlcdui/mt_uirobot/displayable/SendBackgroundTest.java --- a/javauis/lcdui_qt/tsrc/src/com/nokia/openlcdui/mt_uirobot/displayable/SendBackgroundTest.java Mon May 03 12:27:20 2010 +0300 +++ b/javauis/lcdui_qt/tsrc/src/com/nokia/openlcdui/mt_uirobot/displayable/SendBackgroundTest.java Fri May 14 15:47:24 2010 +0300 @@ -11,7 +11,7 @@ * * Contributors: * -* Description: +* Description: * */ package com.nokia.openlcdui.mt_uirobot.displayable; @@ -33,7 +33,8 @@ *
* Created: 2008-05-07 */ -public class SendBackgroundTest extends UITestBase { +public class SendBackgroundTest extends UITestBase +{ private static final int MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX = 100; private static final int SEND_BACKGROUND_DELAY = 300; @@ -42,8 +43,9 @@ /** * Constructor. */ - public SendBackgroundTest() { - super(); + public SendBackgroundTest() + { + super(); } /** @@ -52,51 +54,57 @@ * @param sTestName Test name. * @param rTestMethod Test method. */ - public SendBackgroundTest(String sTestName) { + public SendBackgroundTest(String sTestName) + { super(sTestName); } - public static Test suite() { + public static Test suite() + { TestSuite suite = new TestSuite(); java.util.Vector methodNames; - java.util.Enumeration e; + java.util.Enumeration e; - // Add widget tests - methodNames = SendBackgroundTest.methodNames(); - e = methodNames.elements(); - while (e.hasMoreElements()) { - suite.addTest(new SendBackgroundTest((String)e.nextElement())); - } - + // Add widget tests + methodNames = SendBackgroundTest.methodNames(); + e = methodNames.elements(); + while(e.hasMoreElements()) + { + suite.addTest(new SendBackgroundTest((String)e.nextElement())); + } + return suite; } - public static java.util.Vector methodNames() { + public static java.util.Vector methodNames() + { java.util.Vector methodNames = new java.util.Vector(); methodNames.addElement("testIsShownWhenBackground"); methodNames.addElement("testIsShownWhenNotCurrent"); methodNames.addElement("testGetHeightAndWidth"); return methodNames; } - - public void runTest() throws Throwable { - if (getName().equals("testIsShownWhenBackground")) testIsShownWhenBackground(); - else if (getName().equals("testIsShownWhenNotCurrent")) testIsShownWhenNotCurrent(); - else if (getName().equals("testGetHeightAndWidth")) testGetHeightAndWidth(); + + public void runTest() throws Throwable + { + if(getName().equals("testIsShownWhenBackground")) testIsShownWhenBackground(); + else if(getName().equals("testIsShownWhenNotCurrent")) testIsShownWhenNotCurrent(); + else if(getName().equals("testGetHeightAndWidth")) testGetHeightAndWidth(); else super.runTest(); - } + } /** * Test that isShown()-method returns false when displayable is in * background. */ - public void testIsShownWhenBackground() { + public void testIsShownWhenBackground() + { boolean testPassed = true; String testMsg = ""; TextBox textBox = new TextBox("title", "content", - MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); + MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); setCurrent(textBox); @@ -104,7 +112,8 @@ // returns false: key(Key.Applications, SEND_BACKGROUND_DELAY); - if (textBox.isShown()) { + if(textBox.isShown()) + { testPassed = false; testMsg = "isShown() returned true when MIDlet was in background."; } @@ -116,7 +125,8 @@ key(Key.Select, 0); key(Key.Select, SEND_FOREGROUND_DELAY); - if (!textBox.isShown()) { + if(!textBox.isShown()) + { testPassed = false; testMsg = "isShown() returned false when MIDlet was in foreground."; } @@ -128,18 +138,20 @@ * Tests that isShown() returns false if displayable is first set current * and then another displayable is set current. */ - public void testIsShownWhenNotCurrent() { + public void testIsShownWhenNotCurrent() + { boolean testPassed = true; String testMsg = ""; TextBox textBox = new TextBox("title", "content", - MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); + MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); TextBox textBox2 = new TextBox("title2", "content2", - MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); + MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); // First set displayable current and make sure it's shown: setCurrent(textBox); - if (!textBox.isShown()) { + if(!textBox.isShown()) + { testPassed = false; testMsg = "isShown() returned false when displayable current."; } @@ -148,7 +160,8 @@ // one isn't shown: setCurrent(textBox2); - if (textBox.isShown()) { + if(textBox.isShown()) + { testPassed = false; testMsg = "isShown() returned true when displayable isn't current."; } @@ -156,10 +169,11 @@ // Now move first displayable back to current and make sure // it knows it's shown: setCurrent(textBox); - if (!textBox.isShown()) { + if(!textBox.isShown()) + { testPassed = false; testMsg = "isShown() returned false when displayable set " - + " back to current."; + + " back to current."; } assertTrue(getName() + " failed, " + testMsg, testPassed); @@ -169,16 +183,17 @@ * Tests the functionality of getWidth() and getHeight()-methods when * displayable not current and when MIDlet is sent to background. */ - public void testGetHeightAndWidth() { + public void testGetHeightAndWidth() + { boolean testPassed = true; String testMsg = ""; int width = 0; int height = 0; TextBox textBox = new TextBox("title", "content", - MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); + MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); TextBox textBox2 = new TextBox("title2", "content2", - MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); + MAX_NUM_OF_CHARS_IN_TEST_TEXTBOX, 0); // Get initial values: width = textBox.getWidth(); @@ -187,23 +202,25 @@ // Set displayable to current and make sure the dimension isn't changed: setCurrent(textBox); - if ((textBox.getWidth() != width) || (textBox.getHeight() != height)) { + if((textBox.getWidth() != width) || (textBox.getHeight() != height)) + { testPassed = false; testMsg = "dimension changed after displayable set current:" - + " original w: " + width + " original h:" + height - + " new w: " + textBox.getWidth() + " new h: " - + textBox.getHeight(); + + " original w: " + width + " original h:" + height + + " new w: " + textBox.getWidth() + " new h: " + + textBox.getHeight(); } // Send MIDlet to background and verify that dimension remains same: key(Key.Applications, SEND_BACKGROUND_DELAY); - if ((textBox.getWidth() != width) || (textBox.getHeight() != height)) { + if((textBox.getWidth() != width) || (textBox.getHeight() != height)) + { testPassed = false; testMsg = "dimension changed after MIDlet sent to background:" - + " original w: " + width + " original h:" + height - + " new w: " + textBox.getWidth() + " new h: " - + textBox.getHeight(); + + " original w: " + width + " original h:" + height + + " new w: " + textBox.getWidth() + " new h: " + + textBox.getHeight(); } // Move MIDlet back to foreground: @@ -216,12 +233,13 @@ // of first displayable remains same: setCurrent(textBox2); - if ((textBox.getWidth() != width) || (textBox.getHeight() != height)) { + if((textBox.getWidth() != width) || (textBox.getHeight() != height)) + { testPassed = false; testMsg = "dimension changed after other displayable set current:" - + " original w: " + width + " original h:" + height - + " new w: " + textBox.getWidth() + " new h: " - + textBox.getHeight(); + + " original w: " + width + " original h:" + height + + " new w: " + textBox.getWidth() + " new h: " + + textBox.getHeight(); } assertTrue(getName() + " failed, " + testMsg, testPassed);