- Timestamp:
- 01/30/15 18:09:47 (10 years ago)
- Location:
- trunk/autoquest-plugin-android
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-android/.classpath
r1820 r1869 17 17 </attributes> 18 18 </classpathentry> 19 <classpathentry kind="src" output="target/test-classes" path="src/test/java"> 20 <attributes> 21 <attribute name="optional" value="true"/> 22 <attribute name="maven.pomderived" value="true"/> 23 </attributes> 24 </classpathentry> 19 25 <classpathentry kind="output" path="target/classes"/> 20 26 </classpath> -
trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android/AndroidLogParser.java
r1819 r1869 154 154 155 155 /** 156 *157 158 private Boolean showSteps = false;156 * Show parsed elements to find out failures. 157 */ 158 private Boolean showSteps = true; 159 159 160 160 /** … … 303 303 currentGUIElementHash = Long.parseLong(atts.getValue("hash")); 304 304 currentGUIElementSpec = new ANDROIDGUIElementSpec(); 305 currentGUIElementSpec.set HashCode((int) currentGUIElementHash.longValue());305 currentGUIElementSpec.setElementHash((int) currentGUIElementHash.longValue()); 306 306 307 307 } … … 315 315 if ("class".equals(atts.getValue("name"))) { 316 316 currentGUIElementSpec.setType(atts.getValue("value")); 317 } 318 else if ("title".equals(atts.getValue("name"))) { 319 currentGUIElementSpec.setName(atts.getValue("value")); 317 320 } 318 321 else if ("path".equals(atts.getValue("name"))) { -
trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android/guimodel/ANDROIDGUIElement.java
r1819 r1869 101 101 return "Android"; 102 102 } 103 104 /** 105 * <p> 106 * Returns the type of the GUI element, i.e., the name of its Android class. 107 * </p> 108 * 109 * @return the Android class name 110 */ 111 public String getAndroidType() { 112 return specification.getType(); 113 } 114 115 /** 116 * <p> 117 * Returns the name of the GUI element. 118 * </p> 119 * 120 * @return the name 121 */ 122 public String getName() { 123 return specification.getName(); 124 } 125 126 /** 127 * <p> 128 * Returns the path of the GUI element. 129 * </p> 130 * 131 * @return the path 132 */ 133 public String getPath() { 134 return specification.getPath(); 135 } 136 137 /** 138 * <p> 139 * Returns the GUI element identifier. 140 * </p> 141 * 142 * @return identifier of the GUI element 143 */ 144 int getIndex() { 145 return specification.getIndex(); 146 } 147 148 /** 149 * <p> 150 * Returns the object hash of the GUI element. 151 * </p> 152 * 153 * @return the object hash 154 */ 155 int getElementHash() { 156 return specification.getElementHash(); 157 } 103 158 104 159 /* … … 113 168 return str + "<-" + getParent().getStringIdentifier(); 114 169 } 170 return str; 171 } 172 173 /* 174 * (non-Javadoc) 175 * 176 * @see java.lang.Object#toString() 177 */ 178 @Override 179 public String toString() { 180 String str = 181 getElementDescriptor() + "(" + getName() + "," + getElementHash() + "," + getPath() + 182 "," + getIndex() + ")"; 115 183 return str; 116 184 } -
trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android/guimodel/ANDROIDGUIElementSpec.java
r1819 r1869 31 31 /** 32 32 * <p> 33 * default serial version UID33 * Default serial version UID 34 34 * </p> 35 35 */ … … 37 37 38 38 /* 39 * (non-Javadoc) see de.ugoe.cs.autoquest.androidmonitor.AndroidmonitorLogFile#logComponent() 39 * (non-Javadoc) 40 * 41 * @see de.ugoe.cs.autoquest.androidmonitor.AndroidmonitorLogFile#logComponent() 40 42 */ 41 43 /** … … 46 48 * </p> 47 49 */ 48 private int hashCode;50 private int elementHash; 49 51 50 52 /** … … 56 58 private String path; 57 59 58 /** 59 * <p> 60 * id of the object as it is returned by view.getId() 60 /* 61 * (non-Javadoc) 62 * 63 * @see http://developer.android.com/reference/android/view/View.html#getId() 64 */ 65 /** 66 * <p> 67 * Id of the object as it is returned by view.getId(). 61 68 * </p> 62 69 */ … … 65 72 /** 66 73 * <p> 67 * the type of GUI element represented by this specification, which is usually the java class of 68 * the android GUI element 74 * Current name of the GUI element 75 * </p> 76 */ 77 private String name; 78 79 /** 80 * <p> 81 * The type of GUI element, i.e., the class of the android GUI element. 69 82 * </p> 70 83 */ … … 73 86 /** 74 87 * <p> 75 * Type hierarchy of the class itself 88 * Type hierarchy of the class itself. 76 89 * </p> 77 90 */ 78 91 private List<String> typeHierarchy = null; 92 93 /* 94 * (non-Javadoc) 95 * 96 * @see 97 * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSecificationSimilarity(IGUIElementSpec 98 * ) 99 */ 100 @Override 101 public boolean getSimilarity(IGUIElementSpec other) { 102 if (this == other) { 103 return true; 104 } 105 106 if (!(other instanceof ANDROIDGUIElementSpec)) { 107 return false; 108 } 109 110 ANDROIDGUIElementSpec otherSpec = (ANDROIDGUIElementSpec) other; 111 112 if (type == null ? otherSpec.type != null : !type.equals(otherSpec.type)) { 113 return false; 114 } 115 116 /* 117 * Up to now, we compared, if the basics match. Due to testing with different virtual 118 * devices it seems to be the case that the id of a view (named index here) keeps the same 119 * even on different devices even if the hashCode changes. Some of the GUI elements does not 120 * have an id (id is -1). 121 */ 122 123 if (otherSpec.index > 1 && index == otherSpec.index) { 124 return true; 125 } 126 127 /* 128 * Two elements could also be similar if the path of the elements is equal and the name is 129 * set, equal and not equal to "image:" even if index <= 1. This comparison is not 130 * implemented up to know due to the reason that all recorded elements up to 2015/01 either 131 * have an index > 1 or no name to be compared. 132 * 133 * In all other cases up to know it is not clear if two elements are similar. 134 * 135 * Not working: 136 * 137 * - Position of the elements: Due to the reason that there are a lot of different displays 138 * on the android market and the in the most cases the layout depends on the display size 139 * (different resolutions) similar elements have different positions. 140 */ 141 142 return false; 143 } 144 79 145 80 146 /* … … 102 168 return typeHierarchy.toArray(new String[typeHierarchy.size()]); 103 169 } 104 105 @Override 106 public boolean getSimilarity(IGUIElementSpec other) { 170 171 /** 172 * <p> 173 * Returns the object hash of the specified GUI element. 174 * </p> 175 * 176 * @return the elementHash 177 */ 178 public int getElementHash() { 179 return elementHash; 180 } 181 182 /** 183 * <p> 184 * Returns the path associated with the specified GUI element. 185 * </p> 186 * 187 * @return the path to an element 188 */ 189 public String getPath() { 190 return path; 191 } 192 193 /** 194 * <p> 195 * Returns the GUI element identifier. 196 * </p> 197 * 198 * @return identifier of the GUI element 199 */ 200 public int getIndex() { 201 return index; 202 } 203 204 /** 205 * <p> 206 * Returns the name of the specified GUI element. Displayed text in the application or image 207 * name. 208 * </p> 209 * 210 * @return text or image of the GUI element. 211 */ 212 public String getName() { 213 if (name == null || name.trim().length() == 0) { 214 return "NOT_SET"; 215 } 216 return name; 217 } 218 219 /** 220 * <p> 221 * Sets the GUI element identifier. 222 * </p> 223 * 224 * @param indentifier 225 */ 226 public void setIndex(int index) { 227 this.index = index; 228 } 229 230 /** 231 * Set the hash code associated with the GUI element. 232 * 233 * @param hash 234 * the hash of an element object 235 */ 236 public void setElementHash(int hash) { 237 this.elementHash = hash; 238 } 239 240 /** 241 * Set the path associated with the specified GUI element. 242 * 243 * @param path 244 * the path to an element 245 */ 246 public void setPath(String path) { 247 this.path = path; 248 } 249 250 /** 251 * <p> 252 * Sets the type of the specified GUI element. 253 * </p> 254 * 255 * @param type 256 * the type 257 */ 258 public void setType(String type) { 259 this.type = type; 260 } 261 262 /** 263 * <p> 264 * Sets the name of the specified GUI element. Displayed text in the application or image name. 265 * </p> 266 * 267 * @param name 268 * the name 269 */ 270 public void setName(String name) { 271 this.name = name; 272 } 273 274 /** 275 * <p> 276 * Sets the type hierarchy of the specified GUI element. 277 * 278 * @param typeHierarchy 279 * </p> 280 */ 281 public void setTypeHierarchy(List<String> typeHierarchy) { 282 this.typeHierarchy = typeHierarchy; 283 } 284 285 /* 286 * (non-Javadoc) 287 * 288 * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#equals(IGUIElementSpec) 289 */ 290 @Override 291 public boolean equals(Object other) { 107 292 if (this == other) { 108 293 return true; … … 113 298 } 114 299 115 // Check wheter view.id() keeps the same even if something in the 116 // structure changes. The hash in the JFCMonitor seems to be unique at 117 // all. In the Androidmonitore the hash of an element changes even from 118 // one start of the activity to another. 300 ANDROIDGUIElementSpec otherSpec = (ANDROIDGUIElementSpec) other; 301 302 return (elementHash == otherSpec.elementHash) && 303 (path == null ? otherSpec.path == null : path.equals(otherSpec.path)) && 304 (index == otherSpec.index) && 305 (name == null ? otherSpec.name == null : name.equals(otherSpec.name)) && 306 (type == null ? otherSpec.type == null : type.equals(otherSpec.type)); 307 } 308 309 /* 310 * (non-Javadoc) 311 * 312 * @see java.lang.Object#hashCode() 313 */ 314 @Override 315 public int hashCode() { 316 // 17 due to the reason that this is a prime number. 317 int result = 17; 119 318 /* 120 * Maybe some other comparisons will be necessary in the future. 319 * 31 due to the reason that a lot of VM's could optimize this multiplication by a shift. 320 * Source: Effective Java, Joshua Bloch, 2008, p.48 121 321 */ 122 123 return false; 124 } 125 126 /* 127 * (non-Javadoc) 128 * 129 * @see java.lang.Object#hashCode() 130 */ 131 @Override 132 public int hashCode() { 133 return hashCode; 134 } 135 136 /** 137 * <p> 138 * Returns the path associated with the specified GUI element. 139 * </p> 140 * 141 * @return the path to an element 142 */ 143 public String getPath() { 144 return path; 145 } 146 147 public int getIndex() { 148 return index; 149 } 150 151 public void setIndex(int index) { 152 this.index = index; 153 } 154 155 /** 156 * Set the hash code associated with the GUI element. 157 * 158 * @param hash 159 * the hash of an element object 160 */ 161 public void setHashCode(int hash) { 162 this.hashCode = hash; 163 } 164 165 /** 166 * Set the path associated with the specified GUI element. 167 * 168 * @param path 169 * the path to an element 170 */ 171 public void setPath(String path) { 172 this.path = path; 173 } 174 175 /** 176 * <p> 177 * Sets the type of the specified GUI element. 178 * </p> 179 * 180 * @param type 181 * the type 182 */ 183 public void setType(String type) { 184 this.type = type; 185 } 186 187 /** 188 * <p> 189 * Sets the type hierarchy of the specified GUI element. 190 * 191 * @param typeHierarchy 192 * </p> 193 */ 194 public void setTypeHierarchy(List<String> typeHierarchy) { 195 this.typeHierarchy = typeHierarchy; 196 } 322 result = 31 * result + elementHash; 323 result = 31 * result + path.hashCode(); 324 result = 31 * result + index; 325 result = 31 * result + getName().hashCode(); 326 result = 31 * result + type.hashCode(); 327 return result; 328 } 329 197 330 198 331 }
Note: See TracChangeset
for help on using the changeset viewer.