--- a/javauis/lcdui_qt/tsrc/src/com/nokia/openlcdui/mt/font/FontTest.java Mon May 03 12:27:20 2010 +0300
+++ b/javauis/lcdui_qt/tsrc/src/com/nokia/openlcdui/mt/font/FontTest.java Fri May 14 15:47:24 2010 +0300
@@ -11,7 +11,7 @@
*
* Contributors:
*
-* Description:
+* Description:
*
*/
package com.nokia.openlcdui.mt.font;
@@ -28,14 +28,16 @@
* <li>Collection of tests to test Font's functionality. <br>
* <br>
*/
-public class FontTest extends SWTTestCase {
+public class FontTest extends SWTTestCase
+{
private static String shortString = "Lorem ipsum";
/**
* Constructor.
*/
- public FontTest() {
+ public FontTest()
+ {
}
/**
@@ -44,7 +46,8 @@
* @param sTestName Test name.
* @param rTestMethod Test method.
*/
- public FontTest(String sTestName) {
+ public FontTest(String sTestName)
+ {
super(sTestName);
}
@@ -53,47 +56,54 @@
*
* @return New TestSuite.
*/
- public static Test suite() {
- TestSuite suite = new TestSuite();
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite();
- java.util.Vector methodNames;
- java.util.Enumeration e;
+ java.util.Vector methodNames;
+ java.util.Enumeration e;
- // Add widget tests
- methodNames = FontTest.methodNames();
- e = methodNames.elements();
- while (e.hasMoreElements()) {
- suite.addTest(new FontTest((String)e.nextElement()));
- }
+ // Add widget tests
+ methodNames = FontTest.methodNames();
+ e = methodNames.elements();
+ while(e.hasMoreElements())
+ {
+ suite.addTest(new FontTest((String)e.nextElement()));
+ }
- return suite;
+ return suite;
}
- public static java.util.Vector methodNames() {
+ public static java.util.Vector methodNames()
+ {
java.util.Vector methodNames = new java.util.Vector();
methodNames.addElement("testConstructors");
methodNames.addElement("testAccessors");
return methodNames;
}
-
- protected void runTest() throws Throwable {
- if (getName().equals("testConstructors")) testConstructors();
- else if (getName().equals("testAccessors")) testAccessors();
+
+ protected void runTest() throws Throwable
+ {
+ if(getName().equals("testConstructors")) testConstructors();
+ else if(getName().equals("testAccessors")) testAccessors();
else super.runTest();
}
-
-
+
+
/**
* Test method.
*/
- public void testConstructors() {
+ public void testConstructors()
+ {
Font.getDefaultFont();
- try {
+ try
+ {
Font.getFont(-1);
fail("1. IllegalArgumentException should be thrown");
}
- catch (IllegalArgumentException iae) {
+ catch(IllegalArgumentException iae)
+ {
// OK
}
@@ -101,35 +111,43 @@
Font.getFont(Font.FONT_INPUT_TEXT);
- try {
+ try
+ {
Font.getFont(2);
fail("2. IllegalArgumentException should be thrown");
}
- catch (IllegalArgumentException iae) {
+ catch(IllegalArgumentException iae)
+ {
// OK
}
- try {
+ try
+ {
Font.getFont(-1, 0, 0);
fail("3. IllegalArgumentException should be thrown");
}
- catch (IllegalArgumentException iae) {
+ catch(IllegalArgumentException iae)
+ {
// OK
}
- try {
+ try
+ {
Font.getFont(0, -1, 0);
fail("4. IllegalArgumentException should be thrown");
}
- catch (IllegalArgumentException iae) {
+ catch(IllegalArgumentException iae)
+ {
// OK
}
- try {
+ try
+ {
Font.getFont(0, 0, -1);
fail("5. IllegalArgumentException should be thrown");
}
- catch (IllegalArgumentException iae) {
+ catch(IllegalArgumentException iae)
+ {
// OK
}
}
@@ -137,18 +155,20 @@
/**
* Test method.
*/
- public void testAccessors() {
+ public void testAccessors()
+ {
Font font = Font.getDefaultFont();
assertNotNull("Default font shouldn't be null", font);
assertTrue("Default font height shouldn't be null",
- font.getHeight() != 0);
+ font.getHeight() != 0);
int prevWidth = -1;
- for (int i = 0; i < shortString.length(); i++) {
+ for(int i = 0; i < shortString.length(); i++)
+ {
int witdh = font.substringWidth(shortString, 0, i);
assertTrue("String width should increase width at pos " + i,
- (witdh > prevWidth));
+ (witdh > prevWidth));
prevWidth = witdh;
}
}