Changeset 561
- Timestamp:
- 08/17/12 09:26:21 (12 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-usability-test/src/test/java/de/ugoe/cs/quest/usability/AbstractUsabilityEvaluationTC.java
r474 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: AbstractUsabilityEvaluationTC.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 18.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.quest.usability; 9 9 … … 21 21 import de.ugoe.cs.quest.tasktrees.testutils.DummyTextField; 22 22 import de.ugoe.cs.quest.tasktrees.testutils.SimpleLogFormatter; 23 import de.ugoe.cs.quest.tasktrees.treeifc.Iteration; 24 import de.ugoe.cs.quest.tasktrees.treeifc.Selection; 25 import de.ugoe.cs.quest.tasktrees.treeifc.Sequence; 26 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTree; 27 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTreeBuilder; 28 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTreeNode; 29 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTreeNodeFactory; 30 import de.ugoe.cs.quest.tasktrees.treeifc.TextInputInteractionTask; 31 import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeBuilderImpl; 32 import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeNodeFactoryImpl; 33 34 //------------------------------------------------------------------------------------------------- 23 import de.ugoe.cs.quest.tasktrees.treeifc.IIteration; 24 import de.ugoe.cs.quest.tasktrees.treeifc.ISelection; 25 import de.ugoe.cs.quest.tasktrees.treeifc.ISequence; 26 import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTree; 27 import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeBuilder; 28 import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNode; 29 import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNodeFactory; 30 import de.ugoe.cs.quest.tasktrees.treeifc.ITextInputEventTask; 31 import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeBuilder; 32 import de.ugoe.cs.quest.tasktrees.treeimpl.TaskTreeNodeFactory; 33 35 34 /** 36 35 * TODO comment … … 39 38 * @author 2012, last modified by $Author: pharms$ 40 39 */ 41 //------------------------------------------------------------------------------------------------- 42 public class AbstractUsabilityEvaluationTC 43 { 44 45 /** */ 46 private TaskTreeBuilder mTaskTreeBuilder = new TaskTreeBuilderImpl(); 47 48 /** */ 49 private TaskTreeNodeFactory mTaskTreeNodeFactory = new TaskTreeNodeFactoryImpl(); 50 51 //----------------------------------------------------------------------------------------------- 52 /** 40 public class AbstractUsabilityEvaluationTC { 41 42 /** */ 43 private ITaskTreeBuilder taskTreeBuilder = new TaskTreeBuilder(); 44 45 /** */ 46 private ITaskTreeNodeFactory taskTreeNodeFactory = new TaskTreeNodeFactory(); 47 48 /** 53 49 * 54 50 */ 55 //----------------------------------------------------------------------------------------------- 56 @Before 57 public void setUp() 58 { 59 Logger.getLogger("").getHandlers()[0].setFormatter(new SimpleLogFormatter()); 60 } 61 62 //----------------------------------------------------------------------------------------------- 63 /** 51 @Before 52 public void setUp() { 53 Logger.getLogger("").getHandlers()[0].setFormatter(new SimpleLogFormatter()); 54 } 55 56 /** 64 57 * 65 58 */ 66 //----------------------------------------------------------------------------------------------- 67 protected TaskTree createTaskTree(String spec) 68 { 69 Matcher matcher = 70 Pattern.compile("(\\s*(\\w+)\\s*(\\(((\\w*\\s*)*)\\))?\\s*(\\{))|(\\})").matcher(spec); 71 72 if (!matcher.find()) 59 protected ITaskTree createTaskTree(String spec) { 60 Matcher matcher = 61 Pattern.compile("(\\s*(\\w+)\\s*(\\(((\\w*\\s*)*)\\))?\\s*(\\{))|(\\})").matcher(spec); 62 63 if (!matcher.find()) { 64 if (!matcher.hitEnd()) { 65 throw new IllegalArgumentException("could not parse task specification"); 66 } 67 } 68 69 return taskTreeNodeFactory.createTaskTree(parseTask(matcher, new int[1])); 70 } 71 72 /** 73 * TODO: comment 74 * 75 * @param expectedDefects 76 * @param evaluateUsability 77 */ 78 protected void assertUsabilityEvaluationResult(UsabilityDefect[] expectedDefects, 79 UsabilityEvaluationResult evaluationResult) 73 80 { 74 if (!matcher.hitEnd()) 75 { 76 throw new IllegalArgumentException("could not parse task specification"); 77 } 78 } 79 80 return mTaskTreeNodeFactory.createTaskTree(parseTask(matcher, new int[1])); 81 } 82 83 //----------------------------------------------------------------------------------------------- 84 /** 85 * TODO: comment 86 * 87 * @param expectedDefects 88 * @param evaluateUsability 89 */ 90 //----------------------------------------------------------------------------------------------- 91 protected void assertUsabilityEvaluationResult(UsabilityDefect[] expectedDefects, 92 UsabilityEvaluationResult evaluationResult) 93 { 94 assertEquals(expectedDefects.length, evaluationResult.getAllDefects().size()); 95 96 EXPECTED_DEFECT_ITERATION: 97 for (UsabilityDefect expectedDefect : expectedDefects) 98 { 99 for (UsabilityDefect defect : evaluationResult.getAllDefects()) 100 { 101 if (expectedDefect.equals(defect)) 102 { 103 System.err.println(defect.getParameterizedDescription()); 104 continue EXPECTED_DEFECT_ITERATION; 105 } 106 } 107 108 for (UsabilityDefect defect : evaluationResult.getAllDefects()) 109 { 110 System.err.println(defect); 111 } 112 113 fail("expected defect " + expectedDefect + " not found in evaluation result"); 114 } 115 } 116 117 118 //----------------------------------------------------------------------------------------------- 119 /** 81 assertEquals(expectedDefects.length, evaluationResult.getAllDefects().size()); 82 83 EXPECTED_DEFECT_ITERATION: 84 for (UsabilityDefect expectedDefect : expectedDefects) { 85 for (UsabilityDefect defect : evaluationResult.getAllDefects()) { 86 if (expectedDefect.equals(defect)) { 87 System.err.println(defect.getParameterizedDescription()); 88 continue EXPECTED_DEFECT_ITERATION; 89 } 90 } 91 92 for (UsabilityDefect defect : evaluationResult.getAllDefects()) { 93 System.err.println(defect); 94 } 95 96 fail("expected defect " + expectedDefect + " not found in evaluation result"); 97 } 98 } 99 100 /** 120 101 * 121 102 */ 122 //----------------------------------------------------------------------------------------------- 123 private TaskTreeNode parseTask(Matcher tokenMatcher, int[] typeNumbers) 124 { 125 String firstToken = tokenMatcher.group(); 126 127 if ("}".equals(firstToken)) 128 { 129 throw new IllegalArgumentException("found a closing bracket at an unexpected place"); 130 } 131 132 TaskTreeNode treeNode = instantiateTreeNode(tokenMatcher, typeNumbers); 133 134 if (!tokenMatcher.find()) 135 { 136 throw new IllegalArgumentException("could not parse task specification"); 137 } 138 139 firstToken = tokenMatcher.group(); 140 141 if (!"}".equals(firstToken)) 142 { 143 TaskTreeNode child = null; 144 145 do 146 { 147 child = parseTask(tokenMatcher, typeNumbers); 148 149 if (child != null) 150 { 151 addChild(treeNode, child); 152 153 if (!tokenMatcher.find()) 154 { 103 private ITaskTreeNode parseTask(Matcher tokenMatcher, int[] typeNumbers) { 104 String firstToken = tokenMatcher.group(); 105 106 if ("}".equals(firstToken)) { 107 throw new IllegalArgumentException("found a closing bracket at an unexpected place"); 108 } 109 110 ITaskTreeNode treeNode = instantiateTreeNode(tokenMatcher, typeNumbers); 111 112 if (!tokenMatcher.find()) { 155 113 throw new IllegalArgumentException("could not parse task specification"); 156 } 157 158 firstToken = tokenMatcher.group(); 159 160 if ("}".equals(firstToken)) 161 { 162 break; 163 } 164 } 165 166 } 167 while (child != null); 168 169 } 170 171 return treeNode; 172 } 173 174 //----------------------------------------------------------------------------------------------- 175 /** 176 * TODO: comment 177 * 178 * @param group 179 * @return 180 */ 181 //----------------------------------------------------------------------------------------------- 182 private TaskTreeNode instantiateTreeNode(Matcher tokenMatcher, int[] typeNumbers) 183 { 184 String type = tokenMatcher.group(2); 185 String additionalInfo = tokenMatcher.group(4); 186 187 if ("Interaction".equals(type)) 188 { 189 return mTaskTreeNodeFactory.createNewInteractionTask 190 (new DummyGUIElement("dummy"), new DummyInteraction("dummy", typeNumbers[0]++)); 191 } 192 else if ("Sequence".equals(type)) 193 { 194 return mTaskTreeNodeFactory.createNewSequence(); 195 } 196 else if ("Iteration".equals(type)) 197 { 198 return mTaskTreeNodeFactory.createNewIteration(); 199 } 200 else if ("Selection".equals(type)) 201 { 202 return mTaskTreeNodeFactory.createNewSelection(); 203 } 204 else if ("TextInput".equals(type)) 205 { 206 if (additionalInfo == null) 207 { 208 fail("no simulated text provided for text input interactin task"); 209 } 210 211 TextInputInteractionTask task = 212 mTaskTreeNodeFactory.createNewTextInputInteractionTask(new DummyTextField(additionalInfo)); 213 214 task.setEnteredText(additionalInfo); 215 return task; 216 } 217 else 218 { 219 fail("invalid type of task tree node: " + type); 220 return null; 221 } 222 } 223 224 //----------------------------------------------------------------------------------------------- 225 /** 226 * TODO: comment 227 * 228 * @param treeNode 229 * @param child 230 */ 231 //----------------------------------------------------------------------------------------------- 232 private void addChild(TaskTreeNode parent, TaskTreeNode child) 233 { 234 if (parent instanceof Sequence) 235 { 236 mTaskTreeBuilder.addChild((Sequence) parent, child); 237 } 238 else if (parent instanceof Iteration) 239 { 240 if (parent.getChildren().size() <= 0) 241 { 242 mTaskTreeBuilder.setChild((Iteration) parent, child); 243 } 244 else 245 { 246 fail("can not add more than one child to an iteration"); 247 } 248 } 249 else if (parent instanceof Selection) 250 { 251 mTaskTreeBuilder.addChild((Selection) parent, child); 252 } 253 else if (parent instanceof TextInputInteractionTask) 254 { 255 mTaskTreeBuilder.addChild((TextInputInteractionTask) parent, child); 256 } 257 else 258 { 259 fail("can not add children to parent task tree node of type " + parent.getClass().getName()); 260 } 261 } 114 } 115 116 firstToken = tokenMatcher.group(); 117 118 if (!"}".equals(firstToken)) { 119 ITaskTreeNode child = null; 120 121 do { 122 child = parseTask(tokenMatcher, typeNumbers); 123 124 if (child != null) { 125 addChild(treeNode, child); 126 127 if (!tokenMatcher.find()) { 128 throw new IllegalArgumentException("could not parse task specification"); 129 } 130 131 firstToken = tokenMatcher.group(); 132 133 if ("}".equals(firstToken)) { 134 break; 135 } 136 } 137 138 } 139 while (child != null); 140 141 } 142 143 return treeNode; 144 } 145 146 /** 147 * TODO: comment 148 * 149 * @param group 150 * @return 151 */ 152 private ITaskTreeNode instantiateTreeNode(Matcher tokenMatcher, int[] typeNumbers) { 153 String type = tokenMatcher.group(2); 154 String additionalInfo = tokenMatcher.group(4); 155 156 if ("Interaction".equals(type)) { 157 return taskTreeNodeFactory.createNewEventTask 158 (new DummyInteraction("dummy", typeNumbers[0]++), new DummyGUIElement("dummy")); 159 } 160 else if ("Sequence".equals(type)) { 161 return taskTreeNodeFactory.createNewSequence(); 162 } 163 else if ("Iteration".equals(type)) { 164 return taskTreeNodeFactory.createNewIteration(); 165 } 166 else if ("Selection".equals(type)) { 167 return taskTreeNodeFactory.createNewSelection(); 168 } 169 else if ("TextInput".equals(type)) { 170 if (additionalInfo == null) { 171 fail("no simulated text provided for text input interactin task"); 172 } 173 174 ITextInputEventTask task = 175 taskTreeNodeFactory.createNewTextInputEventTask(new DummyTextField(additionalInfo)); 176 177 task.setEnteredText(additionalInfo); 178 return task; 179 } 180 else { 181 fail("invalid type of task tree node: " + type); 182 return null; 183 } 184 } 185 186 /** 187 * TODO: comment 188 * 189 * @param treeNode 190 * @param child 191 */ 192 private void addChild(ITaskTreeNode parent, ITaskTreeNode child) { 193 if (parent instanceof ISequence) { 194 taskTreeBuilder.addChild((ISequence) parent, child); 195 } 196 else if (parent instanceof IIteration) { 197 if (parent.getChildren().size() <= 0) { 198 taskTreeBuilder.setChild((IIteration) parent, child); 199 } 200 else { 201 fail("can not add more than one child to an iteration"); 202 } 203 } 204 else if (parent instanceof ISelection) { 205 taskTreeBuilder.addChild((ISelection) parent, child); 206 } 207 else if (parent instanceof ITextInputEventTask) { 208 taskTreeBuilder.addChild((ITextInputEventTask) parent, child); 209 } 210 else { 211 fail("can not add children to parent task tree node of type " + 212 parent.getClass().getName()); 213 } 214 } 262 215 263 216 } -
trunk/quest-core-usability-test/src/test/java/de/ugoe/cs/quest/usability/TextInputStatisticsRuleTest.java
r497 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: TextInputStatisticsRuleTest.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 18.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.quest.usability; 9 9 … … 18 18 import org.junit.Test; 19 19 20 //-------------------------------------------------------------------------------------------------21 20 /** 22 21 * TODO comment … … 25 24 * @author 2012, last modified by $Author: pharms$ 26 25 */ 27 //------------------------------------------------------------------------------------------------- 28 public class TextInputStatisticsRuleTest extends AbstractUsabilityEvaluationTC 29 { 30 31 //----------------------------------------------------------------------------------------------- 32 /** 33 * TODO: comment 34 * 35 */ 36 //----------------------------------------------------------------------------------------------- 37 @Test 38 public void testWithDifferentTextInputInteractionsOnly() 39 { 40 UsabilityEvaluationManager manager = new UsabilityEvaluationManager(); 41 42 // ===== check ===== 43 String spec = "TextInput (bla) {}"; 44 UsabilityDefect[] expectedDefects = new UsabilityDefect[] 45 { 46 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) 47 }; 48 49 assertUsabilityEvaluationResult 50 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 51 52 // ===== check ===== 53 spec = 54 "Sequence {" + 55 " TextInput (bla) {}" + 56 "}"; 57 58 expectedDefects = new UsabilityDefect[] 59 { 60 new UsabilityDefect(HIGH, UsabilityDefectDescription.TEXT_FIELD_INPUT_RATIO) 61 }; 62 63 assertUsabilityEvaluationResult 64 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 65 66 // ===== check ===== 67 spec = 68 "Sequence {" + 69 " TextInput (a) {}" + 70 " TextInput (b) {}" + 71 " TextInput (c) {}" + 72 " TextInput (d) {}" + 73 "}"; 74 75 expectedDefects = new UsabilityDefect[] 76 { 77 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) 78 }; 79 80 assertUsabilityEvaluationResult 81 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 82 83 // ===== check ===== 84 spec = 85 "Selection {" + 86 " TextInput (a) {}" + 87 " TextInput (b) {}" + 88 " TextInput (c) {}" + 89 " TextInput (d) {}" + 90 "}"; 91 92 expectedDefects = new UsabilityDefect[] 93 { 94 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) 95 }; 96 97 assertUsabilityEvaluationResult 98 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 99 100 // ===== check ===== 101 spec = 102 "Iteration {" + 103 " TextInput (bla) {}" + 104 "}"; 105 106 expectedDefects = new UsabilityDefect[] 107 { 108 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) 109 }; 110 111 assertUsabilityEvaluationResult 112 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 113 114 // ===== check ===== 115 spec = 116 "Sequence {" + 117 " TextInput (a) {}" + 118 " Sequence {" + 119 " TextInput (b) {}" + 120 " TextInput (c) {}" + 121 " TextInput (d) {}" + 122 " TextInput (e) {}" + 123 " }" + 124 " Iteration {" + 125 " TextInput (f) {}" + 126 " }" + 127 " TextInput (g) {}" + 128 " Selection {" + 129 " TextInput (h) {}" + 130 " TextInput (i) {}" + 131 " TextInput (j) {}" + 132 " TextInput (k) {}" + 133 " }" + 134 " Sequence {" + 135 " TextInput (l) {}" + 136 " Sequence {" + 137 " TextInput (m) {}" + 138 " TextInput (n) {}" + 139 " TextInput (o) {}" + 140 " TextInput (p) {}" + 141 " }" + 142 " Iteration {" + 143 " TextInput (q) {}" + 144 " }" + 145 " TextInput (r) {}" + 146 " Selection {" + 147 " TextInput (s) {}" + 148 " TextInput (t) {}" + 149 " TextInput (u) {}" + 150 " TextInput (v) {}" + 151 " }" + 152 " }" + 153 " Selection {" + 154 " TextInput (w) {}" + 155 " Sequence {" + 156 " TextInput (x) {}" + 157 " TextInput (y) {}" + 158 " TextInput (z) {}" + 159 " TextInput (aa) {}" + 160 " }" + 161 " Iteration {" + 162 " TextInput (ab) {}" + 163 " }" + 164 " TextInput (ac) {}" + 165 " Selection {" + 166 " TextInput (ad) {}" + 167 " TextInput (ae) {}" + 168 " TextInput (af) {}" + 169 " TextInput (ag) {}" + 170 " }" + 171 " }" + 172 " TextInput (ah) {}" + 173 "}"; 174 175 expectedDefects = new UsabilityDefect[] 176 { 177 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) 178 }; 179 180 assertUsabilityEvaluationResult 181 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 182 } 183 184 //----------------------------------------------------------------------------------------------- 185 /** 186 * TODO: comment 187 * 188 */ 189 //----------------------------------------------------------------------------------------------- 190 @Test 191 public void testCombinationsOfTextInputInteractionsAndOtherInteractions() 192 { 193 UsabilityEvaluationManager manager = new UsabilityEvaluationManager(); 194 195 // ===== check ===== 196 String spec = 197 "Sequence {" + 198 " Interaction {}" + 199 " TextInput (a) {}" + 200 " TextInput (b) {}" + 201 " Interaction {}" + 202 " TextInput (c) {}" + 203 "}"; 204 205 UsabilityDefect[] expectedDefects = new UsabilityDefect[] 206 { 207 new UsabilityDefect(LOW, TEXT_FIELD_INPUT_RATIO) 208 }; 209 210 assertUsabilityEvaluationResult 211 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 212 213 // ===== check ===== 214 spec = 215 "Sequence {" + 216 " Interaction {}" + 217 " TextInput (a) {}" + 218 " Interaction {}" + 219 " Interaction {}" + 220 " TextInput (c) {}" + 221 "}"; 222 223 expectedDefects = new UsabilityDefect[] 224 { 225 new UsabilityDefect(INFO, TEXT_FIELD_INPUT_RATIO) 226 }; 227 228 assertUsabilityEvaluationResult 229 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 230 231 // ===== check ===== 232 spec = 233 "Sequence {" + 234 " Interaction {}" + 235 " TextInput (a) {}" + 236 " Interaction {}" + 237 " Interaction {}" + 238 " Interaction {}" + 239 "}"; 240 241 expectedDefects = new UsabilityDefect[0]; 242 243 assertUsabilityEvaluationResult 244 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 245 246 // ===== check ===== 247 spec = 248 "Selection {" + 249 " Interaction {}" + 250 " TextInput (a) {}" + 251 " TextInput (b) {}" + 252 " Interaction {}" + 253 " TextInput (c) {}" + 254 "}"; 255 256 expectedDefects = new UsabilityDefect[] 257 { 258 new UsabilityDefect(LOW, TEXT_FIELD_INPUT_RATIO) 259 }; 260 261 assertUsabilityEvaluationResult 262 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 263 264 // ===== check ===== 265 spec = 266 "Sequence {" + 267 " TextInput (a) {}" + 268 " Sequence {" + 269 " Interaction {}" + 270 " TextInput (b) {}" + 271 " TextInput (c) {}" + 272 " Interaction {}" + 273 " TextInput (d) {}" + 274 " }" + 275 " Iteration {" + 276 " TextInput (e) {}" + 277 " }" + 278 " Interaction {}" + 279 " Selection {" + 280 " Interaction {}" + 281 " TextInput (f) {}" + 282 " TextInput (g) {}" + 283 " Interaction {}" + 284 " TextInput (h) {}" + 285 " TextInput (i) {}" + 286 " }" + 287 " Sequence {" + 288 " TextInput (j) {}" + 289 " Sequence {" + 290 " TextInput (k) {}" + 291 " Interaction {}" + 292 " TextInput (l) {}" + 293 " TextInput (m) {}" + 294 " Interaction {}" + 295 " TextInput (n) {}" + 296 " TextInput (o) {}" + 297 " }" + 298 " Iteration {" + 299 " Interaction {}" + 300 " }" + 301 " Interaction {}" + 302 " Selection {" + 303 " TextInput (p) {}" + 304 " TextInput (q) {}" + 305 " TextInput (r) {}" + 306 " Interaction {}" + 307 " TextInput (s) {}" + 308 " TextInput (t) {}" + 309 " Interaction {}" + 310 " TextInput (u) {}" + 311 " TextInput (v) {}" + 312 " }" + 313 " }" + 314 " Selection {" + 315 " Interaction {}" + 316 " Sequence {" + 317 " TextInput (w) {}" + 318 " Interaction {}" + 319 " TextInput (x) {}" + 320 " TextInput (y) {}" + 321 " Interaction {}" + 322 " }" + 323 " Iteration {" + 324 " TextInput (z) {}" + 325 " }" + 326 " TextInput (aa) {}" + 327 " Selection {" + 328 " TextInput (ab) {}" + 329 " Interaction {}" + 330 " TextInput (ac) {}" + 331 " TextInput (ad) {}" + 332 " Interaction {}" + 333 " TextInput (ae) {}" + 334 " }" + 335 " }" + 336 " Interaction {}" + 337 "}"; 338 339 expectedDefects = new UsabilityDefect[] 340 { 341 new UsabilityDefect(LOW, TEXT_FIELD_INPUT_RATIO) 342 }; 343 344 assertUsabilityEvaluationResult 345 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 346 347 // ===== check ===== 348 spec = 349 "Sequence {" + 350 " TextInput (a) {}" + 351 " Sequence {" + 352 " Interaction {}" + 353 " TextInput (b) {}" + 354 " Interaction {}" + 355 " Interaction {}" + 356 " TextInput (c) {}" + 357 " }" + 358 " Iteration {" + 359 " TextInput (d) {}" + 360 " }" + 361 " Interaction {}" + 362 " Selection {" + 363 " Interaction {}" + 364 " TextInput (e) {}" + 365 " Interaction {}" + 366 " Interaction {}" + 367 " TextInput (g) {}" + 368 " Interaction {}" + 369 " }" + 370 " Sequence {" + 371 " TextInput (i) {}" + 372 " Sequence {" + 373 " TextInput (j) {}" + 374 " Interaction {}" + 375 " TextInput (k) {}" + 376 " Interaction {}" + 377 " Interaction {}" + 378 " TextInput (m) {}" + 379 " Interaction {}" + 380 " }" + 381 " Iteration {" + 382 " Interaction {}" + 383 " }" + 384 " Interaction {}" + 385 " Selection {" + 386 " TextInput (o) {}" + 387 " Interaction {}" + 388 " Interaction {}" + 389 " Interaction {}" + 390 " Interaction {}" + 391 " TextInput (s) {}" + 392 " Interaction {}" + 393 " TextInput (t) {}" + 394 " TextInput (u) {}" + 395 " }" + 396 " }" + 397 " Selection {" + 398 " Interaction {}" + 399 " Sequence {" + 400 " TextInput (v) {}" + 401 " Interaction {}" + 402 " Interaction {}" + 403 " TextInput (x) {}" + 404 " Interaction {}" + 405 " }" + 406 " Iteration {" + 407 " TextInput (y) {}" + 408 " }" + 409 " TextInput (z) {}" + 410 " Selection {" + 411 " TextInput (aa) {}" + 412 " Interaction {}" + 413 " TextInput (ab) {}" + 414 " Interaction {}" + 415 " Interaction {}" + 416 " TextInput (ad) {}" + 417 " }" + 418 " }" + 419 " Interaction {}" + 420 "}"; 421 422 expectedDefects = new UsabilityDefect[] 423 { 424 new UsabilityDefect(INFO, TEXT_FIELD_INPUT_RATIO) 425 }; 426 427 assertUsabilityEvaluationResult 428 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 429 } 430 431 //----------------------------------------------------------------------------------------------- 432 /** 433 * TODO: comment 434 * 435 */ 436 //----------------------------------------------------------------------------------------------- 437 @Test 438 public void testTextEntryRepetitions() 439 { 440 UsabilityEvaluationManager manager = new UsabilityEvaluationManager(); 441 442 // ===== check ===== 443 String spec = 444 "Sequence {" + 445 " TextInput (a b c) {}" + 446 " Sequence {" + 447 " TextInput (a) {}" + 448 " TextInput (b) {}" + 449 " TextInput (c) {}" + 450 " TextInput (a) {}" + 451 " }" + 452 " Iteration {" + 453 " TextInput (a) {}" + 454 " }" + 455 " TextInput (a) {}" + 456 " Selection {" + 457 " TextInput (b c) {}" + 458 " TextInput (a) {}" + 459 " TextInput (a c) {}" + 460 " TextInput (b a) {}" + 461 " }" + 462 " Sequence {" + 463 " TextInput (b c) {}" + 464 " Sequence {" + 465 " TextInput (d a c) {}" + 466 " TextInput (b b b a) {}" + 467 " TextInput (a a c c) {}" + 468 " TextInput (b b a) {}" + 469 " }" + 470 " }" + 471 " TextInput (d) {}" + 472 "}"; 473 474 UsabilityDefect[] expectedDefects = new UsabilityDefect[] 475 { 476 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 477 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_REPETITIONS) 478 }; 479 480 assertUsabilityEvaluationResult 481 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 482 483 // ===== check ===== 484 spec = 485 "Sequence {" + 486 " TextInput (a b c d e f g h i j k l m) {}" + 487 " Sequence {" + 488 " TextInput (a) {}" + 489 " TextInput (b) {}" + 490 " TextInput (c) {}" + 491 " TextInput (d) {}" + 492 " }" + 493 " Iteration {" + 494 " TextInput (e) {}" + 495 " }" + 496 " TextInput (f) {}" + 497 " Selection {" + 498 " TextInput (g) {}" + 499 " TextInput (h) {}" + 500 " TextInput (i) {}" + 501 " TextInput (j) {}" + 502 " }" + 503 " Sequence {" + 504 " TextInput (k) {}" + 505 " Sequence {" + 506 " TextInput (l) {}" + 507 " TextInput (m) {}" + 508 " TextInput (n) {}" + 509 " TextInput (o) {}" + 510 " }" + 511 " }" + 512 " TextInput (p) {}" + 513 "}"; 514 515 expectedDefects = new UsabilityDefect[] 516 { 517 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 518 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_REPETITIONS) 519 }; 520 521 assertUsabilityEvaluationResult 522 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 523 524 // ===== check ===== 525 spec = 526 "Sequence {" + 527 " TextInput (a b c d e f g h i j k l m) {}" + 528 " Sequence {" + 529 " TextInput (a) {}" + 530 " TextInput (b) {}" + 531 " TextInput (c) {}" + 532 " TextInput (d) {}" + 533 " }" + 534 " Iteration {" + 535 " TextInput (e) {}" + 536 " }" + 537 " TextInput (a) {}" + 538 " Selection {" + 539 " TextInput (b) {}" + 540 " TextInput (c) {}" + 541 " TextInput (d) {}" + 542 " TextInput (e) {}" + 543 " }" + 544 " Sequence {" + 545 " TextInput (a) {}" + 546 " Sequence {" + 547 " TextInput (b) {}" + 548 " TextInput (c) {}" + 549 " TextInput (d) {}" + 550 " TextInput (e) {}" + 551 " }" + 552 " }" + 553 " TextInput (f) {}" + 554 "}"; 555 556 expectedDefects = new UsabilityDefect[] 557 { 558 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 559 new UsabilityDefect(MEDIUM, TEXT_FIELD_INPUT_REPETITIONS) 560 }; 561 562 assertUsabilityEvaluationResult 563 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 564 565 // ===== check ===== 566 spec = 567 "Sequence {" + 568 " TextInput (a b c d e f g h i j k l m) {}" + 569 " Sequence {" + 570 " TextInput (a) {}" + 571 " TextInput (b) {}" + 572 " TextInput (c) {}" + 573 " TextInput (a) {}" + 574 " }" + 575 " Iteration {" + 576 " TextInput (b) {}" + 577 " }" + 578 " TextInput (c) {}" + 579 " Selection {" + 580 " TextInput (a) {}" + 581 " TextInput (b) {}" + 582 " TextInput (c) {}" + 583 " TextInput (a) {}" + 584 " }" + 585 " Sequence {" + 586 " TextInput (b) {}" + 587 " Sequence {" + 588 " TextInput (c) {}" + 589 " TextInput (a) {}" + 590 " TextInput (b) {}" + 591 " TextInput (c) {}" + 592 " }" + 593 " }" + 594 " TextInput (a) {}" + 595 "}"; 596 597 expectedDefects = new UsabilityDefect[] 598 { 599 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 600 new UsabilityDefect(MEDIUM, TEXT_FIELD_INPUT_REPETITIONS) 601 }; 602 603 assertUsabilityEvaluationResult 604 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 605 606 // ===== check ===== 607 spec = 608 "Sequence {" + 609 " TextInput (a b c) {}" + 610 " Sequence {" + 611 " TextInput (a) {}" + 612 " TextInput (b) {}" + 613 " TextInput (c) {}" + 614 " }" + 615 "}"; 616 617 expectedDefects = new UsabilityDefect[] 618 { 619 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 620 new UsabilityDefect(LOW, TEXT_FIELD_INPUT_REPETITIONS) 621 }; 622 623 assertUsabilityEvaluationResult 624 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 625 626 // ===== check ===== 627 spec = 628 "Sequence {" + 629 " TextInput (a b c) {}" + 630 " Sequence {" + 631 " TextInput (a) {}" + 632 " TextInput (a) {}" + 633 " TextInput (b) {}" + 634 " }" + 635 "}"; 636 637 expectedDefects = new UsabilityDefect[] 638 { 639 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 640 new UsabilityDefect(LOW, TEXT_FIELD_INPUT_REPETITIONS) 641 }; 642 643 assertUsabilityEvaluationResult 644 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 645 646 // ===== check ===== 647 spec = 648 "Sequence {" + 649 " TextInput (a b c) {}" + 650 " Sequence {" + 651 " TextInput (a) {}" + 652 " TextInput (d) {}" + 653 " TextInput (e) {}" + 654 " }" + 655 "}"; 656 657 expectedDefects = new UsabilityDefect[] 658 { 659 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 660 new UsabilityDefect(INFO, TEXT_FIELD_INPUT_REPETITIONS) 661 }; 662 663 assertUsabilityEvaluationResult 664 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 665 666 } 667 668 //----------------------------------------------------------------------------------------------- 669 /** 670 * TODO: comment 671 * 672 */ 673 //----------------------------------------------------------------------------------------------- 674 @Test 675 public void testNoLetterOrDigitInput() 676 { 677 UsabilityEvaluationManager manager = new UsabilityEvaluationManager(); 678 679 // ===== check ===== 680 String spec = 681 "Sequence {" + 682 " TextInput (_a_b_c_) {}" + 683 "}"; 684 685 UsabilityDefect[] expectedDefects = new UsabilityDefect[] 686 { 687 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 688 new UsabilityDefect(HIGH, TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO) 689 }; 690 691 assertUsabilityEvaluationResult 692 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 693 694 // ===== check ===== 695 spec = 696 "Sequence {" + 697 " TextInput (12345_6789012345) {}" + 698 "}"; 699 700 expectedDefects = new UsabilityDefect[] 701 { 702 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 703 new UsabilityDefect(MEDIUM, TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO) 704 }; 705 706 assertUsabilityEvaluationResult 707 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 708 709 // ===== check ===== 710 spec = 711 "Sequence {" + 712 " TextInput (123456789012345678901234567890_123456789012345) {}" + 713 "}"; 714 715 expectedDefects = new UsabilityDefect[] 716 { 717 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 718 new UsabilityDefect(LOW, TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO) 719 }; 720 721 assertUsabilityEvaluationResult 722 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 723 724 // ===== check ===== 725 spec = 726 "Sequence {" + 727 " TextInput (1234567890123456789012345678901234567890123456789_01234567890" + 728 "12345678901234567890123456789012345) {}" + 729 "}"; 730 731 expectedDefects = new UsabilityDefect[] 732 { 733 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 734 new UsabilityDefect(INFO, TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO) 735 }; 736 737 assertUsabilityEvaluationResult 738 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 739 740 } 26 public class TextInputStatisticsRuleTest extends AbstractUsabilityEvaluationTC { 27 28 /** 29 * TODO: comment 30 * 31 */ 32 @Test 33 public void testWithDifferentTextInputInteractionsOnly() { 34 UsabilityEvaluationManager manager = new UsabilityEvaluationManager(); 35 36 // ===== check ===== 37 String spec = 38 "TextInput (bla) {}"; 39 UsabilityDefect[] expectedDefects = new UsabilityDefect[] 40 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) }; 41 42 assertUsabilityEvaluationResult 43 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 44 45 // ===== check ===== 46 spec = 47 "Sequence {" + 48 " TextInput (bla) {}" + 49 "}"; 50 51 expectedDefects = new UsabilityDefect[] 52 { new UsabilityDefect(HIGH, UsabilityDefectDescription.TEXT_FIELD_INPUT_RATIO) }; 53 54 assertUsabilityEvaluationResult 55 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 56 57 // ===== check ===== 58 spec = 59 "Sequence {" + 60 " TextInput (a) {}" + 61 " TextInput (b) {}" + 62 " TextInput (c) {}" + 63 " TextInput (d) {}" + 64 "}"; 65 66 expectedDefects = new UsabilityDefect[] 67 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) }; 68 69 assertUsabilityEvaluationResult 70 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 71 72 // ===== check ===== 73 spec = 74 "Selection {" + 75 " TextInput (a) {}" + 76 " TextInput (b) {}" + 77 " TextInput (c) {}" + 78 " TextInput (d) {}" + 79 "}"; 80 81 expectedDefects = new UsabilityDefect[] 82 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) }; 83 84 assertUsabilityEvaluationResult 85 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 86 87 // ===== check ===== 88 spec = 89 "Iteration {" + 90 " TextInput (bla) {}" + 91 "}"; 92 93 expectedDefects = new UsabilityDefect[] 94 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) }; 95 96 assertUsabilityEvaluationResult 97 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 98 99 // ===== check ===== 100 spec = 101 "Sequence {" + 102 " TextInput (a) {}" + 103 " Sequence {" + 104 " TextInput (b) {}" + 105 " TextInput (c) {}" + 106 " TextInput (d) {}" + 107 " TextInput (e) {}" + 108 " }" + 109 " Iteration {" + 110 " TextInput (f) {}" + 111 " }" + 112 " TextInput (g) {}" + 113 " Selection {" + 114 " TextInput (h) {}" + 115 " TextInput (i) {}" + 116 " TextInput (j) {}" + 117 " TextInput (k) {}" + 118 " }" + 119 " Sequence {" + 120 " TextInput (l) {}" + 121 " Sequence {" + 122 " TextInput (m) {}" + 123 " TextInput (n) {}" + 124 " TextInput (o) {}" + 125 " TextInput (p) {}" + 126 " }" + 127 " Iteration {" + 128 " TextInput (q) {}" + 129 " }" + 130 " TextInput (r) {}" + 131 " Selection {" + 132 " TextInput (s) {}" + 133 " TextInput (t) {}" + 134 " TextInput (u) {}" + 135 " TextInput (v) {}" + 136 " }" + 137 " }" + 138 " Selection {" + 139 " TextInput (w) {}" + 140 " Sequence {" + 141 " TextInput (x) {}" + 142 " TextInput (y) {}" + 143 " TextInput (z) {}" + 144 " TextInput (aa) {}" + 145 " }" + 146 " Iteration {" + 147 " TextInput (ab) {}" + 148 " }" + 149 " TextInput (ac) {}" + 150 " Selection {" + 151 " TextInput (ad) {}" + 152 " TextInput (ae) {}" + 153 " TextInput (af) {}" + 154 " TextInput (ag) {}" + 155 " }" + 156 " }" + 157 " TextInput (ah) {}" + 158 "}"; 159 160 expectedDefects = new UsabilityDefect[] 161 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO) }; 162 163 assertUsabilityEvaluationResult 164 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 165 } 166 167 /** 168 * TODO: comment 169 * 170 */ 171 @Test 172 public void testCombinationsOfTextInputInteractionsAndOtherInteractions() { 173 UsabilityEvaluationManager manager = new UsabilityEvaluationManager(); 174 175 // ===== check ===== 176 String spec = 177 "Sequence {" + 178 " Interaction {}" + 179 " TextInput (a) {}" + 180 " TextInput (b) {}" + 181 " Interaction {}" + 182 " TextInput (c) {}" + 183 "}"; 184 185 UsabilityDefect[] expectedDefects = new UsabilityDefect[] 186 { new UsabilityDefect(LOW, TEXT_FIELD_INPUT_RATIO) }; 187 188 assertUsabilityEvaluationResult 189 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 190 191 // ===== check ===== 192 spec = 193 "Sequence {" + 194 " Interaction {}" + 195 " TextInput (a) {}" + 196 " Interaction {}" + 197 " Interaction {}" + 198 " TextInput (c) {}" + 199 "}"; 200 201 expectedDefects = new UsabilityDefect[] 202 { new UsabilityDefect(INFO, TEXT_FIELD_INPUT_RATIO) }; 203 204 assertUsabilityEvaluationResult 205 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 206 207 // ===== check ===== 208 spec = 209 "Sequence {" + 210 " Interaction {}" + 211 " TextInput (a) {}" + 212 " Interaction {}" + 213 " Interaction {}" + 214 " Interaction {}" + 215 "}"; 216 217 expectedDefects = new UsabilityDefect[0]; 218 219 assertUsabilityEvaluationResult 220 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 221 222 // ===== check ===== 223 spec = 224 "Selection {" + 225 " Interaction {}" + 226 " TextInput (a) {}" + 227 " TextInput (b) {}" + 228 " Interaction {}" + 229 " TextInput (c) {}" + 230 "}"; 231 232 expectedDefects = new UsabilityDefect[] 233 { new UsabilityDefect(LOW, TEXT_FIELD_INPUT_RATIO) }; 234 235 assertUsabilityEvaluationResult 236 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 237 238 // ===== check ===== 239 spec = 240 "Sequence {" + 241 " TextInput (a) {}" + 242 " Sequence {" + 243 " Interaction {}" + 244 " TextInput (b) {}" + 245 " TextInput (c) {}" + 246 " Interaction {}" + 247 " TextInput (d) {}" + 248 " }" + 249 " Iteration {" + 250 " TextInput (e) {}" + 251 " }" + 252 " Interaction {}" + 253 " Selection {" + 254 " Interaction {}" + 255 " TextInput (f) {}" + 256 " TextInput (g) {}" + 257 " Interaction {}" + 258 " TextInput (h) {}" + 259 " TextInput (i) {}" + 260 " }" + 261 " Sequence {" + 262 " TextInput (j) {}" + 263 " Sequence {" + 264 " TextInput (k) {}" + 265 " Interaction {}" + 266 " TextInput (l) {}" + 267 " TextInput (m) {}" + 268 " Interaction {}" + 269 " TextInput (n) {}" + 270 " TextInput (o) {}" + 271 " }" + 272 " Iteration {" + 273 " Interaction {}" + 274 " }" + 275 " Interaction {}" + 276 " Selection {" + 277 " TextInput (p) {}" + 278 " TextInput (q) {}" + 279 " TextInput (r) {}" + 280 " Interaction {}" + 281 " TextInput (s) {}" + 282 " TextInput (t) {}" + 283 " Interaction {}" + 284 " TextInput (u) {}" + 285 " TextInput (v) {}" + 286 " }" + 287 " }" + 288 " Selection {" + 289 " Interaction {}" + 290 " Sequence {" + 291 " TextInput (w) {}" + 292 " Interaction {}" + 293 " TextInput (x) {}" + 294 " TextInput (y) {}" + 295 " Interaction {}" + 296 " }" + 297 " Iteration {" + 298 " TextInput (z) {}" + 299 " }" + 300 " TextInput (aa) {}" + 301 " Selection {" + 302 " TextInput (ab) {}" + 303 " Interaction {}" + 304 " TextInput (ac) {}" + 305 " TextInput (ad) {}" + 306 " Interaction {}" + 307 " TextInput (ae) {}" + 308 " }" + 309 " }" + 310 " Interaction {}" + 311 "}"; 312 313 expectedDefects = new UsabilityDefect[] 314 { new UsabilityDefect(LOW, TEXT_FIELD_INPUT_RATIO) }; 315 316 assertUsabilityEvaluationResult 317 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 318 319 // ===== check ===== 320 spec = 321 "Sequence {" + 322 " TextInput (a) {}" + 323 " Sequence {" + 324 " Interaction {}" + 325 " TextInput (b) {}" + 326 " Interaction {}" + 327 " Interaction {}" + 328 " TextInput (c) {}" + 329 " }" + 330 " Iteration {" + 331 " TextInput (d) {}" + 332 " }" + 333 " Interaction {}" + 334 " Selection {" + 335 " Interaction {}" + 336 " TextInput (e) {}" + 337 " Interaction {}" + 338 " Interaction {}" + 339 " TextInput (g) {}" + 340 " Interaction {}" + 341 " }" + 342 " Sequence {" + 343 " TextInput (i) {}" + 344 " Sequence {" + 345 " TextInput (j) {}" + 346 " Interaction {}" + 347 " TextInput (k) {}" + 348 " Interaction {}" + 349 " Interaction {}" + 350 " TextInput (m) {}" + 351 " Interaction {}" + 352 " }" + 353 " Iteration {" + 354 " Interaction {}" + 355 " }" + 356 " Interaction {}" + 357 " Selection {" + 358 " TextInput (o) {}" + 359 " Interaction {}" + 360 " Interaction {}" + 361 " Interaction {}" + 362 " Interaction {}" + 363 " TextInput (s) {}" + 364 " Interaction {}" + 365 " TextInput (t) {}" + 366 " TextInput (u) {}" + 367 " }" + 368 " }" + 369 " Selection {" + 370 " Interaction {}" + 371 " Sequence {" + 372 " TextInput (v) {}" + 373 " Interaction {}" + 374 " Interaction {}" + 375 " TextInput (x) {}" + 376 " Interaction {}" + 377 " }" + 378 " Iteration {" + 379 " TextInput (y) {}" + 380 " }" + 381 " TextInput (z) {}" + 382 " Selection {" + 383 " TextInput (aa) {}" + 384 " Interaction {}" + 385 " TextInput (ab) {}" + 386 " Interaction {}" + 387 " Interaction {}" + 388 " TextInput (ad) {}" + 389 " }" + 390 " }" + 391 " Interaction {}" + 392 "}"; 393 394 expectedDefects = new UsabilityDefect[] 395 { new UsabilityDefect(INFO, TEXT_FIELD_INPUT_RATIO) }; 396 397 assertUsabilityEvaluationResult 398 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 399 } 400 401 /** 402 * TODO: comment 403 * 404 */ 405 @Test 406 public void testTextEntryRepetitions() { 407 UsabilityEvaluationManager manager = new UsabilityEvaluationManager(); 408 409 // ===== check ===== 410 String spec = 411 "Sequence {" + 412 " TextInput (a b c) {}" + 413 " Sequence {" + 414 " TextInput (a) {}" + 415 " TextInput (b) {}" + 416 " TextInput (c) {}" + 417 " TextInput (a) {}" + 418 " }" + 419 " Iteration {" + 420 " TextInput (a) {}" + 421 " }" + 422 " TextInput (a) {}" + 423 " Selection {" + 424 " TextInput (b c) {}" + 425 " TextInput (a) {}" + 426 " TextInput (a c) {}" + 427 " TextInput (b a) {}" + 428 " }" + 429 " Sequence {" + 430 " TextInput (b c) {}" + 431 " Sequence {" + 432 " TextInput (d a c) {}" + 433 " TextInput (b b b a) {}" + 434 " TextInput (a a c c) {}" + 435 " TextInput (b b a) {}" + 436 " }" + 437 " }" + 438 " TextInput (d) {}" + 439 "}"; 440 441 UsabilityDefect[] expectedDefects = new UsabilityDefect[] 442 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 443 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_REPETITIONS) }; 444 445 assertUsabilityEvaluationResult 446 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 447 448 // ===== check ===== 449 spec = 450 "Sequence {" + 451 " TextInput (a b c d e f g h i j k l m) {}" + 452 " Sequence {" + 453 " TextInput (a) {}" + 454 " TextInput (b) {}" + 455 " TextInput (c) {}" + 456 " TextInput (d) {}" + 457 " }" + 458 " Iteration {" + 459 " TextInput (e) {}" + 460 " }" + 461 " TextInput (f) {}" + 462 " Selection {" + 463 " TextInput (g) {}" + 464 " TextInput (h) {}" + 465 " TextInput (i) {}" + 466 " TextInput (j) {}" + 467 " }" + 468 " Sequence {" + 469 " TextInput (k) {}" + 470 " Sequence {" + 471 " TextInput (l) {}" + 472 " TextInput (m) {}" + 473 " TextInput (n) {}" + 474 " TextInput (o) {}" + 475 " }" + 476 " }" + 477 " TextInput (p) {}" + 478 "}"; 479 480 expectedDefects = new UsabilityDefect[] 481 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 482 new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_REPETITIONS) }; 483 484 assertUsabilityEvaluationResult 485 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 486 487 // ===== check ===== 488 spec = 489 "Sequence {" + 490 " TextInput (a b c d e f g h i j k l m) {}" + 491 " Sequence {" + 492 " TextInput (a) {}" + 493 " TextInput (b) {}" + 494 " TextInput (c) {}" + 495 " TextInput (d) {}" + 496 " }" + 497 " Iteration {" + 498 " TextInput (e) {}" + 499 " }" + 500 " TextInput (a) {}" + 501 " Selection {" + 502 " TextInput (b) {}" + 503 " TextInput (c) {}" + 504 " TextInput (d) {}" + 505 " TextInput (e) {}" + 506 " }" + 507 " Sequence {" + 508 " TextInput (a) {}" + 509 " Sequence {" + 510 " TextInput (b) {}" + 511 " TextInput (c) {}" + 512 " TextInput (d) {}" + 513 " TextInput (e) {}" + 514 " }" + 515 " }" + 516 " TextInput (f) {}" + 517 "}"; 518 519 expectedDefects = new UsabilityDefect[] 520 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 521 new UsabilityDefect(MEDIUM, TEXT_FIELD_INPUT_REPETITIONS) }; 522 523 assertUsabilityEvaluationResult 524 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 525 526 // ===== check ===== 527 spec = 528 "Sequence {" + 529 " TextInput (a b c d e f g h i j k l m) {}" + 530 " Sequence {" + 531 " TextInput (a) {}" + 532 " TextInput (b) {}" + 533 " TextInput (c) {}" + 534 " TextInput (a) {}" + 535 " }" + 536 " Iteration {" + 537 " TextInput (b) {}" + 538 " }" + 539 " TextInput (c) {}" + 540 " Selection {" + 541 " TextInput (a) {}" + 542 " TextInput (b) {}" + 543 " TextInput (c) {}" + 544 " TextInput (a) {}" + 545 " }" + 546 " Sequence {" + 547 " TextInput (b) {}" + 548 " Sequence {" + 549 " TextInput (c) {}" + 550 " TextInput (a) {}" + 551 " TextInput (b) {}" + 552 " TextInput (c) {}" + 553 " }" + 554 " }" + 555 " TextInput (a) {}" + 556 "}"; 557 558 expectedDefects = new UsabilityDefect[] 559 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 560 new UsabilityDefect(MEDIUM, TEXT_FIELD_INPUT_REPETITIONS) }; 561 562 assertUsabilityEvaluationResult 563 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 564 565 // ===== check ===== 566 spec = 567 "Sequence {" + 568 " TextInput (a b c) {}" + 569 " Sequence {" + 570 " TextInput (a) {}" + 571 " TextInput (b) {}" + 572 " TextInput (c) {}" + 573 " }" + 574 "}"; 575 576 expectedDefects = new UsabilityDefect[] 577 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 578 new UsabilityDefect(LOW, TEXT_FIELD_INPUT_REPETITIONS) }; 579 580 assertUsabilityEvaluationResult 581 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 582 583 // ===== check ===== 584 spec = 585 "Sequence {" + 586 " TextInput (a b c) {}" + 587 " Sequence {" + 588 " TextInput (a) {}" + 589 " TextInput (a) {}" + 590 " TextInput (b) {}" + 591 " }" + 592 "}"; 593 594 expectedDefects = new UsabilityDefect[] 595 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 596 new UsabilityDefect(LOW, TEXT_FIELD_INPUT_REPETITIONS) }; 597 598 assertUsabilityEvaluationResult 599 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 600 601 // ===== check ===== 602 spec = 603 "Sequence {" + 604 " TextInput (a b c) {}" + 605 " Sequence {" + 606 " TextInput (a) {}" + 607 " TextInput (d) {}" + 608 " TextInput (e) {}" + 609 " }" + 610 "}"; 611 612 expectedDefects = new UsabilityDefect[] 613 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 614 new UsabilityDefect(INFO, TEXT_FIELD_INPUT_REPETITIONS) }; 615 616 assertUsabilityEvaluationResult 617 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 618 619 } 620 621 /** 622 * TODO: comment 623 * 624 */ 625 @Test 626 public void testNoLetterOrDigitInput() { 627 UsabilityEvaluationManager manager = new UsabilityEvaluationManager(); 628 629 // ===== check ===== 630 String spec = 631 "Sequence {" + 632 " TextInput (_a_b_c_) {}" + 633 "}"; 634 635 UsabilityDefect[] expectedDefects = new UsabilityDefect[] 636 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 637 new UsabilityDefect(HIGH, TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO) }; 638 639 assertUsabilityEvaluationResult 640 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 641 642 // ===== check ===== 643 spec = 644 "Sequence {" + 645 " TextInput (12345_6789012345) {}" + 646 "}"; 647 648 expectedDefects = new UsabilityDefect[] 649 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 650 new UsabilityDefect(MEDIUM, TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO) }; 651 652 assertUsabilityEvaluationResult 653 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 654 655 // ===== check ===== 656 spec = 657 "Sequence {" + 658 " TextInput (123456789012345678901234567890_123456789012345) {}" + 659 "}"; 660 661 expectedDefects = new UsabilityDefect[] 662 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 663 new UsabilityDefect(LOW, TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO) }; 664 665 assertUsabilityEvaluationResult 666 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 667 668 // ===== check ===== 669 spec = 670 "Sequence {" + 671 " TextInput (1234567890123456789012345678901234567890123456789_01234567890" + 672 "12345678901234567890123456789012345) {}" + 673 "}"; 674 675 expectedDefects = new UsabilityDefect[] 676 { new UsabilityDefect(HIGH, TEXT_FIELD_INPUT_RATIO), 677 new UsabilityDefect(INFO, TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO) }; 678 679 assertUsabilityEvaluationResult 680 (expectedDefects, manager.evaluateUsability(createTaskTree(spec))); 681 682 } 741 683 } -
trunk/quest-core-usability-test/src/test/java/de/ugoe/cs/quest/usability/UsabilityDefectDescriptionTest.java
r497 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: UsabilityDefectDescriptionTest.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 20.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.quest.usability; 9 9 … … 16 16 import org.junit.Test; 17 17 18 //-------------------------------------------------------------------------------------------------19 18 /** 20 19 * TODO comment … … 23 22 * @author 2012, last modified by $Author: pharms$ 24 23 */ 25 //------------------------------------------------------------------------------------------------- 26 public class UsabilityDefectDescriptionTest 27 { 24 public class UsabilityDefectDescriptionTest { 28 25 29 //----------------------------------------------------------------------------------------------- 30 /** 31 * TODO: comment 32 * 33 */ 34 //----------------------------------------------------------------------------------------------- 35 @Test 36 public void testInitialization() 37 { 38 for (UsabilityDefectDescription description : UsabilityDefectDescription.values()) 39 { 40 assertNotNull(description.toString()); 41 assertNotSame("", description.toString()); 42 System.err.println(description); 26 /** 27 * TODO: comment 28 * 29 */ 30 @Test 31 public void testInitialization() { 32 for (UsabilityDefectDescription description : UsabilityDefectDescription.values()) { 33 assertNotNull(description.toString()); 34 assertNotSame("", description.toString()); 35 System.err.println(description); 36 } 43 37 } 44 }45 38 46 //----------------------------------------------------------------------------------------------- 47 /** 48 * TODO: comment 49 * 50 */ 51 //----------------------------------------------------------------------------------------------- 52 @Test 53 public void testParameterization() 54 { 55 for (UsabilityDefectDescription description : UsabilityDefectDescription.values()) 56 { 57 Map<String, String> parameters = new HashMap<String, String>(); 58 59 for (String parameter : description.getDescriptionParameters()) 60 { 61 parameters.put(parameter, "<parameter " + parameter + ">"); 62 } 63 64 assertNotNull(description.toString(parameters)); 65 assertNotSame("", description.toString(parameters)); 66 System.err.println(description.toString(parameters)); 39 /** 40 * TODO: comment 41 * 42 */ 43 @Test 44 public void testParameterization() { 45 for (UsabilityDefectDescription description : UsabilityDefectDescription.values()) { 46 Map<String, String> parameters = new HashMap<String, String>(); 47 48 for (String parameter : description.getDescriptionParameters()) { 49 parameters.put(parameter, "<parameter " + parameter + ">"); 50 } 51 52 assertNotNull(description.toString(parameters)); 53 assertNotSame("", description.toString(parameters)); 54 System.err.println(description.toString(parameters)); 55 } 67 56 } 68 }69 57 70 58 } -
trunk/quest-core-usability/src/main/java/de/ugoe/cs/quest/usability/TextInputStatisticsRule.java
r496 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: TextInputStatisticsRule.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 16.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.quest.usability; 9 9 … … 14 14 import java.util.Map; 15 15 16 import de.ugoe.cs.quest.eventcore.guimodel.TextArea; 17 import de.ugoe.cs.quest.eventcore.guimodel.TextField; 18 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTree; 19 import de.ugoe.cs.quest.tasktrees.treeifc.TaskTreeNode; 20 import de.ugoe.cs.quest.tasktrees.treeifc.TextInputInteractionTask; 21 22 //------------------------------------------------------------------------------------------------- 16 import de.ugoe.cs.quest.eventcore.guimodel.ITextArea; 17 import de.ugoe.cs.quest.eventcore.guimodel.ITextField; 18 import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTree; 19 import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNode; 20 import de.ugoe.cs.quest.tasktrees.treeifc.ITextInputEventTask; 21 23 22 /** 24 23 * TODO comment … … 27 26 * @author 2012, last modified by $Author: pharms$ 28 27 */ 29 //------------------------------------------------------------------------------------------------- 30 public class TextInputStatisticsRule implements de.ugoe.cs.quest.usability.UsabilityEvaluationRule 31 { 32 33 //----------------------------------------------------------------------------------------------- 34 /* (non-Javadoc) 35 * @see de.ugoe.cs.usability.UsabilityEvaluationRule#evaluate(TaskTree) 36 */ 37 //----------------------------------------------------------------------------------------------- 38 @Override 39 public UsabilityEvaluationResult evaluate(TaskTree taskTree) 40 { 41 TextInputStatistics statistics = new TextInputStatistics(); 42 calculateStatistics(taskTree.getRoot(), statistics); 43 44 UsabilityEvaluationResult results = new UsabilityEvaluationResult(); 45 analyzeStatistics(statistics, results); 46 47 return results; 48 } 49 50 //----------------------------------------------------------------------------------------------- 51 /** 52 * TODO: comment 53 * 54 * @param statistics 55 * @param results 56 */ 57 //----------------------------------------------------------------------------------------------- 58 private void analyzeStatistics(TextInputStatistics statistics, UsabilityEvaluationResult results) 59 { 60 checkTextInputRatio(statistics, results); 61 checkTextFieldEntryRepetitions(statistics, results); 62 checkTextFieldNoLetterOrDigitInputs(statistics, results); 63 } 64 65 //----------------------------------------------------------------------------------------------- 66 /** 67 * TODO: comment 68 * 69 * @param statistics 70 * @param results 71 */ 72 //----------------------------------------------------------------------------------------------- 73 private void checkTextInputRatio(TextInputStatistics statistics, 28 public class TextInputStatisticsRule implements de.ugoe.cs.quest.usability.UsabilityEvaluationRule { 29 30 /* 31 * (non-Javadoc) 32 * 33 * @see de.ugoe.cs.usability.UsabilityEvaluationRule#evaluate(TaskTree) 34 */ 35 @Override 36 public UsabilityEvaluationResult evaluate(ITaskTree taskTree) { 37 TextInputStatistics statistics = new TextInputStatistics(); 38 calculateStatistics(taskTree.getRoot(), statistics); 39 40 UsabilityEvaluationResult results = new UsabilityEvaluationResult(); 41 analyzeStatistics(statistics, results); 42 43 return results; 44 } 45 46 /** 47 * TODO: comment 48 * 49 * @param statistics 50 * @param results 51 */ 52 private void analyzeStatistics(TextInputStatistics statistics, 74 53 UsabilityEvaluationResult results) 75 {76 float allTextFieldInputs =77 statistics.getNoOfTextFieldInputs() + statistics.getNoOfTextAreaInputs();78 79 float ratio = allTextFieldInputs / (float) statistics.getNoOfAllInteractions();80 81 UsabilityDefectSeverity severity = null;82 if (ratio > 0.9)83 54 { 84 severity = UsabilityDefectSeverity.HIGH; 85 } 86 else if (ratio > 0.7) 55 checkTextInputRatio(statistics, results); 56 checkTextFieldEntryRepetitions(statistics, results); 57 checkTextFieldNoLetterOrDigitInputs(statistics, results); 58 } 59 60 /** 61 * TODO: comment 62 * 63 * @param statistics 64 * @param results 65 */ 66 private void checkTextInputRatio(TextInputStatistics statistics, 67 UsabilityEvaluationResult results) 87 68 { 88 severity = UsabilityDefectSeverity.MEDIUM; 89 } 90 else if (ratio > 0.5) 69 float allTextFieldInputs = 70 statistics.getNoOfTextFieldInputs() + statistics.getNoOfTextAreaInputs(); 71 72 float ratio = allTextFieldInputs / (float) statistics.getNoOfAllEvents(); 73 74 UsabilityDefectSeverity severity = null; 75 if (ratio > 0.9) { 76 severity = UsabilityDefectSeverity.HIGH; 77 } 78 else if (ratio > 0.7) { 79 severity = UsabilityDefectSeverity.MEDIUM; 80 } 81 else if (ratio > 0.5) { 82 severity = UsabilityDefectSeverity.LOW; 83 } 84 else if (ratio > 0.3) { 85 severity = UsabilityDefectSeverity.INFO; 86 } 87 88 if (severity != null) { 89 Map<String, String> parameters = new HashMap<String, String>(); 90 parameters.put("textInputRatio", DecimalFormat.getInstance().format(ratio * 100) + "%"); 91 92 results.addDefect 93 (new UsabilityDefect(severity, UsabilityDefectDescription.TEXT_FIELD_INPUT_RATIO, 94 parameters)); 95 } 96 } 97 98 /** 99 * TODO: comment 100 * 101 * @param statistics 102 * @param results 103 */ 104 private void checkTextFieldEntryRepetitions(TextInputStatistics statistics, 105 UsabilityEvaluationResult results) 91 106 { 92 severity = UsabilityDefectSeverity.LOW; 93 } 94 else if (ratio > 0.3) 107 Map<String, Integer> words = new HashMap<String, Integer>(); 108 int numberOfRepeatedWords = 0; 109 int maxRepetitions = 0; 110 111 for (int i = 0; i < statistics.getNoOfTextFieldInputs(); i++) { 112 String[] fragments = statistics.getTextFieldInputFragments(i); 113 for (String fragment : fragments) { 114 if (!"".equals(fragment.trim())) { 115 Integer count = words.get(fragment); 116 if (count == null) { 117 words.put(fragment, 1); 118 } 119 else { 120 count++; 121 words.put(fragment, count); 122 maxRepetitions = Math.max(count, maxRepetitions); 123 124 if (count == 2) { 125 // do not calculate repeated words several times 126 numberOfRepeatedWords++; 127 } 128 } 129 } 130 } 131 } 132 133 UsabilityDefectSeverity severity = null; 134 if ((numberOfRepeatedWords > 10) || (maxRepetitions > 10)) { 135 severity = UsabilityDefectSeverity.HIGH; 136 } 137 else if ((numberOfRepeatedWords > 4) || (maxRepetitions > 4)) { 138 severity = UsabilityDefectSeverity.MEDIUM; 139 } 140 else if ((numberOfRepeatedWords > 2) || (maxRepetitions > 2)) { 141 severity = UsabilityDefectSeverity.LOW; 142 } 143 else if ((numberOfRepeatedWords > 1) || (maxRepetitions > 1)) { 144 severity = UsabilityDefectSeverity.INFO; 145 } 146 147 if (severity != null) { 148 Map<String, String> parameters = new HashMap<String, String>(); 149 parameters.put("textRepetitionRatio", numberOfRepeatedWords + 150 " repeated tokens, up to " + maxRepetitions + " repetitions per token"); 151 152 results.addDefect 153 (new UsabilityDefect(severity, 154 UsabilityDefectDescription.TEXT_FIELD_INPUT_REPETITIONS, 155 parameters)); 156 } 157 } 158 159 /** 160 * TODO: comment 161 * 162 * @param statistics 163 * @param results 164 */ 165 private void checkTextFieldNoLetterOrDigitInputs(TextInputStatistics statistics, 166 UsabilityEvaluationResult results) 95 167 { 96 severity = UsabilityDefectSeverity.INFO; 97 } 98 99 if (severity != null) 100 { 101 Map<String, String> parameters = new HashMap<String, String>(); 102 parameters.put("textInputRatio", DecimalFormat.getInstance().format(ratio * 100) + "%"); 103 104 results.addDefect 105 (new UsabilityDefect 106 (severity, UsabilityDefectDescription.TEXT_FIELD_INPUT_RATIO, parameters)); 107 } 108 } 109 110 //----------------------------------------------------------------------------------------------- 111 /** 112 * TODO: comment 113 * 114 * @param statistics 115 * @param results 116 */ 117 //----------------------------------------------------------------------------------------------- 118 private void checkTextFieldEntryRepetitions(TextInputStatistics statistics, 119 UsabilityEvaluationResult results) 120 { 121 Map<String, Integer> words = new HashMap<String, Integer>(); 122 int numberOfRepeatedWords = 0; 123 int maxRepetitions = 0; 124 125 for (int i = 0; i < statistics.getNoOfTextFieldInputs(); i++) 126 { 127 String[] fragments = statistics.getTextFieldInputFragments(i); 128 for (String fragment : fragments) 129 { 130 if (!"".equals(fragment.trim())) 168 int allCharactersCount = 0; 169 int noLetterOrDigitCount = 0; 170 171 for (int i = 0; i < statistics.getNoOfTextFieldInputs(); i++) { 172 String[] fragments = statistics.getTextFieldInputFragments(i); 173 for (String fragment : fragments) { 174 String effectiveFragment = fragment.trim(); 175 for (int j = 0; j < effectiveFragment.length(); j++) { 176 if (!Character.isWhitespace(effectiveFragment.charAt(j))) { 177 if (!Character.isLetterOrDigit(effectiveFragment.charAt(j))) { 178 noLetterOrDigitCount++; 179 } 180 allCharactersCount++; 181 } 182 } 183 } 184 } 185 186 float ratio = (float) noLetterOrDigitCount / (float) allCharactersCount; 187 188 UsabilityDefectSeverity severity = null; 189 if (ratio > 0.1) // every 10th sign 131 190 { 132 Integer count = words.get(fragment); 133 if (count == null) 134 { 135 words.put(fragment, 1); 136 } 137 else 138 { 139 count++; 140 words.put(fragment, count); 141 maxRepetitions = Math.max(count, maxRepetitions); 142 143 if (count == 2) 144 { 145 // do not calculate repeated words several times 146 numberOfRepeatedWords++; 191 severity = UsabilityDefectSeverity.HIGH; 192 } 193 else if (ratio > 0.05) // every 20th sign 194 { 195 severity = UsabilityDefectSeverity.MEDIUM; 196 } 197 else if (ratio > 0.02) // every 50th sign 198 { 199 severity = UsabilityDefectSeverity.LOW; 200 } 201 else if (ratio > 0.01) // every 100th sign 202 { 203 severity = UsabilityDefectSeverity.INFO; 204 } 205 206 if (severity != null) { 207 Map<String, String> parameters = new HashMap<String, String>(); 208 parameters.put("noLetterOrDigitRatio", allCharactersCount + " entered characters of " + 209 "which " + noLetterOrDigitCount + " were no letter or digit"); 210 211 results.addDefect 212 (new UsabilityDefect(severity, 213 UsabilityDefectDescription.TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO, 214 parameters)); 215 } 216 } 217 218 /** 219 * TODO: comment 220 * 221 * @param taskTree 222 * @param statistics 223 */ 224 private void calculateStatistics(ITaskTreeNode node, TextInputStatistics statistics) { 225 if (node instanceof ITextInputEventTask) { 226 calculateStatistics((ITextInputEventTask) node, statistics); 227 } 228 else { 229 if ((node.getChildren() == null) || (node.getChildren().size() == 0)) { 230 statistics.incrementNoOfOtherEventTasks(); 147 231 } 148 } 149 } 150 } 151 } 152 153 UsabilityDefectSeverity severity = null; 154 if ((numberOfRepeatedWords > 10) || (maxRepetitions > 10)) 155 { 156 severity = UsabilityDefectSeverity.HIGH; 157 } 158 else if ((numberOfRepeatedWords > 4) || (maxRepetitions > 4)) 159 { 160 severity = UsabilityDefectSeverity.MEDIUM; 161 } 162 else if ((numberOfRepeatedWords > 2) || (maxRepetitions > 2)) 163 { 164 severity = UsabilityDefectSeverity.LOW; 165 } 166 else if ((numberOfRepeatedWords > 1) || (maxRepetitions > 1)) 167 { 168 severity = UsabilityDefectSeverity.INFO; 169 } 170 171 if (severity != null) 172 { 173 Map<String, String> parameters = new HashMap<String, String>(); 174 parameters.put("textRepetitionRatio", numberOfRepeatedWords + " repeated tokens, up to " + 175 maxRepetitions + " repetitions per token"); 176 177 results.addDefect 178 (new UsabilityDefect 179 (severity, UsabilityDefectDescription.TEXT_FIELD_INPUT_REPETITIONS, parameters)); 180 } 181 } 182 183 //----------------------------------------------------------------------------------------------- 184 /** 185 * TODO: comment 186 * 187 * @param statistics 188 * @param results 189 */ 190 //----------------------------------------------------------------------------------------------- 191 private void checkTextFieldNoLetterOrDigitInputs(TextInputStatistics statistics, 192 UsabilityEvaluationResult results) 193 { 194 int allCharactersCount = 0; 195 int noLetterOrDigitCount = 0; 196 197 for (int i = 0; i < statistics.getNoOfTextFieldInputs(); i++) 198 { 199 String[] fragments = statistics.getTextFieldInputFragments(i); 200 for (String fragment : fragments) 201 { 202 String effectiveFragment = fragment.trim(); 203 for (int j = 0; j < effectiveFragment.length(); j++) 204 { 205 if (!Character.isWhitespace(effectiveFragment.charAt(j))) 206 { 207 if (!Character.isLetterOrDigit(effectiveFragment.charAt(j))) 208 { 209 noLetterOrDigitCount++; 232 else { 233 for (ITaskTreeNode child : node.getChildren()) { 234 calculateStatistics(child, statistics); 235 } 210 236 } 211 allCharactersCount++; 212 } 213 } 214 } 215 } 216 217 float ratio = (float) noLetterOrDigitCount / (float) allCharactersCount; 218 219 UsabilityDefectSeverity severity = null; 220 if (ratio > 0.1) // every 10th sign 221 { 222 severity = UsabilityDefectSeverity.HIGH; 223 } 224 else if (ratio > 0.05) // every 20th sign 225 { 226 severity = UsabilityDefectSeverity.MEDIUM; 227 } 228 else if (ratio > 0.02) // every 50th sign 229 { 230 severity = UsabilityDefectSeverity.LOW; 231 } 232 else if (ratio > 0.01) // every 100th sign 233 { 234 severity = UsabilityDefectSeverity.INFO; 235 } 236 237 if (severity != null) 238 { 239 Map<String, String> parameters = new HashMap<String, String>(); 240 parameters.put("noLetterOrDigitRatio", allCharactersCount + " entered characters of " + 241 "which " + noLetterOrDigitCount + " were no letter or digit"); 242 243 results.addDefect 244 (new UsabilityDefect 245 (severity, UsabilityDefectDescription.TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO, parameters)); 246 } 247 } 248 249 //----------------------------------------------------------------------------------------------- 250 /** 251 * TODO: comment 252 * 253 * @param taskTree 254 * @param statistics 255 */ 256 //----------------------------------------------------------------------------------------------- 257 private void calculateStatistics(TaskTreeNode node, TextInputStatistics statistics) 258 { 259 if (node instanceof TextInputInteractionTask) 260 { 261 calculateStatistics((TextInputInteractionTask) node, statistics); 262 } 263 else 264 { 265 if ((node.getChildren() == null) || 266 (node.getChildren().size() == 0)) 267 { 268 statistics.incrementNoOfOtherInteractionTasks(); 269 } 270 else 271 { 272 for (TaskTreeNode child : node.getChildren()) 273 { 274 calculateStatistics(child, statistics); 275 } 276 } 277 } 278 } 279 280 //----------------------------------------------------------------------------------------------- 281 /** 282 * TODO: comment 283 * 284 * @param taskTree 285 * @param statistics 286 */ 287 //----------------------------------------------------------------------------------------------- 288 private void calculateStatistics(TextInputInteractionTask node, TextInputStatistics statistics) 289 { 290 String[] fragments = determineTextFragments(node.getEnteredText()); 291 292 if (node.getGUIElement() instanceof TextField) 293 { 294 statistics.addTextFieldInput(node, fragments); 295 } 296 else if (node.getGUIElement() instanceof TextArea) 297 { 298 statistics.addTextAreaInput(node, fragments); 299 } 300 } 301 302 //----------------------------------------------------------------------------------------------- 303 /** 304 * TODO: comment 305 * 306 * @param enteredText 307 * @return 308 */ 309 //----------------------------------------------------------------------------------------------- 310 private String[] determineTextFragments(String enteredText) 311 { 312 List<String> fragments = new ArrayList<String>(); 313 314 StringBuffer fragment = new StringBuffer(); 315 char lastChar = 0; 316 317 for (int i = 0; i < enteredText.length(); i++) 318 { 319 char currentChar = enteredText.charAt(i); 320 321 if (!isEqualCharacterType(lastChar, currentChar)) 322 { 323 // the previous fragment ended. so finalize it and start a new one 324 if ((fragment != null) && (fragment.length() > 0)) 325 { 326 fragments.add(fragment.toString()); 327 fragment = new StringBuffer(); 328 } 329 } 330 331 fragment.append(currentChar); 332 lastChar = currentChar; 333 } 334 335 if ((fragment != null) && (fragment.length() > 0)) 336 { 337 fragments.add(fragment.toString()); 338 } 339 340 return fragments.toArray(new String[fragments.size()]); 341 } 342 343 //----------------------------------------------------------------------------------------------- 344 /** 345 * TODO: comment 346 * 347 * @param lastChar 348 * @param currentChar 349 * @return 350 */ 351 //----------------------------------------------------------------------------------------------- 352 private boolean isEqualCharacterType(char char1, char char2) 353 { 354 return 355 ((char1 == char2) || 356 (Character.isWhitespace(char1) && Character.isWhitespace(char2)) || 357 (Character.isDigit(char1) && Character.isDigit(char2)) || 358 (Character.isLetter(char1) && Character.isLetter(char2)) || 359 (Character.isJavaIdentifierPart(char1) && Character.isJavaIdentifierPart(char2))); 360 } 361 362 //------------------------------------------------------------------------------------------------- 363 /** 364 * TODO comment 365 * 366 * @version $Revision: $ $Date: 16.07.2012$ 367 * @author 2012, last modified by $Author: pharms$ 368 */ 369 //------------------------------------------------------------------------------------------------- 370 public static class TextInputStatistics 371 { 372 /** */ 373 private List<Object[]> mTextFieldInputs = new ArrayList<Object[]>(); 374 375 /** */ 376 private List<Object[]> mTextAreaInputs = new ArrayList<Object[]>(); 377 378 /** */ 379 private int mOtherInteractionsCount; 380 381 //----------------------------------------------------------------------------------------------- 382 /** 383 * TODO: comment 384 * @param node 385 * @param fragments 386 * 387 */ 388 //----------------------------------------------------------------------------------------------- 389 public void addTextFieldInput(TextInputInteractionTask node, String[] fragments) 390 { 391 mTextFieldInputs.add(new Object[] { node, fragments }); 392 } 393 394 //----------------------------------------------------------------------------------------------- 395 /** 396 * TODO: comment 397 * @param node 398 * @param fragments 399 * 400 */ 401 //----------------------------------------------------------------------------------------------- 402 public void addTextAreaInput(TextInputInteractionTask node, String[] fragments) 403 { 404 mTextAreaInputs.add(new Object[] { node, fragments }); 405 } 406 407 //----------------------------------------------------------------------------------------------- 408 /** 409 * TODO: comment 410 * 237 } 238 } 239 240 /** 241 * TODO: comment 242 * 243 * @param taskTree 244 * @param statistics 245 */ 246 private void calculateStatistics(ITextInputEventTask node, TextInputStatistics statistics) { 247 String[] fragments = determineTextFragments(node.getEnteredText()); 248 249 if (node.getEventTarget() instanceof ITextField) { 250 statistics.addTextFieldInput(node, fragments); 251 } 252 else if (node.getEventTarget() instanceof ITextArea) { 253 statistics.addTextAreaInput(node, fragments); 254 } 255 } 256 257 /** 258 * TODO: comment 259 * 260 * @param enteredText 411 261 * @return 412 262 */ 413 //----------------------------------------------------------------------------------------------- 414 public int getNoOfAllInteractions() 415 { 416 return mTextFieldInputs.size() + mTextAreaInputs.size() + mOtherInteractionsCount; 417 } 418 419 //----------------------------------------------------------------------------------------------- 420 /** 421 * TODO: comment 422 * 263 private String[] determineTextFragments(String enteredText) { 264 List<String> fragments = new ArrayList<String>(); 265 266 StringBuffer fragment = new StringBuffer(); 267 char lastChar = 0; 268 269 for (int i = 0; i < enteredText.length(); i++) { 270 char currentChar = enteredText.charAt(i); 271 272 if (!isEqualCharacterType(lastChar, currentChar)) { 273 // the previous fragment ended. so finalize it and start a new one 274 if ((fragment != null) && (fragment.length() > 0)) { 275 fragments.add(fragment.toString()); 276 fragment = new StringBuffer(); 277 } 278 } 279 280 fragment.append(currentChar); 281 lastChar = currentChar; 282 } 283 284 if ((fragment != null) && (fragment.length() > 0)) { 285 fragments.add(fragment.toString()); 286 } 287 288 return fragments.toArray(new String[fragments.size()]); 289 } 290 291 /** 292 * TODO: comment 293 * 294 * @param lastChar 295 * @param currentChar 423 296 * @return 424 297 */ 425 //----------------------------------------------------------------------------------------------- 426 public int getNoOfTextFieldInputs() 427 { 428 return mTextFieldInputs.size(); 429 } 430 431 //----------------------------------------------------------------------------------------------- 432 /** 433 * TODO: comment 434 * 435 * @param i 436 * @return 437 */ 438 //----------------------------------------------------------------------------------------------- 439 public String[] getTextFieldInputFragments(int index) 440 { 441 return (String[]) mTextFieldInputs.get(index)[1]; 442 } 443 444 //----------------------------------------------------------------------------------------------- 445 /** 446 * TODO: comment 447 * 448 * @return 449 */ 450 //----------------------------------------------------------------------------------------------- 451 public int getNoOfTextAreaInputs() 452 { 453 return mTextAreaInputs.size(); 454 } 455 456 //----------------------------------------------------------------------------------------------- 457 /** 458 * TODO: comment 459 * 460 * @param i 461 * @return 462 */ 463 //----------------------------------------------------------------------------------------------- 464 public String[] getTextAreaInputFragments(int index) 465 { 466 return (String[]) mTextAreaInputs.get(index)[1]; 467 } 468 469 //----------------------------------------------------------------------------------------------- 470 /** 471 * TODO: comment 472 * 473 */ 474 //----------------------------------------------------------------------------------------------- 475 public void incrementNoOfOtherInteractionTasks() 476 { 477 mOtherInteractionsCount++; 478 } 479 480 481 } 298 private boolean isEqualCharacterType(char char1, char char2) { 299 return 300 ((char1 == char2) || 301 (Character.isWhitespace(char1) && Character.isWhitespace(char2)) || 302 (Character.isDigit(char1) && Character.isDigit(char2)) || 303 (Character.isLetter(char1) && Character.isLetter(char2)) || 304 (Character.isJavaIdentifierPart(char1) && Character.isJavaIdentifierPart(char2))); 305 } 306 307 /** 308 * TODO comment 309 * 310 * @version $Revision: $ $Date: 16.07.2012$ 311 * @author 2012, last modified by $Author: pharms$ 312 */ 313 public static class TextInputStatistics { 314 315 /** */ 316 private List<Object[]> textFieldInputs = new ArrayList<Object[]>(); 317 318 /** */ 319 private List<Object[]> textAreaInputs = new ArrayList<Object[]>(); 320 321 /** */ 322 private int otherEventsCount; 323 324 /** 325 * TODO: comment 326 * 327 * @param node 328 * @param fragments 329 * 330 */ 331 public void addTextFieldInput(ITextInputEventTask node, String[] fragments) { 332 textFieldInputs.add(new Object[] { node, fragments }); 333 } 334 335 /** 336 * TODO: comment 337 * 338 * @param node 339 * @param fragments 340 * 341 */ 342 public void addTextAreaInput(ITextInputEventTask node, String[] fragments) { 343 textAreaInputs.add(new Object[] { node, fragments }); 344 } 345 346 /** 347 * TODO: comment 348 * 349 * @return 350 */ 351 public int getNoOfAllEvents() { 352 return textFieldInputs.size() + textAreaInputs.size() + otherEventsCount; 353 } 354 355 /** 356 * TODO: comment 357 * 358 * @return 359 */ 360 public int getNoOfTextFieldInputs() { 361 return textFieldInputs.size(); 362 } 363 364 /** 365 * TODO: comment 366 * 367 * @param i 368 * @return 369 */ 370 public String[] getTextFieldInputFragments(int index) { 371 return (String[]) textFieldInputs.get(index)[1]; 372 } 373 374 /** 375 * TODO: comment 376 * 377 * @return 378 */ 379 public int getNoOfTextAreaInputs() { 380 return textAreaInputs.size(); 381 } 382 383 /** 384 * TODO: comment 385 * 386 * @param i 387 * @return 388 */ 389 public String[] getTextAreaInputFragments(int index) { 390 return (String[]) textAreaInputs.get(index)[1]; 391 } 392 393 /** 394 * TODO: comment 395 * 396 */ 397 public void incrementNoOfOtherEventTasks() { 398 otherEventsCount++; 399 } 400 401 } 482 402 483 403 } -
trunk/quest-core-usability/src/main/java/de/ugoe/cs/quest/usability/UsabilityDefect.java
r477 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: UsabilityDefect.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 16.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.quest.usability; 9 9 10 10 import java.util.Map; 11 11 12 //-------------------------------------------------------------------------------------------------13 12 /** 14 13 * TODO comment … … 17 16 * @author 2012, last modified by $Author: pharms$ 18 17 */ 19 //------------------------------------------------------------------------------------------------- 20 public class UsabilityDefect 21 { 18 public class UsabilityDefect { 22 19 23 /** */ 24 private UsabilityDefectSeverity mSeverity; 25 26 /** */ 27 private UsabilityDefectDescription mDescription; 20 /** */ 21 private UsabilityDefectSeverity severity; 28 22 29 /** */30 private Map<String, String> mDescriptionParameters;23 /** */ 24 private UsabilityDefectDescription description; 31 25 32 //----------------------------------------------------------------------------------------------- 33 /** 34 * TODO: comment 35 * 36 * @param medium 37 * @param highTextInputRatio 38 */ 39 //----------------------------------------------------------------------------------------------- 40 public UsabilityDefect(UsabilityDefectSeverity severity, 41 UsabilityDefectDescription description) 42 { 43 this(severity, description, null); 44 } 26 /** */ 27 private Map<String, String> descriptionParameters; 45 28 46 //----------------------------------------------------------------------------------------------- 47 /** 48 * TODO: comment 49 * 50 * @param medium 51 * @param highTextInputRatio 52 */ 53 //----------------------------------------------------------------------------------------------- 54 public UsabilityDefect(UsabilityDefectSeverity severity, 55 UsabilityDefectDescription description, 56 Map<String, String> parameters) 57 { 58 mSeverity = severity; 59 mDescription = description; 60 mDescriptionParameters = parameters; 61 } 29 /** 30 * TODO: comment 31 * 32 * @param medium 33 * @param highTextInputRatio 34 */ 35 public UsabilityDefect(UsabilityDefectSeverity severity, UsabilityDefectDescription description) 36 { 37 this(severity, description, null); 38 } 62 39 63 //----------------------------------------------------------------------------------------------- 64 /** 65 * TODO: comment 66 * 67 * @return 68 */ 69 //----------------------------------------------------------------------------------------------- 70 public UsabilityDefectSeverity getSeverity() 71 { 72 return mSeverity; 73 } 40 /** 41 * TODO: comment 42 * 43 * @param medium 44 * @param highTextInputRatio 45 */ 46 public UsabilityDefect(UsabilityDefectSeverity severity, 47 UsabilityDefectDescription description, 48 Map<String, String> parameters) 49 { 50 this.severity = severity; 51 this.description = description; 52 this.descriptionParameters = parameters; 53 } 74 54 75 //----------------------------------------------------------------------------------------------- 76 /** 77 * @param severity the severity to set 78 */ 79 //----------------------------------------------------------------------------------------------- 80 public void setSeverity(UsabilityDefectSeverity severity) 81 { 82 mSeverity = severity; 83 } 55 /** 56 * TODO: comment 57 * 58 * @return 59 */ 60 public UsabilityDefectSeverity getSeverity() { 61 return severity; 62 } 84 63 85 //----------------------------------------------------------------------------------------------- 86 /** 87 * @param description the description to set 88 */ 89 //----------------------------------------------------------------------------------------------- 90 public void setDescription(UsabilityDefectDescription description) 91 { 92 mDescription = description; 93 } 64 /** 65 * @param severity 66 * the severity to set 67 */ 68 public void setSeverity(UsabilityDefectSeverity severity) { 69 this.severity = severity; 70 } 94 71 95 //----------------------------------------------------------------------------------------------- 96 /** 72 /** 73 * @param description 74 * the description to set 75 */ 76 public void setDescription(UsabilityDefectDescription description) { 77 this.description = description; 78 } 79 80 /** 97 81 * 98 82 */ 99 //----------------------------------------------------------------------------------------------- 100 public String getParameterizedDescription() 101 { 102 return mDescription.toString(mDescriptionParameters); 103 } 83 public String getParameterizedDescription() { 84 return description.toString(descriptionParameters); 85 } 104 86 105 //----------------------------------------------------------------------------------------------- 106 /* (non-Javadoc) 107 * @see java.lang.Object#equals(java.lang.Object) 108 */ 109 //----------------------------------------------------------------------------------------------- 110 @Override 111 public boolean equals(Object obj) 112 { 113 if (obj instanceof UsabilityDefect) 114 { 115 return 116 (mSeverity == ((UsabilityDefect) obj).mSeverity) && 117 (mDescription == ((UsabilityDefect) obj).mDescription); 87 /* 88 * (non-Javadoc) 89 * 90 * @see java.lang.Object#equals(java.lang.Object) 91 */ 92 @Override 93 public boolean equals(Object obj) { 94 if (obj instanceof UsabilityDefect) { 95 return 96 (severity == ((UsabilityDefect) obj).severity) && 97 (description == ((UsabilityDefect) obj).description); 98 } 99 else { 100 return false; 101 } 118 102 } 119 else 120 { 121 return false; 103 104 /* 105 * (non-Javadoc) 106 * 107 * @see java.lang.Object#hashCode() 108 */ 109 @Override 110 public int hashCode() { 111 return severity.hashCode() + description.hashCode(); 122 112 } 123 }124 113 125 //----------------------------------------------------------------------------------------------- 126 /* (non-Javadoc) 127 * @see java.lang.Object#hashCode() 128 */ 129 //----------------------------------------------------------------------------------------------- 130 @Override 131 public int hashCode() 132 { 133 return mSeverity.hashCode() + mDescription.hashCode(); 134 } 135 136 //----------------------------------------------------------------------------------------------- 137 /* (non-Javadoc) 138 * @see java.lang.Object#toString() 139 */ 140 //----------------------------------------------------------------------------------------------- 141 @Override 142 public String toString() 143 { 144 return "UsabilityDefect(" + mSeverity.name() + ", " + mDescription.name() + ")"; 145 } 114 /* 115 * (non-Javadoc) 116 * 117 * @see java.lang.Object#toString() 118 */ 119 @Override 120 public String toString() { 121 return "UsabilityDefect(" + severity.name() + ", " + description.name() + ")"; 122 } 146 123 147 124 } -
trunk/quest-core-usability/src/main/java/de/ugoe/cs/quest/usability/UsabilityDefectDescription.java
r496 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: UsabilityDefectDescriptions.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 18.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 8 7 package de.ugoe.cs.quest.usability; 9 8 … … 18 17 import javax.xml.bind.Unmarshaller; 19 18 20 //-------------------------------------------------------------------------------------------------21 19 /** 22 20 * TODO comment … … 25 23 * @author 2012, last modified by $Author: pharms$ 26 24 */ 27 //------------------------------------------------------------------------------------------------- 28 public enum UsabilityDefectDescription 29 { 30 TEXT_FIELD_INPUT_RATIO, 31 TEXT_FIELD_INPUT_REPETITIONS, 32 TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO; 25 public enum UsabilityDefectDescription { 26 27 TEXT_FIELD_INPUT_RATIO, 28 TEXT_FIELD_INPUT_REPETITIONS, 29 TEXT_FIELD_NO_LETTER_OR_DIGIT_RATIO; 33 30 34 /** */ 35 private static final String DEFAULT_MESSAGES_FILE = "defectDescriptions_en.xml"; 36 37 /** */ 38 private static DefectDescriptions sDefectDescriptions; 31 /** */ 32 private static final String DEFAULT_MESSAGES_FILE = "defectDescriptions_en.xml"; 39 33 40 /** */ 41 private DefectDescription mDefectDescription; 42 43 //----------------------------------------------------------------------------------------------- 44 /** 45 * TODO: comment 46 * 47 * @param name 48 * @param ordinal 49 */ 50 //----------------------------------------------------------------------------------------------- 51 private UsabilityDefectDescription() 52 { 53 init(); 54 } 34 /** */ 35 private static DefectDescriptions sDefectDescriptions; 55 36 56 //----------------------------------------------------------------------------------------------- 57 /** 58 * TODO: comment 59 * 60 */ 61 //----------------------------------------------------------------------------------------------- 62 @SuppressWarnings("unchecked") 63 private void init() 64 { 65 synchronized (this.getClass()) 66 { 67 if (sDefectDescriptions == null) 68 { 69 InputStream inputStream = ClassLoader.getSystemResourceAsStream(DEFAULT_MESSAGES_FILE); 37 /** */ 38 private DefectDescription defectDescription; 70 39 71 try 72 { 73 String packageName = DefectDescriptions.class.getPackage().getName(); 74 JAXBContext jaxbContext = JAXBContext.newInstance(packageName); 75 Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); 76 77 sDefectDescriptions = 78 ((JAXBElement<DefectDescriptions>) unmarshaller.unmarshal(inputStream)).getValue(); 40 /** 41 * TODO: comment 42 * 43 * @param name 44 * @param ordinal 45 */ 46 private UsabilityDefectDescription() { 47 init(); 48 } 49 50 /** 51 * TODO: comment 52 * 53 */ 54 @SuppressWarnings("unchecked") 55 private void init() { 56 synchronized (this.getClass()) { 57 if (sDefectDescriptions == null) { 58 InputStream inputStream = 59 ClassLoader.getSystemResourceAsStream(DEFAULT_MESSAGES_FILE); 60 61 try { 62 String packageName = DefectDescriptions.class.getPackage().getName(); 63 JAXBContext jaxbContext = JAXBContext.newInstance(packageName); 64 Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); 65 66 sDefectDescriptions = 67 ((JAXBElement<DefectDescriptions>) unmarshaller.unmarshal(inputStream)) 68 .getValue(); 69 } 70 catch (Exception e) { 71 throw new RuntimeException 72 ("error while initializing usability defect descriptions", e); 73 } 74 finally { 75 if (inputStream != null) { 76 try { 77 inputStream.close(); 78 } 79 catch (IOException e) { 80 // ignore 81 } 82 } 83 } 84 } 79 85 } 80 catch (Exception e) 81 { 82 throw new RuntimeException("error while initializing usability defect descriptions", e); 86 87 for (DefectDescription description : sDefectDescriptions.getDefectDescription()) { 88 if (this.name().equals(description.getDefectId())) { 89 defectDescription = description; 90 break; 91 } 83 92 } 84 finally 85 { 86 if (inputStream != null) 87 { 88 try 89 { 90 inputStream.close(); 91 } 92 catch (IOException e) 93 { 94 // ignore 95 } 96 } 93 94 if (defectDescription == null) { 95 throw new RuntimeException 96 ("error while initializing usability defect descriptions. No " + 97 "description text available for description " + this.name()); 97 98 } 98 }99 99 } 100 101 for (DefectDescription description : sDefectDescriptions.getDefectDescription())102 {103 if (this.name().equals(description.getDefectId()))104 {105 mDefectDescription = description;106 break;107 }108 }109 110 if (mDefectDescription == null)111 {112 throw new RuntimeException("error while initializing usability defect descriptions. No " +113 "description text available for description " + this.name());114 }115 }116 100 117 //----------------------------------------------------------------------------------------------- 118 /** 101 /** 119 102 * 120 103 */ 121 //----------------------------------------------------------------------------------------------- 122 public String[] getDescriptionParameters() 123 { 124 List<String> parameters = new ArrayList<String>(); 125 126 for (Object fragment : mDefectDescription.getTextFragmentOrParameterFragment()) 127 { 128 if (fragment instanceof ParameterFragment) 129 { 130 parameters.add(((ParameterFragment) fragment).getParameterName()); 131 } 104 public String[] getDescriptionParameters() { 105 List<String> parameters = new ArrayList<String>(); 106 107 for (Object fragment : defectDescription.getTextFragmentOrParameterFragment()) { 108 if (fragment instanceof ParameterFragment) { 109 parameters.add(((ParameterFragment) fragment).getParameterName()); 110 } 111 } 112 113 return parameters.toArray(new String[parameters.size()]); 132 114 } 133 134 return parameters.toArray(new String[parameters.size()]); 135 } 136 137 //----------------------------------------------------------------------------------------------- 138 /** 115 116 /** 139 117 * 140 118 */ 141 //----------------------------------------------------------------------------------------------- 142 public String toString(Map<String, String> parameters) throws IllegalArgumentException 143 { 144 StringBuffer result = new StringBuffer(); 145 146 for (Object fragment : mDefectDescription.getTextFragmentOrParameterFragment()) 147 { 148 if (result.length() > 0) 149 { 150 result.append(" "); 151 } 152 153 if (fragment instanceof ParameterFragment) 154 { 155 String value = null; 156 if (parameters != null) 157 { 158 value = parameters.get(((ParameterFragment) fragment).getParameterName()); 119 public String toString(Map<String, String> parameters) throws IllegalArgumentException { 120 StringBuffer result = new StringBuffer(); 121 122 for (Object fragment : defectDescription.getTextFragmentOrParameterFragment()) { 123 if (result.length() > 0) { 124 result.append(" "); 125 } 126 127 if (fragment instanceof ParameterFragment) { 128 String value = null; 129 if (parameters != null) { 130 value = parameters.get(((ParameterFragment) fragment).getParameterName()); 131 } 132 133 if (value != null) { 134 result.append(value); 135 } 136 else { 137 throw new IllegalArgumentException 138 ("required parameter \"" + 139 ((ParameterFragment) fragment).getParameterName() + 140 "\" for usability defect description " + this.name() + " not provided"); 141 } 142 } 143 else { 144 result.append(getFragmentString(fragment)); 145 } 159 146 } 160 161 if (value != null) 162 { 163 result.append(value); 147 148 return result.toString(); 149 } 150 151 /* 152 * (non-Javadoc) 153 * 154 * @see java.lang.Enum#toString() 155 */ 156 @Override 157 public String toString() { 158 StringBuffer result = new StringBuffer(); 159 160 int paramCount = 1; 161 for (Object fragment : defectDescription.getTextFragmentOrParameterFragment()) { 162 if (result.length() > 0) { 163 result.append(" "); 164 } 165 166 if (fragment instanceof ParameterFragment) { 167 result.append("<parameter"); 168 result.append(paramCount++); 169 result.append(">"); 170 } 171 else { 172 result.append(getFragmentString(fragment)); 173 } 164 174 } 165 else 166 { 167 throw new IllegalArgumentException 168 ("required parameter \"" + ((ParameterFragment) fragment).getParameterName() + 169 "\" for usability defect description " + this.name() + " not provided"); 175 176 return result.toString(); 177 } 178 179 /** 180 * TODO: comment 181 * 182 * @param fragment 183 * @return 184 */ 185 private String getFragmentString(Object fragment) { 186 String fragmentStr = fragment.toString().trim(); 187 188 fragmentStr = fragmentStr.replaceAll("\n", " "); 189 190 while (fragmentStr.indexOf(" ") > -1) { 191 fragmentStr = fragmentStr.replaceAll(" ", " "); 170 192 } 171 } 172 else 173 { 174 result.append(getFragmentString(fragment)); 175 } 193 194 return fragmentStr; 176 195 } 177 178 return result.toString();179 }180 181 //-----------------------------------------------------------------------------------------------182 /* (non-Javadoc)183 * @see java.lang.Enum#toString()184 */185 //-----------------------------------------------------------------------------------------------186 @Override187 public String toString()188 {189 StringBuffer result = new StringBuffer();190 191 int paramCount = 1;192 for (Object fragment : mDefectDescription.getTextFragmentOrParameterFragment())193 {194 if (result.length() > 0)195 {196 result.append(" ");197 }198 199 if (fragment instanceof ParameterFragment)200 {201 result.append("<parameter");202 result.append(paramCount++);203 result.append(">");204 }205 else206 {207 result.append(getFragmentString(fragment));208 }209 }210 211 return result.toString();212 }213 214 //-----------------------------------------------------------------------------------------------215 /**216 * TODO: comment217 *218 * @param fragment219 * @return220 */221 //-----------------------------------------------------------------------------------------------222 private String getFragmentString(Object fragment)223 {224 String fragmentStr = fragment.toString().trim();225 226 fragmentStr = fragmentStr.replaceAll("\n", " ");227 228 while (fragmentStr.indexOf(" ") > -1)229 {230 fragmentStr = fragmentStr.replaceAll(" ", " ");231 }232 233 return fragmentStr;234 }235 196 236 197 } -
trunk/quest-core-usability/src/main/java/de/ugoe/cs/quest/usability/UsabilityDefectSeverity.java
r442 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: UsabilityDefectSeverity.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 16.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.quest.usability; 9 9 10 //-------------------------------------------------------------------------------------------------11 10 /** 12 11 * TODO comment … … 15 14 * @author 2012, last modified by $Author: pharms$ 16 15 */ 17 //------------------------------------------------------------------------------------------------- 18 public enum UsabilityDefectSeverity 19 { 20 INFO, 21 LOW, 22 MEDIUM, 23 HIGH; 16 public enum UsabilityDefectSeverity { 17 18 INFO, LOW, MEDIUM, HIGH; 19 24 20 } -
trunk/quest-core-usability/src/main/java/de/ugoe/cs/quest/usability/UsabilityEvaluationManager.java
r442 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: UsabilityEvaluationManager.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 16.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 8 7 package de.ugoe.cs.quest.usability; 9 8 … … 12 11 import java.util.logging.Logger; 13 12 14 import de.ugoe.cs.quest.tasktrees.treeifc. TaskTree;13 import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTree; 15 14 16 //-------------------------------------------------------------------------------------------------17 15 /** 18 16 * TODO comment … … 21 19 * @author 2012, last modified by $Author: pharms$ 22 20 */ 23 //------------------------------------------------------------------------------------------------- 24 public class UsabilityEvaluationManager 25 { 26 /** */ 27 private static Logger LOG = Logger.getLogger(UsabilityEvaluationManager.class.getName()); 21 public class UsabilityEvaluationManager { 22 23 /** */ 24 private static Logger LOG = Logger.getLogger(UsabilityEvaluationManager.class.getName()); 28 25 29 /** */ 30 private List<UsabilityEvaluationRule> mRules = new ArrayList<UsabilityEvaluationRule>(); 31 32 //----------------------------------------------------------------------------------------------- 33 /** 34 * TODO: comment 35 * 36 */ 37 //----------------------------------------------------------------------------------------------- 38 public UsabilityEvaluationManager() 39 { 40 super(); 41 init(); 42 } 26 /** */ 27 private List<UsabilityEvaluationRule> rules = new ArrayList<UsabilityEvaluationRule>(); 43 28 44 //----------------------------------------------------------------------------------------------- 45 /** 46 * TODO: comment 47 * 48 */ 49 //----------------------------------------------------------------------------------------------- 50 private void init() 51 { 52 mRules.add(new TextInputStatisticsRule()); 53 } 29 /** 30 * TODO: comment 31 * 32 */ 33 public UsabilityEvaluationManager() { 34 super(); 35 init(); 36 } 54 37 55 //----------------------------------------------------------------------------------------------- 56 /** 57 * TODO: comment 58 * 59 * @param taskTree 60 */ 61 //----------------------------------------------------------------------------------------------- 62 public UsabilityEvaluationResult evaluateUsability(TaskTree taskTree) 63 { 64 LOG.info("evaluating usability of task tree " + taskTree); 65 66 List<UsabilityEvaluationResult> results = new ArrayList<UsabilityEvaluationResult>(); 67 68 for (UsabilityEvaluationRule rule : mRules) 69 { 70 LOG.info("applying rule " + rule.getClass().getSimpleName()); 71 UsabilityEvaluationResult result = rule.evaluate(taskTree); 72 results.add(result); 73 LOG.info("the rule found " + result.getAllDefects().size() + " usability defects, of " + 74 "which " + result.getSevereDefects().size() + " are severe."); 38 /** 39 * TODO: comment 40 * 41 */ 42 private void init() { 43 rules.add(new TextInputStatisticsRule()); 75 44 } 76 77 UsabilityEvaluationResult result = mergeResults(results);78 LOG.info("the evaluation result contains " + result.getAllDefects().size() + " defects, of " +79 "which " + result.getSevereDefects().size() + " are severe.");80 return result;81 }82 45 83 //----------------------------------------------------------------------------------------------- 84 /** 85 * TODO: comment 86 * 87 * @param results 88 * @return 89 */ 90 //----------------------------------------------------------------------------------------------- 91 private UsabilityEvaluationResult mergeResults(List<UsabilityEvaluationResult> results) 92 { 93 UsabilityEvaluationResult result = new UsabilityEvaluationResult(); 94 95 for (UsabilityEvaluationResult ruleResult : results) 96 { 97 for (UsabilityDefect defect : ruleResult.getAllDefects()) 98 { 99 result.addDefect(defect); 100 } 46 /** 47 * TODO: comment 48 * 49 * @param taskTree 50 */ 51 public UsabilityEvaluationResult evaluateUsability(ITaskTree taskTree) { 52 LOG.info("evaluating usability of task tree " + taskTree); 53 54 List<UsabilityEvaluationResult> results = new ArrayList<UsabilityEvaluationResult>(); 55 56 for (UsabilityEvaluationRule rule : rules) { 57 LOG.info("applying rule " + rule.getClass().getSimpleName()); 58 UsabilityEvaluationResult result = rule.evaluate(taskTree); 59 results.add(result); 60 LOG.info("the rule found " + result.getAllDefects().size() + " usability defects, of " + 61 "which " + result.getSevereDefects().size() + " are severe."); 62 } 63 64 UsabilityEvaluationResult result = mergeResults(results); 65 LOG.info("the evaluation result contains " + result.getAllDefects().size() + 66 " defects, of which " + result.getSevereDefects().size() + " are severe."); 67 return result; 101 68 } 102 103 return result; 104 } 105 69 70 /** 71 * TODO: comment 72 * 73 * @param results 74 * @return 75 */ 76 private UsabilityEvaluationResult mergeResults(List<UsabilityEvaluationResult> results) { 77 UsabilityEvaluationResult result = new UsabilityEvaluationResult(); 78 79 for (UsabilityEvaluationResult ruleResult : results) { 80 for (UsabilityDefect defect : ruleResult.getAllDefects()) { 81 result.addDefect(defect); 82 } 83 } 84 85 return result; 86 } 87 106 88 } -
trunk/quest-core-usability/src/main/java/de/ugoe/cs/quest/usability/UsabilityEvaluationResult.java
r442 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: UsabilityEvaluationResult.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 16.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.quest.usability; 9 9 … … 11 11 import java.util.List; 12 12 13 //-------------------------------------------------------------------------------------------------14 13 /** 15 14 * TODO comment … … 18 17 * @author 2012, last modified by $Author: pharms$ 19 18 */ 20 //------------------------------------------------------------------------------------------------- 21 public class UsabilityEvaluationResult 22 { 23 /** */ 24 private List<UsabilityDefect> mDefects = new ArrayList<UsabilityDefect>(); 19 public class UsabilityEvaluationResult { 20 21 /** */ 22 private List<UsabilityDefect> defects = new ArrayList<UsabilityDefect>(); 25 23 26 //----------------------------------------------------------------------------------------------- 27 /** 28 * TODO: comment 29 * 30 * @param defect 31 */ 32 //----------------------------------------------------------------------------------------------- 33 public void addDefect(UsabilityDefect defect) 34 { 35 mDefects.add(defect); 36 } 24 /** 25 * TODO: comment 26 * 27 * @param defect 28 */ 29 public void addDefect(UsabilityDefect defect) { 30 defects.add(defect); 31 } 37 32 38 //----------------------------------------------------------------------------------------------- 39 /** 40 * TODO: comment 41 * 42 * @return 43 */ 44 //----------------------------------------------------------------------------------------------- 45 public List<UsabilityDefect> getAllDefects() 46 { 47 return mDefects; 48 } 33 /** 34 * TODO: comment 35 * 36 * @return 37 */ 38 public List<UsabilityDefect> getAllDefects() { 39 return defects; 40 } 49 41 50 //----------------------------------------------------------------------------------------------- 51 /** 52 * TODO: comment 53 * 54 * @return 55 */ 56 //----------------------------------------------------------------------------------------------- 57 public List<UsabilityDefect> getSevereDefects() 58 { 59 List<UsabilityDefect> severeDefects = new ArrayList<UsabilityDefect>(); 60 61 for (UsabilityDefect defect : mDefects) 62 { 63 if (defect.getSeverity() == UsabilityDefectSeverity.HIGH) 64 { 65 severeDefects.add(defect); 66 } 42 /** 43 * TODO: comment 44 * 45 * @return 46 */ 47 public List<UsabilityDefect> getSevereDefects() { 48 List<UsabilityDefect> severeDefects = new ArrayList<UsabilityDefect>(); 49 50 for (UsabilityDefect defect : defects) { 51 if (defect.getSeverity() == UsabilityDefectSeverity.HIGH) { 52 severeDefects.add(defect); 53 } 54 } 55 56 return severeDefects; 67 57 } 68 69 return severeDefects;70 }71 58 72 59 } -
trunk/quest-core-usability/src/main/java/de/ugoe/cs/quest/usability/UsabilityEvaluationRule.java
r442 r561 1 //-------------------------------------------------------------------------------------------------2 1 // Module : $RCSfile: UsabilityEvaluationRule.java,v $ 3 2 // Version : $Revision: 0.0 $ $Author: pharms $ $Date: 16.07.2012 $ … … 5 4 // Creation : 2012 by pharms 6 5 // Copyright : Patrick Harms, 2012 7 //------------------------------------------------------------------------------------------------- 6 7 8 8 package de.ugoe.cs.quest.usability; 9 9 10 import de.ugoe.cs.quest.tasktrees.treeifc. TaskTree;10 import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTree; 11 11 12 //-------------------------------------------------------------------------------------------------13 12 /** 14 13 * TODO comment … … 17 16 * @author 2012, last modified by $Author: pharms$ 18 17 */ 19 //------------------------------------------------------------------------------------------------- 20 public interface UsabilityEvaluationRule 21 { 18 public interface UsabilityEvaluationRule { 22 19 23 //----------------------------------------------------------------------------------------------- 24 /** 25 * TODO: comment 26 * 27 * @param taskTree 28 * @return 29 */ 30 //----------------------------------------------------------------------------------------------- 31 UsabilityEvaluationResult evaluate(TaskTree taskTree); 20 /** 21 * TODO: comment 22 * 23 * @param taskTree 24 * @return 25 */ 26 UsabilityEvaluationResult evaluate(ITaskTree taskTree); 32 27 33 28 }
Note: See TracChangeset
for help on using the changeset viewer.