// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package de.ugoe.cs.autoquest.plugin.guitar; import java.io.File; import java.util.LinkedList; import java.util.List; import de.ugoe.cs.autoquest.eventcore.Event; import de.ugoe.cs.autoquest.plugin.guitar.eventcore.GUITAREventTarget; import de.ugoe.cs.autoquest.plugin.guitar.eventcore.GUITAREventType; import de.ugoe.cs.autoquest.plugin.guitar.eventcore.GUITARReplayable; import edu.umd.cs.guitar.model.IO; import edu.umd.cs.guitar.model.data.EFG; import edu.umd.cs.guitar.model.data.EventType; import edu.umd.cs.guitar.model.data.StepType; import edu.umd.cs.guitar.model.data.TestCase; /** *
* Parser for GUITAR test case files. *
* * @author Steffen Herbold * @version 1.0 */ public class GUITARTestCaseParser { /** ** Name of the EFG file for the application the test cases that are parsed * are generated for. *
*/ private String efgFileName = null; /** ** Internal handle to the parsed EFG. *
*/ private EFG efg = null; /** ** Constructor. Creates a new GUITARTestCaseParser. No EFG file is * associated with this parser. *
*/ public GUITARTestCaseParser() { } /** ** Constructor. Creates a new GUITARTestCaseParser. *
* * @param efgFileName * EFG file associated with the test cases that are parsed. */ public GUITARTestCaseParser(String efgFileName) { this.efgFileName = efgFileName; } /** ** Parses a GUITAR test case file and returns its contents as an event * sequence. *
* * @param testcaseFile * file that is parsed * @return event sequence describing the test case */ public List* If {@link #efgFileName} is specified, this function retrieves the * widgetId of the widget the event with id eventId belongs to from the EFG. *
* * @param eventId * @return widgetId of the associated widget; null if {@link #efgFileName} * ==null or no widgetId for the event is found in the EFG */ private String getWidgetId(String eventId) { if (eventId != null && efgFileName != null) { if (efg == null) { efg = (EFG) IO.readObjFromFile(efgFileName, EFG.class); } for (EventType event : efg.getEvents().getEvent()) { if (eventId.equals(event.getEventId())) { return event.getWidgetId(); } } } return null; } }