1 /*
2 * Copyright (c) 2002-2025 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://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 */
15 package org.htmlunit.junit.annotation;
16
17 import static org.htmlunit.junit.SetExpectedAlertsBeforeTestExecutionCallback.EMPTY_DEFAULT;
18
19 import java.lang.annotation.ElementType;
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 import java.lang.annotation.Target;
23
24 import org.htmlunit.SimpleWebTestCase;
25 import org.htmlunit.WebDriverTestCase;
26
27 /**
28 * Allows to express the expected alerts (i.e. the messages passed to the
29 * window.alert function) for the different browsers for a unit test.
30 * Expected alerts can be retrieved within a unit test with {@link SimpleWebTestCase#getExpectedAlerts()}
31 * (resp. {@link WebDriverTestCase#getExpectedAlerts}) to be compared with the actual alerts but most of the time
32 * utility functions like {@link SimpleWebTestCase#loadPageWithAlerts(String)}
33 * (resp. {@link WebDriverTestCase#loadPageWithAlerts2(String)}) are used which do it
34 * after having loaded the page.
35 *
36 * @author Ahmed Ashour
37 * @author Frank Danek
38 * @author Ronald Brill
39 * @author cd alexndr
40 */
41 @Retention(RetentionPolicy.RUNTIME)
42 @Target(ElementType.METHOD)
43 public @interface Alerts {
44
45 /**
46 * Alerts that is used for all browsers (if defined, the other values are ignored).
47 * @return the alerts
48 */
49 String[] value() default { EMPTY_DEFAULT };
50
51 /**
52 * Alerts for latest Edge.
53 * @return the alerts
54 */
55 String[] EDGE() default { EMPTY_DEFAULT };
56
57 /**
58 * Alerts for latest Firefox.
59 * @return the alerts
60 */
61 String[] FF() default { EMPTY_DEFAULT };
62
63 /**
64 * Alerts for Firefox ESR.
65 * @return the alerts
66 */
67 String[] FF_ESR() default { EMPTY_DEFAULT };
68
69 /**
70 * Alerts for latest Chrome.
71 * @return the alerts
72 */
73 String[] CHROME() default { EMPTY_DEFAULT };
74
75 /**
76 * The default alerts, if nothing more specific is defined.
77 * @return the alerts
78 */
79 String[] DEFAULT() default { EMPTY_DEFAULT };
80 }