source: trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLPageSpec.java @ 1059

Last change on this file since 1059 was 1059, checked in by fglaser, 11 years ago
  • Further works on NewHTMLLogParser to parse testtrace without errors
  • Test for NewHTMLLogParser added
  • dummy mapping for html added that contains unmapped elements
File size: 3.6 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.plugin.html.guimodel;
16
17import java.net.URL;
18
19import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
20
21/**
22 * <p>
23 * TODO comment
24 * </p>
25 *
26 * @author Patrick Harms
27 */
28public class HTMLPageSpec extends HTMLGUIElementSpec implements IGUIElementSpec {
29
30    /**  */
31    private static final long serialVersionUID = 1L;
32   
33    /** */
34    private HTMLServerSpec server;
35   
36    /** */
37    private String pagePath;
38   
39    /** */
40    private String pageTitle;
41   
42    /**
43     * <p>
44     * TODO: comment
45     * </p>
46     *
47     * @param server
48     * @param pagePath
49     * @param pageTitle
50     */
51    public HTMLPageSpec(HTMLServerSpec server, String pagePath, String pageTitle) {
52        super("page");
53       
54        if (server == null) {
55            throw new IllegalArgumentException("server must not be null");
56        }
57        else if (pagePath == null) {
58            throw new IllegalArgumentException("pagePath must not be null");
59        }
60//        else if (pageTitle == null) {
61//            throw new IllegalArgumentException("pageTitle must not be null");
62//        }
63       
64        this.server = server;
65        this.pagePath = pagePath;
66        this.pageTitle = pageTitle;
67    }
68
69    /**
70     * <p>
71     * TODO: comment
72     * </p>
73     *
74     * @param server
75     * @param pagePath
76     * @param pageTitle
77     */
78    public HTMLPageSpec(URL pageURL, String pageTitle) {
79        super("page");
80       
81        if (pageURL == null) {
82            throw new IllegalArgumentException("pageURL must not be null");
83        }
84        else if (pageTitle == null) {
85            throw new IllegalArgumentException("pageTitle must not be null");
86        }
87       
88        this.server = new HTMLServerSpec(pageURL);
89        this.pagePath = pageURL.getPath();
90        this.pageTitle = pageTitle;
91    }
92
93    /* (non-Javadoc)
94     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec)
95     */
96    @Override
97    public boolean getSimilarity(IGUIElementSpec other) {
98        if (other instanceof HTMLPageSpec) {
99            HTMLPageSpec otherSpec = (HTMLPageSpec) other;
100           
101            if (!super.getSimilarity(otherSpec)) {
102                return false;
103            }
104            else if (!server.getSimilarity(otherSpec.server)) {
105                return false;
106            }
107            else if (!pagePath.equals(otherSpec.pagePath)) {
108                return false;
109            }
110            else {
111                return pageTitle.equals(otherSpec.pageTitle);
112            }
113        }
114       
115        return false;
116    }
117
118    /**
119     * <p>
120     * TODO: comment
121     * </p>
122     *
123     * @return
124     */
125    public HTMLServerSpec getServer() {
126        return server;
127    }
128
129    /**
130     * <p>
131     * TODO: comment
132     * </p>
133     *
134     * @return
135     */
136    public String getPagePath() {
137        return pagePath;
138    }
139
140    /**
141     * <p>
142     * TODO: comment
143     * </p>
144     *
145     * @return
146     */
147    String getPageTitle() {
148        return pageTitle;
149    }
150
151}
Note: See TracBrowser for help on using the repository browser.