/
LinkTextMatcher.java
57 lines (51 loc) · 1.65 KB
/
LinkTextMatcher.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*******************************************************************************
* Copyright (c) 2017 Red Hat, Inc and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc - initial API and implementation
*******************************************************************************/
package org.eclipse.reddeer.core.matcher;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Widget;
import org.hamcrest.Matcher;
import org.eclipse.reddeer.core.handler.LinkHandler;
import org.eclipse.reddeer.core.matcher.WithTextMatcher;
/**
* Matcher matching text of {@link Link} to specified text.
*
* @author Lucia Jelinkova
*
*/
public class LinkTextMatcher extends WithTextMatcher {
/**
* Creates new LinkTextMatcher matching specified text to text of {@link Link}.
*
* @param text text to match text of {@link Link}
*/
public LinkTextMatcher(String text) {
super(text);
}
/**
* Creates new LinkTextMatcher matching specified string matcher to text of {@link Link}.
*
* @param matcher matcher to match text of {@link Link}
*/
public LinkTextMatcher(Matcher<String> matcher) {
super(matcher);
}
/* (non-Javadoc)
* @see org.eclipse.reddeer.core.matcher.AbstractWidgetWithTextMatcher#extractWidgetText(org.eclipse.swt.widgets.Widget)
*/
@Override
protected String extractWidgetText(Widget widget) {
if (widget instanceof Link){
return LinkHandler.getInstance().getText((Link) widget);
}
return null;
}
}