1a139d6e587c8b380be518f20779833541bb8fa5fThanh Le/*
21194ec356a16f3c6dcf408289e36e42c149d6dc8Kevin Jin * Copyright (C) 2013 DroidDriver committers
3a139d6e587c8b380be518f20779833541bb8fa5fThanh Le *
4a139d6e587c8b380be518f20779833541bb8fa5fThanh Le * Licensed under the Apache License, Version 2.0 (the "License");
5a139d6e587c8b380be518f20779833541bb8fa5fThanh Le * you may not use this file except in compliance with the License.
6a139d6e587c8b380be518f20779833541bb8fa5fThanh Le * You may obtain a copy of the License at
7a139d6e587c8b380be518f20779833541bb8fa5fThanh Le *
8a139d6e587c8b380be518f20779833541bb8fa5fThanh Le *      http://www.apache.org/licenses/LICENSE-2.0
9a139d6e587c8b380be518f20779833541bb8fa5fThanh Le *
10a139d6e587c8b380be518f20779833541bb8fa5fThanh Le * Unless required by applicable law or agreed to in writing, software
11a139d6e587c8b380be518f20779833541bb8fa5fThanh Le * distributed under the License is distributed on an "AS IS" BASIS,
12a139d6e587c8b380be518f20779833541bb8fa5fThanh Le * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a139d6e587c8b380be518f20779833541bb8fa5fThanh Le * See the License for the specific language governing permissions and
14a139d6e587c8b380be518f20779833541bb8fa5fThanh Le * limitations under the License.
15a139d6e587c8b380be518f20779833541bb8fa5fThanh Le */
16a139d6e587c8b380be518f20779833541bb8fa5fThanh Le
1774676fdd3c8a9e599eddd13bea56898674d9916aKevin Jinpackage com.google.android.droiddriver.validators;
18a139d6e587c8b380be518f20779833541bb8fa5fThanh Le
1949eb778a47b1b7630e5f3ec8d02b7e5bed58f7b9Kevin Jinimport com.google.android.droiddriver.UiElement;
20cf1203b8078bed407ed0035c201746fae136439aKevin Jinimport com.google.android.droiddriver.actions.Action;
2149eb778a47b1b7630e5f3ec8d02b7e5bed58f7b9Kevin Jin
22a139d6e587c8b380be518f20779833541bb8fa5fThanh Le/**
2374676fdd3c8a9e599eddd13bea56898674d9916aKevin Jin * Interface for validating a UiElement, checked when an action is performed.
2474676fdd3c8a9e599eddd13bea56898674d9916aKevin Jin * For example, in general accessibility mandates that an actionable UiElement
2574676fdd3c8a9e599eddd13bea56898674d9916aKevin Jin * has content description or text.
26a139d6e587c8b380be518f20779833541bb8fa5fThanh Le */
2774676fdd3c8a9e599eddd13bea56898674d9916aKevin Jinpublic interface Validator {
2874676fdd3c8a9e599eddd13bea56898674d9916aKevin Jin  /**
29cf1203b8078bed407ed0035c201746fae136439aKevin Jin   * Returns true if this {@link Validator} applies to {@code element} on this
30cf1203b8078bed407ed0035c201746fae136439aKevin Jin   * {@code action}.
3174676fdd3c8a9e599eddd13bea56898674d9916aKevin Jin   */
32cf1203b8078bed407ed0035c201746fae136439aKevin Jin  boolean isApplicable(UiElement element, Action action);
33cf1203b8078bed407ed0035c201746fae136439aKevin Jin
34cf1203b8078bed407ed0035c201746fae136439aKevin Jin  /**
35cf1203b8078bed407ed0035c201746fae136439aKevin Jin   * Returns {@code null} if {@code element} is valid on this {@code action},
36cf1203b8078bed407ed0035c201746fae136439aKevin Jin   * otherwise a string describing the failure.
37cf1203b8078bed407ed0035c201746fae136439aKevin Jin   */
38cf1203b8078bed407ed0035c201746fae136439aKevin Jin  String validate(UiElement element, Action action);
39a139d6e587c8b380be518f20779833541bb8fa5fThanh Le}
40