CompareTo ArrayIndexOutOfBoundsException

Help
2010-02-17
2013-02-18
  • Peter Chapman
    Peter Chapman
    2010-02-17

    Hi,

    I've been trying to implement a test script using T-Plan Robot and its Java API. I'm running the following line of code in a class extending DefaultJavaTestScript.

    compareTo(new File { new File("/home/peter/images/maximize.png") }, "search");

    The following runtime error occurs:

    java.lang.ArrayIndexOutOfBoundsException: -1
    at com.tplan.robot.imagecomparison.histogram.ImageHistogram.getSortedListOfColors(ImageHistogram.java:209)
    at com.tplan.robot.imagecomparison.search.SearchImageComparisonModule.rebuildHeuristics(SearchImageComparisonModule.java:313)
    at com.tplan.robot.imagecomparison.search.SearchImageComparisonModule.compare(SearchImageComparisonModule.java:100)
    at com.tplan.robot.scripting.commands.impl.CompareToCommand.handleCompareToEvent(CompareToCommand.java:367)
    at com.tplan.robot.scripting.commands.impl.CompareToCommand.execute(CompareToCommand.java:313)
    at com.tplan.robot.scripting.AbstractJavaTestScript.runScriptCommand(AbstractJavaTestScript.java:160)
    at com.tplan.robot.scripting.DefaultJavaTestScript.compareTo(DefaultJavaTestScript.java:3198)
    at com.tplan.robot.scripting.DefaultJavaTestScript.compareTo(DefaultJavaTestScript.java:3252)
    at edu.university.peter.VNCRobot.FileOpenScripts.FrustrationTest.test(FrustrationTest.java:38)
    at com.tplan.robot.scripting.interpret.java.JavaTestScriptInterpret.execute(JavaTestScriptInterpret.java:248)
    at com.tplan.robot.scripting.ExecOrCompileThread.run(ExecOrCompileThread.java:51)

    Any thoughts as to the cause?

     
  • Robert Pes
    Robert Pes
    2010-02-18

    This is a bug which has been fixed in the code of ImageHistogram approx 2 weeks ago. It happens when the template image has a particular combination of color counters. Have you put any transparency into the template image?

    You have 3 options at the moment:

    1. Get the latest code from CVS and build the tool on your own
    2. Wait until the next release (anywhere between a week to a month from now)
    3. Recreate the template image in a way which changes the colors contained in it (such as make it smaller/bigger or cut it from a bit different part of the screen).

    BTW nice name of the test script class :-)

     
  • Peter Chapman
    Peter Chapman
    2010-02-18

    Thank you!

     
  • Robert Pes
    Robert Pes
    2010-03-29

    The fix was released in 2.0.3 today.