[927] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany |
---|
| 2 | // |
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
---|
| 4 | // you may not use this file except in compliance with the License. |
---|
| 5 | // You may obtain a copy of the License at |
---|
| 6 | // |
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 8 | // |
---|
| 9 | // Unless required by applicable law or agreed to in writing, software |
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 12 | // See the License for the specific language governing permissions and |
---|
| 13 | // limitations under the License. |
---|
| 14 | |
---|
[922] | 15 | package de.ugoe.cs.autoquest.usability; |
---|
[474] | 16 | |
---|
| 17 | import static org.junit.Assert.assertEquals; |
---|
[1210] | 18 | import static org.junit.Assert.assertTrue; |
---|
[474] | 19 | import static org.junit.Assert.fail; |
---|
| 20 | |
---|
[698] | 21 | import java.util.ArrayList; |
---|
[1210] | 22 | import java.util.List; |
---|
[725] | 23 | import java.util.logging.Level; |
---|
[474] | 24 | |
---|
| 25 | import org.junit.Before; |
---|
| 26 | |
---|
[1210] | 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; |
---|
[725] | 35 | import de.ugoe.cs.util.console.TextConsole; |
---|
[474] | 36 | |
---|
| 37 | /** |
---|
[1427] | 38 | * @author Patrick Harms |
---|
[474] | 39 | */ |
---|
[561] | 40 | public class AbstractUsabilityEvaluationTC { |
---|
[474] | 41 | |
---|
[561] | 42 | /** */ |
---|
[1210] | 43 | private ITaskBuilder taskBuilder = new TaskBuilder(); |
---|
[561] | 44 | |
---|
| 45 | /** */ |
---|
[1210] | 46 | private ITaskFactory taskFactory = new TaskFactory(); |
---|
[561] | 47 | |
---|
| 48 | /** |
---|
[1335] | 49 | * |
---|
| 50 | */ |
---|
[561] | 51 | @Before |
---|
| 52 | public void setUp() { |
---|
[725] | 53 | new TextConsole(Level.FINEST); |
---|
[561] | 54 | } |
---|
[474] | 55 | |
---|
[561] | 56 | /** |
---|
[1335] | 57 | * |
---|
| 58 | */ |
---|
[1210] | 59 | protected ITaskModel createTaskModel(String spec) { |
---|
| 60 | TaskTreeDecoder decoder = new TaskTreeDecoder(taskFactory, taskBuilder); |
---|
| 61 | |
---|
| 62 | ITaskInstanceList list = decoder.decode(spec); |
---|
| 63 | |
---|
| 64 | assertTrue(list instanceof IUserSession); |
---|
| 65 | |
---|
| 66 | List<IUserSession> sessions = new ArrayList<IUserSession>(); |
---|
| 67 | sessions.add((IUserSession) list); |
---|
[561] | 68 | |
---|
[1210] | 69 | return taskFactory.createTaskModel(sessions); |
---|
[474] | 70 | } |
---|
| 71 | |
---|
[561] | 72 | /** |
---|
[1427] | 73 | * |
---|
[561] | 74 | */ |
---|
| 75 | protected void assertUsabilityEvaluationResult(UsabilityDefect[] expectedDefects, |
---|
| 76 | UsabilityEvaluationResult evaluationResult) |
---|
| 77 | { |
---|
[1335] | 78 | assertEquals(evaluationResult.getAllDefects().toString(), |
---|
| 79 | expectedDefects.length, evaluationResult.getAllDefects().size()); |
---|
[474] | 80 | |
---|
[561] | 81 | EXPECTED_DEFECT_ITERATION: |
---|
| 82 | for (UsabilityDefect expectedDefect : expectedDefects) { |
---|
| 83 | for (UsabilityDefect defect : evaluationResult.getAllDefects()) { |
---|
| 84 | if (expectedDefect.equals(defect)) { |
---|
| 85 | System.err.println(defect.getParameterizedDescription()); |
---|
| 86 | continue EXPECTED_DEFECT_ITERATION; |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | for (UsabilityDefect defect : evaluationResult.getAllDefects()) { |
---|
| 91 | System.err.println(defect); |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | fail("expected defect " + expectedDefect + " not found in evaluation result"); |
---|
[474] | 95 | } |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | } |
---|