source: trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/android/guimodel/AndroidGUIElementSpec.java @ 1754

Last change on this file since 1754 was 1754, checked in by funger, 10 years ago

add get and set to path and set to hashCode

  • Property svn:mime-type set to text/plain
File size: 3.3 KB
Line 
1package de.ugoe.cs.autoquest.plugin.android.guimodel;
2
3import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
4
5/**
6 * <p>
7 * Implements the specification of {@link IGUIElement} for
8 * {@link AndroidGUIElement}s.
9 * </p>
10 *
11 * @version 1.0
12 * @author Florian Unger
13 */
14public class AndroidGUIElementSpec implements IGUIElementSpec {
15
16        // TODO Why is serialVersionUID = 1L initialized by 1L?
17        /**
18         * <p>
19         * default serial version UID
20         * </p>
21         */
22        private static final long serialVersionUID = 1L;
23
24        /*
25         * (non-Javadoc) see
26         * de.ugoe.cs.autoquest.androidmonitor.AndroidmonitorLogFile logComponent()
27         */
28        /**
29         * <p>
30         * Hash code of the GUI element. Used as unique identifier during parsing a
31         * log file. Note that it is possible that the hash code of an element
32         * changes over several log files even if they come from the same target.
33         * </p>
34         */
35        private int hashCode;
36
37        /**
38         * <p>
39         * Path to an element in an activity. e.g. a path of a button could look
40         * like MainActivity/DecorView/ActionBarOverlayLayout/FrameLayout/
41         * RelativeLayout/Button
42         * </p>
43         */
44        private String path;
45
46        /**
47         * <p>
48         * the type of GUI element represented by this specification, which is
49         * usually the java class of the android GUI element
50         * </p>
51         */
52        private String type;
53
54        /*
55         * (non-Javadoc)
56         *
57         * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getType()
58         */
59        @Override
60        public String getType() {
61                return type;
62        }
63
64        /*
65         * (non-Javadoc)
66         *
67         * @see
68         * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getTypeHierarchy
69         * ()
70         */
71        @Override
72        public String[] getTypeHierarchy() {
73                return new String[] { (getType()) };
74                // TODO change this part after adding ancestors in
75                // de.ugoe.cs.autoquest.androidmonitor.AndroidmonitorLogFile#addComponent
76        }
77
78        @Override
79        public boolean getSimilarity(IGUIElementSpec other) {
80                if (this == other) {
81                        return true;
82                }
83
84                if (!(other instanceof AndroidGUIElementSpec)) {
85                        return false;
86                }
87
88                // Check wheter view.id() keeps the same even if something in the
89                // structure changes. The hash in the JFCMonitor seems to be unique at
90                // all. In the Androidmonitore the hash of an element changes even from
91                // one start of the activity to another.
92                /*
93                 * Maybe some other comparisons will be necessary in the future.
94                 */
95
96                return false;
97        }
98
99        /*
100         * (non-Javadoc)
101         *
102         * @see java.lang.Object#hashCode()
103         */
104        @Override
105        public int hashCode() {
106                return hashCode;
107        }
108
109        /**
110         * <p>
111         * Returns the path associated with the specified GUI element.
112         * </p>
113         * @return the path to an element
114         */
115        public String getPath() {
116                return path;
117        }
118
119        /**
120         * Set the hash code associated with the GUI element.
121         * @param hash
122         *                              the hash of an element object
123         */
124        public void setHashCode(int hash){
125                this.hashCode = hash;
126        }
127       
128        /**
129         * Set the path associated with the specified GUI element.
130         * @param path
131         *                              the path to an element
132         */
133        public void setPath(String path) {
134                this.path = path;
135        }
136       
137        /**
138     * <p>
139     * Sets the type of the specified GUI element.
140     * </p>
141     *
142     * @param type
143     *            the type
144     */
145    public void setType(String type) {
146        this.type = type;
147    }
148
149}
Note: See TracBrowser for help on using the repository browser.