[Libreoffice-commits] .: bean/com bean/qa testgraphical/ui test/source
Julien Nabet
serval2412 at kemper.freedesktop.org
Sun Aug 14 16:58:26 PDT 2011
bean/com/sun/star/beans/LocalOfficeConnection.java | 6
bean/qa/complex/bean/OOoBeanTest.java | 54 +++-----
test/source/java/org/openoffice/test/OfficeConnection.java | 2
testgraphical/ui/java/ConvwatchGUIProject/src/IniFile.java | 85 +------------
4 files changed, 37 insertions(+), 110 deletions(-)
New commits:
commit cf4e20ede906dd7aaab5251083041185c4b35a9e
Author: Julien Nabet <serval2412 at yahoo.fr>
Date: Mon Aug 15 01:58:04 2011 +0200
Some PMD cleaning
diff --git a/bean/com/sun/star/beans/LocalOfficeConnection.java b/bean/com/sun/star/beans/LocalOfficeConnection.java
index 1128306..fc098c3 100644
--- a/bean/com/sun/star/beans/LocalOfficeConnection.java
+++ b/bean/com/sun/star/beans/LocalOfficeConnection.java
@@ -179,7 +179,7 @@ public class LocalOfficeConnection
public void dispose()
{
Iterator itr = mComponents.iterator();
- while (itr.hasNext() == true) {
+ while (itr.hasNext()) {
// ignore runtime exceptions in dispose
try { ((XEventListener)itr.next()).disposing(null); }
catch ( RuntimeException aExc ) {}
@@ -462,12 +462,12 @@ public class LocalOfficeConnection
case ';':
idx -= 1; // put back the last read character
state = 5;
- if (name.equals("path")) {
+ if (("path").equals(name)) {
if (path == null)
path = buffer.toString();
else
state = -3; // error: more then one 'path'
- } else if (name.equals("pipe")) {
+ } else if (("pipe").equals(name)) {
if (pipe == null)
pipe = buffer.toString();
else
diff --git a/bean/qa/complex/bean/OOoBeanTest.java b/bean/qa/complex/bean/OOoBeanTest.java
index 69c63e1..74db38d 100644
--- a/bean/qa/complex/bean/OOoBeanTest.java
+++ b/bean/qa/complex/bean/OOoBeanTest.java
@@ -77,8 +77,7 @@ public class OOoBeanTest
*/
private int getSleepTime(int time)
{
- int ret = time;
- if (isWindows() == false)
+ if (!isWindows())
{
return time * 5;
}
@@ -146,7 +145,7 @@ public class OOoBeanTest
try
{
f = new WriterFrame(100, 100, 500,500, false, connection.getComponentContext());
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error: Client are of Java frame does not match the UNO window.");
}
@@ -162,18 +161,18 @@ public class OOoBeanTest
capturer.grabOne(f.getClientArea());
f.setExtendedState(Frame.ICONIFIED);
Thread.sleep(getSleepTime(200));
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error: Frame was iconified.");
}
f.setExtendedState(Frame.NORMAL);
Thread.sleep(getSleepTime(200));
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error: Frame size set back to normal after it was iconified.");
}
capturer.grabTwo(f.getClientArea());
- if (capturer.compare() == false)
+ if (!capturer.compare())
{
fail("Painting error: Minimize (iconify) frame and back to normal size.");
capturer.writeImages();
@@ -187,18 +186,18 @@ public class OOoBeanTest
capturer.grabOne(f.getClientArea());
f.setExtendedState(Frame.MAXIMIZED_BOTH);
Thread.sleep(getSleepTime(200));
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error: Frame maximized.");
}
f.setExtendedState(Frame.NORMAL);
Thread.sleep(getSleepTime(200));
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error: Frame set from maximized to normal.");
}
capturer.grabTwo(f.getClientArea());
- if (capturer.compare() == false)
+ if (!capturer.compare())
{
fail("Painting error: Maximize frame and back to normal size");
capturer.writeImages();
@@ -211,13 +210,13 @@ public class OOoBeanTest
Rectangle oldPosition = f.getBounds();
f.setBounds(0, 0, oldPosition.width, oldPosition.height);
Thread.sleep(getSleepTime(200));
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error: Frame moved.");
}
capturer.grabTwo(f.getClientArea());
- if (capturer.compare() == false)
+ if (!capturer.compare())
{
fail("Painting error: Move frame to a different position.");
capturer.writeImages();
@@ -235,7 +234,7 @@ public class OOoBeanTest
oldPosition = f.getBounds();
f.setBounds(0, curY, oldPosition.width, oldPosition.height);
capturer.grabTwo(f.getClientArea());
- if (capturer.compare() == false)
+ if (!capturer.compare())
{
fail("Painting error: Move frame to a different position.");
capturer.writeImages();
@@ -261,13 +260,13 @@ public class OOoBeanTest
Thread.sleep(getSleepTime(200));
f.toFront();
Thread.sleep(getSleepTime(200));
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error: Frame moved from back to front.");
}
capturer.grabTwo(f.getClientArea());
- if (capturer.compare() == false)
+ if (!capturer.compare())
{
fail("Painting error: Move frame to back and to front.");
capturer.writeImages();
@@ -299,7 +298,7 @@ public class OOoBeanTest
try
{
f = new WriterFrame(100, 100, 500, 300, true, connection.getComponentContext());
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error.");
}
@@ -330,7 +329,7 @@ public class OOoBeanTest
b.releaseSystemWindow();
b.aquireSystemWindow();
}
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error.");
}
@@ -341,7 +340,7 @@ public class OOoBeanTest
{
f.dispose();
}
- if (isWindows() == false)
+ if (!isWindows())
{
Thread.sleep(10000);
}
@@ -375,14 +374,14 @@ public class OOoBeanTest
Thread.sleep(getSleepTime(200));
capturer.grabTwo();
- if (capturer.compare() == false)
+ if (!capturer.compare())
{
fail("Painting error: adding and removing OOoBean " +
"repeatedly to java.lang.Frame.");
capturer.writeImages();
}
- if (f.checkUnoFramePosition() == false)
+ if (!f.checkUnoFramePosition())
{
fail("Sizing error.");
}
@@ -394,7 +393,7 @@ public class OOoBeanTest
{
f.dispose();
}
- if (isWindows() == false)
+ if (!isWindows())
{
Thread.sleep(10000);
}
@@ -428,17 +427,13 @@ public class OOoBeanTest
StringBuffer buf = new StringBuffer(1000);
for (int i = 0; i < 1; i++)
{
-// Thread.sleep(1000);
bean.releaseSystemWindow();
frame.remove(bean);
-// frame.validate();
-// Thread.sleep(1000);
frame.add(bean, BorderLayout.CENTER);
bean.aquireSystemWindow();
-// frame.validate();
}
- if (isWindows() == false)
+ if (!isWindows())
{
Thread.sleep(5000);
}
@@ -532,7 +527,7 @@ public class OOoBeanTest
Thread.sleep(1000);
}
- if (isWindows() == false)
+ if (!isWindows())
{
Thread.sleep(5000);
}
@@ -549,7 +544,7 @@ public class OOoBeanTest
roby.keyRelease(KeyEvent.VK_H);
roby.waitForIdle();
- buf.append("h");
+ buf.append('h');
Thread.sleep(1000);
String s = getText(bean);
System.out.println(" getText: " + s);
@@ -610,7 +605,7 @@ public class OOoBeanTest
f.goToStart();
f.validate();
- if (text.equals(f.getText()) == false)
+ if (!text.equals(f.getText()))
{
fail("Repeated loading of a document failed.");
}
@@ -712,8 +707,7 @@ public class OOoBeanTest
private XMultiServiceFactory getMSF()
{
- final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
- return xMSF1;
+ return(UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()));
}
// setup and close connections
diff --git a/test/source/java/org/openoffice/test/OfficeConnection.java b/test/source/java/org/openoffice/test/OfficeConnection.java
index 4cc59a2..8cd2967 100644
--- a/test/source/java/org/openoffice/test/OfficeConnection.java
+++ b/test/source/java/org/openoffice/test/OfficeConnection.java
@@ -70,7 +70,7 @@ public final class OfficeConnection {
String envArg = Argument.get("env");
if (envArg != null) {
Map<String, String> env = pb.environment();
- int i = envArg.indexOf("=");
+ int i = envArg.indexOf('=');
if (i == -1) {
env.remove(envArg);
} else {
diff --git a/testgraphical/ui/java/ConvwatchGUIProject/src/IniFile.java b/testgraphical/ui/java/ConvwatchGUIProject/src/IniFile.java
index 324509d..078aec9 100644
--- a/testgraphical/ui/java/ConvwatchGUIProject/src/IniFile.java
+++ b/testgraphical/ui/java/ConvwatchGUIProject/src/IniFile.java
@@ -87,7 +87,7 @@ public class IniFile implements Enumeration
public void insertFirstComment(String[] _aList)
{
- if (m_aList.size() == 0)
+ if (m_aList.isEmpty())
{
// can only insert if there is nothing else already in the ini file
for (int i = 0; i < _aList.length; i++)
@@ -224,7 +224,7 @@ public class IniFile implements Enumeration
{
continue;
}
- if (sFindSection.equals("[]"))
+ if (("[]").equals(sFindSection))
{
// special case, empty Section.
return i - 1;
@@ -285,7 +285,7 @@ public class IniFile implements Enumeration
break;
}
- int nEqual = sLine.indexOf("=");
+ int nEqual = sLine.indexOf('=');
if (nEqual >= 0)
{
String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
@@ -318,7 +318,7 @@ public class IniFile implements Enumeration
return j;
}
- int nEqual = sLine.indexOf("=");
+ int nEqual = sLine.indexOf('=');
if (nEqual >= 0)
{
String sKey = toLowerIfNeed(sLine.substring(0, nEqual).trim());
@@ -338,12 +338,10 @@ public class IniFile implements Enumeration
{
return "";
}
- int nEqual = sLine.indexOf("=");
+ int nEqual = sLine.indexOf('=');
if (nEqual >= 0)
{
- String sKey = sLine.substring(0, nEqual).trim();
- String sValue = sLine.substring(nEqual + 1).trim();
- return sValue;
+ return(sLine.substring(nEqual + 1).trim());
}
return "";
}
@@ -357,7 +355,6 @@ public class IniFile implements Enumeration
// private String m_sOldKey;
public String getValue(String _sSection, String _sKey)
{
- String sValue = "";
int m_nCurrentPosition = findKey(_sSection, _sKey);
if (m_nCurrentPosition == -1)
{
@@ -365,22 +362,10 @@ public class IniFile implements Enumeration
return "";
}
- // m_sOldKey = _sKey;
- sValue = getValue(m_nCurrentPosition);
+ return(getValue(m_nCurrentPosition));
- return sValue;
}
-// private String getNextValue()
-// {
-// if (m_nCurrentPosition >= 0)
-// {
-// ++m_nCurrentPosition;
-// String sValue = getValue(m_nCurrentPosition);
-// return sValue;
-// }
-// return "";
-// }
/**
* Returns the value at Section, Key converted to an integer
* Check with hasValue(Section, Key) to check before you get into trouble.
@@ -397,7 +382,7 @@ public class IniFile implements Enumeration
{
try
{
- nValue = Integer.valueOf(sValue).intValue();
+ nValue = Integer.parseInt(sValue);
}
catch (java.lang.NumberFormatException e)
{
@@ -424,7 +409,7 @@ public class IniFile implements Enumeration
// TODO: make private
private void store()
{
- if (m_bListContainUnsavedChanges == false)
+ if (!m_bListContainUnsavedChanges)
{
// nothing has changed, so no need to store
return;
@@ -537,59 +522,7 @@ public class IniFile implements Enumeration
m_bListContainUnsavedChanges = true;
}
}
- // -----------------------------------------------------------------------------
- // String replaceEvaluatedValue(String _sSection, String _sValue)
- // {
- // String sValue = _sValue;
- // int nIndex = 0;
- // while (( nIndex = sValue.indexOf("$(", nIndex)) >= 0)
- // {
- // int nNextIndex = sValue.indexOf(")", nIndex);
- // if (nNextIndex >= 0)
- // {
- // String sKey = sValue.substring(nIndex + 2, nNextIndex);
- // String sNewValue = getValue(_sSection, sKey);
- // if (sNewValue != null && sNewValue.length() > 0)
- // {
- // String sRegexpKey = "\\$\\(" + sKey + "\\)";
- // sValue = sValue.replaceAll(sRegexpKey, sNewValue);
- // }
- // nIndex = nNextIndex;
- // }
- // else
- // {
- // nIndex += 2;
- // }
- // }
- // return sValue;
- // }
- // -----------------------------------------------------------------------------
-
- // public String getLocalEvaluatedValue(String _sSection, String _sKey)
- // {
- // String sValue = getValue(_sSection, _sKey);
- // sValue = replaceEvaluatedValue(_sSection, sValue);
- // return sValue;
- // }
-
- // -----------------------------------------------------------------------------
- // this is a special behaviour.
- // public String getGlobalLocalEvaluatedValue(String _sSection, String _sKey)
- // {
- // String sGlobalValue = getKey("global", _sKey);
- // String sLocalValue = getKey(_sSection, _sKey);
- // if (sLocalValue.length() == 0)
- // {
- // sGlobalValue = replaceEvaluatedKey(_sSection, sGlobalValue);
- // sGlobalValue = replaceEvaluatedKey("global", sGlobalValue);
- // return sGlobalValue;
- // }
- // sLocalValue = replaceEvaluatedKey(_sSection, sLocalValue);
- // sLocalValue = replaceEvaluatedKey("global", sLocalValue);
- //
- // return sLocalValue;
- // }
public void removeSection(String _sSectionToRemove)
{
// first, search for the name
More information about the Libreoffice-commits
mailing list