- Timestamp:
- 05/23/13 16:27:53 (12 years ago)
- Location:
- trunk/autoquest-core-usability-test/src/test/java/de/ugoe/cs/autoquest/usability
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usability-test/src/test/java/de/ugoe/cs/autoquest/usability/AbstractUsabilityEvaluationTC.java
r927 r1210 16 16 17 17 import static org.junit.Assert.assertEquals; 18 import static org.junit.Assert.assertTrue; 18 19 import static org.junit.Assert.fail; 19 20 20 21 import java.util.ArrayList; 22 import java.util.List; 21 23 import java.util.logging.Level; 22 import java.util.regex.Matcher;23 import java.util.regex.Pattern;24 24 25 25 import org.junit.Before; 26 26 27 import de.ugoe.cs.autoquest.eventcore.Event; 28 import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 33 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 34 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 36 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; 37 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeBuilder; 38 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskTreeNodeFactory; 39 import de.ugoe.cs.autoquest.test.DummyGUIElement; 40 import de.ugoe.cs.autoquest.test.DummyInteraction; 41 import de.ugoe.cs.autoquest.test.DummyTextField; 42 import de.ugoe.cs.autoquest.usability.UsabilityDefect; 43 import de.ugoe.cs.autoquest.usability.UsabilityEvaluationResult; 27 import de.ugoe.cs.autoquest.tasktrees.TaskTreeDecoder; 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 30 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; 31 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; 32 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 33 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskBuilder; 34 import de.ugoe.cs.autoquest.tasktrees.treeimpl.TaskFactory; 44 35 import de.ugoe.cs.util.console.TextConsole; 45 36 … … 53 44 54 45 /** */ 55 private ITask TreeBuilder taskTreeBuilder = new TaskTreeBuilder();46 private ITaskBuilder taskBuilder = new TaskBuilder(); 56 47 57 48 /** */ 58 private ITask TreeNodeFactory taskTreeNodeFactory = new TaskTreeNodeFactory();49 private ITaskFactory taskFactory = new TaskFactory(); 59 50 60 51 /** … … 69 60 * 70 61 */ 71 protected ITaskTree createTaskTree(String spec) { 72 Matcher matcher = 73 Pattern.compile("(\\s*(\\w+)\\s*(\\(((\\w*\\s*)*)\\))?\\s*(\\{))|(\\})").matcher(spec); 62 protected ITaskModel createTaskModel(String spec) { 63 TaskTreeDecoder decoder = new TaskTreeDecoder(taskFactory, taskBuilder); 64 65 ITaskInstanceList list = decoder.decode(spec); 66 67 assertTrue(list instanceof IUserSession); 68 69 List<IUserSession> sessions = new ArrayList<IUserSession>(); 70 sessions.add((IUserSession) list); 74 71 75 if (!matcher.find()) { 76 if (!matcher.hitEnd()) { 77 throw new IllegalArgumentException("could not parse task specification"); 78 } 79 } 80 81 return taskTreeNodeFactory.createTaskTree(parseTask(matcher, new int[1])); 72 return taskFactory.createTaskModel(sessions); 82 73 } 83 74 … … 110 101 } 111 102 112 /**113 *114 */115 private ITaskTreeNode parseTask(Matcher tokenMatcher, int[] typeNumbers) {116 String firstToken = tokenMatcher.group();117 118 if ("}".equals(firstToken)) {119 throw new IllegalArgumentException("found a closing bracket at an unexpected place");120 }121 122 ITaskTreeNode treeNode = instantiateTreeNode(tokenMatcher, typeNumbers);123 124 if (!tokenMatcher.find()) {125 throw new IllegalArgumentException("could not parse task specification");126 }127 128 firstToken = tokenMatcher.group();129 130 if (!"}".equals(firstToken)) {131 ITaskTreeNode child = null;132 133 do {134 child = parseTask(tokenMatcher, typeNumbers);135 136 if (child != null) {137 addChild(treeNode, child);138 139 if (!tokenMatcher.find()) {140 throw new IllegalArgumentException("could not parse task specification");141 }142 143 firstToken = tokenMatcher.group();144 145 if ("}".equals(firstToken)) {146 break;147 }148 }149 150 }151 while (child != null);152 153 }154 155 return treeNode;156 }157 158 /**159 * TODO: comment160 *161 * @param group162 * @return163 */164 private ITaskTreeNode instantiateTreeNode(Matcher tokenMatcher, int[] typeNumbers) {165 String type = tokenMatcher.group(2);166 String additionalInfo = tokenMatcher.group(4);167 168 if ("Interaction".equals(type)) {169 return taskTreeNodeFactory.createNewEventTask170 (new DummyInteraction("dummy", typeNumbers[0]++), new DummyGUIElement("dummy"));171 }172 else if ("Sequence".equals(type)) {173 return taskTreeNodeFactory.createNewSequence();174 }175 else if ("Iteration".equals(type)) {176 return taskTreeNodeFactory.createNewIteration();177 }178 else if ("Selection".equals(type)) {179 return taskTreeNodeFactory.createNewSelection();180 }181 else if ("TextInput".equals(type)) {182 if (additionalInfo == null) {183 fail("no simulated text provided for text input interactin task");184 }185 186 TextInput textInput = new TextInput(additionalInfo, new ArrayList<Event>());187 188 IEventTask task = taskTreeNodeFactory.createNewEventTask189 (textInput, new DummyTextField(additionalInfo));190 191 return task;192 }193 else {194 fail("invalid type of task tree node: " + type);195 return null;196 }197 }198 199 /**200 * TODO: comment201 *202 * @param treeNode203 * @param child204 */205 private void addChild(ITaskTreeNode parent, ITaskTreeNode child) {206 if (parent instanceof ISequence) {207 taskTreeBuilder.addChild((ISequence) parent, child);208 }209 else if (parent instanceof IIteration) {210 if (parent.getChildren().size() <= 0) {211 taskTreeBuilder.setChild((IIteration) parent, child);212 }213 else {214 fail("can not add more than one child to an iteration");215 }216 }217 else if (parent instanceof ISelection) {218 taskTreeBuilder.addChild((ISelection) parent, child);219 }220 else {221 fail("can not add children to parent task tree node of type " +222 parent.getClass().getName());223 }224 }225 226 103 } -
trunk/autoquest-core-usability-test/src/test/java/de/ugoe/cs/autoquest/usability/TextInputStatisticsRuleTest.java
r927 r1210 26 26 27 27 import de.ugoe.cs.autoquest.usability.UsabilityDefect; 28 import de.ugoe.cs.autoquest.usability.UsabilityDefectDescription;29 28 import de.ugoe.cs.autoquest.usability.UsabilityEvaluationManager; 30 29 … … 47 46 // ===== check ===== 48 47 String spec = 49 "TextInput (bla) {}"; 48 "UserSession {" + 49 " TextInput (bla) {}" + 50 "}"; 50 51 UsabilityDefect[] expectedDefects = new UsabilityDefect[] 51 52 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) }; 52 53 53 54 assertUsabilityEvaluationResult 54 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 55 56 // ===== check ===== 57 spec = 58 "Sequence {" + 59 " TextInput (bla) {}" + 60 "}"; 61 62 expectedDefects = new UsabilityDefect[] 63 { new UsabilityDefect(HIGH, UsabilityDefectDescription.TEXT_FIELD_INPUT_RATIO) }; 64 65 assertUsabilityEvaluationResult 66 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 67 68 // ===== check ===== 69 spec = 70 "Sequence {" + 55 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 56 57 // ===== check ===== 58 spec = 59 "UserSession {" + 71 60 " TextInput (a) {}" + 72 61 " TextInput (b) {}" + … … 79 68 80 69 assertUsabilityEvaluationResult 81 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));82 83 // ===== check ===== 84 spec = 85 " Selection {" +70 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 71 72 // ===== check ===== 73 spec = 74 "UserSession {" + 86 75 " TextInput (a) {}" + 87 76 " TextInput (b) {}" + … … 94 83 95 84 assertUsabilityEvaluationResult 96 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));85 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 97 86 98 87 // ===== check ===== … … 106 95 107 96 assertUsabilityEvaluationResult 108 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));97 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 109 98 110 99 // ===== check ===== … … 173 162 174 163 assertUsabilityEvaluationResult 175 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));164 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 176 165 } 177 166 … … 198 187 199 188 assertUsabilityEvaluationResult 200 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));189 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 201 190 202 191 // ===== check ===== … … 214 203 215 204 assertUsabilityEvaluationResult 216 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));205 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 217 206 218 207 // ===== check ===== … … 229 218 230 219 assertUsabilityEvaluationResult 231 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));220 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 232 221 233 222 // ===== check ===== … … 245 234 246 235 assertUsabilityEvaluationResult 247 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));236 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 248 237 249 238 // ===== check ===== … … 326 315 327 316 assertUsabilityEvaluationResult 328 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));317 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 329 318 330 319 // ===== check ===== … … 407 396 408 397 assertUsabilityEvaluationResult 409 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));398 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 410 399 } 411 400 … … 455 444 456 445 assertUsabilityEvaluationResult 457 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));446 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 458 447 459 448 // ===== check ===== … … 494 483 495 484 assertUsabilityEvaluationResult 496 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));485 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 497 486 498 487 // ===== check ===== … … 533 522 534 523 assertUsabilityEvaluationResult 535 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));524 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 536 525 537 526 // ===== check ===== … … 572 561 573 562 assertUsabilityEvaluationResult 574 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));563 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 575 564 576 565 // ===== check ===== … … 590 579 591 580 assertUsabilityEvaluationResult 592 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));581 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 593 582 594 583 // ===== check ===== … … 608 597 609 598 assertUsabilityEvaluationResult 610 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));599 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 611 600 612 601 // ===== check ===== … … 626 615 627 616 assertUsabilityEvaluationResult 628 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));617 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 629 618 630 619 } … … 649 638 650 639 assertUsabilityEvaluationResult 651 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));640 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 652 641 653 642 // ===== check ===== … … 662 651 663 652 assertUsabilityEvaluationResult 664 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));653 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 665 654 666 655 // ===== check ===== … … 675 664 676 665 assertUsabilityEvaluationResult 677 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));666 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 678 667 679 668 // ===== check ===== … … 689 678 690 679 assertUsabilityEvaluationResult 691 (expectedDefects, manager.evaluateUsability(createTask Tree(spec)));680 (expectedDefects, manager.evaluateUsability(createTaskModel(spec))); 692 681 693 682 }
Note: See TracChangeset
for help on using the changeset viewer.