1*ef39d40dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ef39d40dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ef39d40dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ef39d40dSAndrew Rist * distributed with this work for additional information 6*ef39d40dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ef39d40dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ef39d40dSAndrew Rist * "License"); you may not use this file except in compliance 9*ef39d40dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*ef39d40dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ef39d40dSAndrew Rist * 13*ef39d40dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ef39d40dSAndrew Rist * software distributed under the License is distributed on an 15*ef39d40dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ef39d40dSAndrew Rist * KIND, either express or implied. See the License for the 17*ef39d40dSAndrew Rist * specific language governing permissions and limitations 18*ef39d40dSAndrew Rist * under the License. 19*ef39d40dSAndrew Rist * 20*ef39d40dSAndrew Rist *************************************************************/ 21*ef39d40dSAndrew Rist 22*ef39d40dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package graphical; 25cdf0e10cSrcweir 26cdf0e10cSrcweir // import java.io.File; 27cdf0e10cSrcweir 28cdf0e10cSrcweir /** 29cdf0e10cSrcweir * 30cdf0e10cSrcweir * @author ll93751 31cdf0e10cSrcweir */ 32cdf0e10cSrcweir public class JPEGEvaluator extends EnhancedComplexTestCase 33cdf0e10cSrcweir { 34cdf0e10cSrcweir // @Override getTestMethodNames()35cdf0e10cSrcweir public String[] getTestMethodNames() 36cdf0e10cSrcweir { 37cdf0e10cSrcweir return new String[]{"EvaluateResult"}; 38cdf0e10cSrcweir } 39cdf0e10cSrcweir 40cdf0e10cSrcweir /** 41cdf0e10cSrcweir * test function. 42cdf0e10cSrcweir */ EvaluateResult()43cdf0e10cSrcweir public void EvaluateResult() 44cdf0e10cSrcweir { 45cdf0e10cSrcweir GlobalLogWriter.set(log); 46cdf0e10cSrcweir ParameterHelper aParam = new ParameterHelper(param); 47cdf0e10cSrcweir 48cdf0e10cSrcweir // aParam.getTestParameters().put("current_ok_status", -1); 49cdf0e10cSrcweir 50cdf0e10cSrcweir // run through all documents found in Inputpath 51cdf0e10cSrcweir foreachResultCreateHTML(aParam); 52cdf0e10cSrcweir } 53cdf0e10cSrcweir checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams)54cdf0e10cSrcweir public void checkOneFile(String _sDocument, String _sResult, ParameterHelper _aParams) throws OfficeException 55cdf0e10cSrcweir { 56cdf0e10cSrcweir // throw new UnsupportedOperationException("Not supported yet."); 57cdf0e10cSrcweir // int dummy = 0; 58cdf0e10cSrcweir 59cdf0e10cSrcweir String sBasename = FileHelper.getBasename(_sDocument); 60cdf0e10cSrcweir String sResultIniFile = _sDocument + ".ini"; 61cdf0e10cSrcweir // File aFile = new File(sResultIniFile); 62cdf0e10cSrcweir // assure("Result file doesn't exists " + sResultIniFile, aFile.exists()); 63cdf0e10cSrcweir // 64cdf0e10cSrcweir // int good = 0; 65cdf0e10cSrcweir // int bad = 0; 66cdf0e10cSrcweir // int ugly = 0; 67cdf0e10cSrcweir // 68cdf0e10cSrcweir // IniFile aResultIniFile = new IniFile(sResultIniFile); 69cdf0e10cSrcweir // int nPages = aResultIniFile.getIntValue("global", "pages", 0); 70cdf0e10cSrcweir // for (int i=0;i<nPages;i++) 71cdf0e10cSrcweir // { 72cdf0e10cSrcweir // String sCurrentPage = "page" + String.valueOf(i + 1); 73cdf0e10cSrcweir // int nPercent = aResultIniFile.getIntValue(sCurrentPage, "percent", -1); 74cdf0e10cSrcweir // if (nPercent == 0) 75cdf0e10cSrcweir // { 76cdf0e10cSrcweir // good++; 77cdf0e10cSrcweir // } 78cdf0e10cSrcweir // else if (nPercent <= 5) 79cdf0e10cSrcweir // { 80cdf0e10cSrcweir // bad ++; 81cdf0e10cSrcweir // } 82cdf0e10cSrcweir // else 83cdf0e10cSrcweir // { 84cdf0e10cSrcweir // ugly ++; 85cdf0e10cSrcweir // } 86cdf0e10cSrcweir // } 87cdf0e10cSrcweir // 88cdf0e10cSrcweir // assure("Error: document doesn't contains pages", nPages > 0); 89cdf0e10cSrcweir 90cdf0e10cSrcweir HTMLResult aOutputter = new HTMLResult(_sResult, sBasename + ".html" ); 91cdf0e10cSrcweir aOutputter.header(_sResult); 92cdf0e10cSrcweir aOutputter.indexSection(sBasename); 93cdf0e10cSrcweir 94cdf0e10cSrcweir IniFile aResultIniFile = new IniFile(sResultIniFile); 95cdf0e10cSrcweir String sStatusRunThrough = aResultIniFile.getValue("global", "state"); 96cdf0e10cSrcweir String sStatusMessage = aResultIniFile.getValue("global", "info"); 97cdf0e10cSrcweir 98cdf0e10cSrcweir // // TODO: this information has to come out of the ini files 99cdf0e10cSrcweir // String sStatusRunThrough = "PASSED, "; 100cdf0e10cSrcweir // String sPassed = "OK"; 101cdf0e10cSrcweir // 102cdf0e10cSrcweir // String sStatusMessage = "From " + nPages + " page(s) are: "; 103cdf0e10cSrcweir // String sGood = ""; 104cdf0e10cSrcweir // String sBad = ""; 105cdf0e10cSrcweir // String sUgly = ""; 106cdf0e10cSrcweir // 107cdf0e10cSrcweir // if (good > 0) 108cdf0e10cSrcweir // { 109cdf0e10cSrcweir // sGood = " good:=" + good; 110cdf0e10cSrcweir // sStatusMessage += sGood; 111cdf0e10cSrcweir // } 112cdf0e10cSrcweir // if (bad > 0) 113cdf0e10cSrcweir // { 114cdf0e10cSrcweir // sBad = " bad:=" + bad; 115cdf0e10cSrcweir // sStatusMessage += sBad; 116cdf0e10cSrcweir // } 117cdf0e10cSrcweir // if (ugly > 0) 118cdf0e10cSrcweir // { 119cdf0e10cSrcweir // sUgly = " ugly:=" + ugly; 120cdf0e10cSrcweir // sStatusMessage += sUgly; 121cdf0e10cSrcweir // } 122cdf0e10cSrcweir // 123cdf0e10cSrcweir // // Failure matrix 124cdf0e10cSrcweir // // 0 1 125cdf0e10cSrcweir // // ugly OK FAILED 126cdf0e10cSrcweir // // bad OK 127cdf0e10cSrcweir // // good OK 128cdf0e10cSrcweir // 129cdf0e10cSrcweir // if (ugly > 0) 130cdf0e10cSrcweir // { 131cdf0e10cSrcweir // sPassed = "FAILED"; 132cdf0e10cSrcweir // } 133cdf0e10cSrcweir // else 134cdf0e10cSrcweir // { 135cdf0e10cSrcweir // if (bad > 0) 136cdf0e10cSrcweir // { 137cdf0e10cSrcweir // sPassed = "NEED A LOOK"; 138cdf0e10cSrcweir // } 139cdf0e10cSrcweir // else 140cdf0e10cSrcweir // { 141cdf0e10cSrcweir // sPassed = "OK"; 142cdf0e10cSrcweir // } 143cdf0e10cSrcweir // } 144cdf0e10cSrcweir // sStatusRunThrough += sPassed; 145cdf0e10cSrcweir // aResultIniFile.insertValue("global", "state", sStatusRunThrough); 146cdf0e10cSrcweir // aResultIniFile.insertValue("global", "info", sStatusMessage); 147cdf0e10cSrcweir // aResultIniFile.close(); 148cdf0e10cSrcweir 149cdf0e10cSrcweir String sHTMLFile = _aParams.getHTMLPrefix(); // "http://so-gfxcmp-lin/gfxcmp_ui/cw.php?inifile="; 150cdf0e10cSrcweir sHTMLFile += _sDocument + ".ini"; 151cdf0e10cSrcweir aOutputter.indexLine(sHTMLFile, sBasename, sStatusRunThrough, sStatusMessage); 152cdf0e10cSrcweir aOutputter.close(); 153cdf0e10cSrcweir // IniFile aIniFile = new IniFile(_sDocument); 154cdf0e10cSrcweir // aIniFile. 155cdf0e10cSrcweir 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir 159cdf0e10cSrcweir } 160