1 /*
2  * Copyright (C) 2009 The Android Open Source Project
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  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.webkit.cts;
18 
19 /**
20  * This class defines constants for webkit test assets.
21  */
22 public class TestHtmlConstants {
23     public static final String BR_TAG_URL = "webkit/test_br_tag.html";
24     public static final String BR_TAG_TITLE = "test br tag";
25 
26     public static final String HELLO_WORLD_URL = "webkit/test_hello_world.html";
27     public static final String HELLO_WORLD_TITLE = "test hello world";
28 
29     public static final String TEST_FAVICON_URL = "webkit/test_favicon.html";
30 
31     public static final String LARGE_IMG_URL = "images/robot.png";
32     public static final String SMALL_IMG_URL = "images/tomato.png";
33 
34     public static final String EMBEDDED_IMG_URL = "webkit/embedded_image.html";
35     public static final String POPUP_URL = "webkit/popup_base.html";
36     public static final String JAVASCRIPT_URL = "webkit/javascript.html";
37     public static final String JS_ALERT_URL = "webkit/jsalert.html";
38     public static final String JS_CONFIRM_URL = "webkit/jsconfirm.html";
39     public static final String JS_PROMPT_URL = "webkit/jsprompt.html";
40     public static final String JS_UNLOAD_URL = "webkit/jsunload.html";
41     public static final String JS_WINDOW_URL = "webkit/jswindow.html";
42     public static final String JS_TIMEOUT_URL = "webkit/jstimeout.html";
43     public static final String JS_FORM_URL = "webkit/jsform.html";
44 
45     public static final String FONT_URL = "webkit/fonts.html";
46 
47     public static final String NETWORK_STATE_URL = "webkit/network_state.html";
48     public static final String TEST_TIMER_URL = "webkit/test_timer.html";
49 
50     public static final String HTML_URL1 = "webkit/test_firstPage.html";
51     public static final String HTML_URL2 = "webkit/test_secondPage.html";
52     public static final String HTML_URL3 = "webkit/test_thirdPage.html";
53     public static final String HTML_URL1_TITLE = "First page";
54 
55     public static final String BLANK_PAGE_URL = "webkit/test_blankPage.html";
56     public static final String ADD_JAVA_SCRIPT_INTERFACE_URL = "webkit/test_jsInterface.html";
57 
58     public static final String LOGIN_FORM_URL = "webkit/test_loginForm.html";
59 
60     // Note: tests should avoid loading external URLs if at all possible, since any changes to that
61     // public site (even if it doesn't currently exist) can affect test behavior. The ".test" TLD is
62     // OK because (1) it's reserved for testing by RFC2606 and (2) the test never navigates to this
63     // page.
64     public static final String EXT_WEB_URL1 = "http://www.example.test/";
65 
66     public static final String PARAM_ASSET_URL = "webkit/test_queryparam.html";
67     public static final String ANCHOR_ASSET_URL = "webkit/test_anchor.html";
68     public static final String IMAGE_ACCESS_URL = "webkit/test_imageaccess.html";
69     public static final String IFRAME_ACCESS_URL = "webkit/test_iframeaccess.html";
70     public static final String DATABASE_ACCESS_URL = "webkit/test_databaseaccess.html";
71     public static final String STOP_LOADING_URL = "webkit/test_stop_loading.html";
72     public static final String BLANK_TAG_URL = "webkit/blank_tag.html";
73     // A page with a link to an arbitrary page controlled by the test server (in this case,
74     // BLANK_PAGE_URL).
75     public static final String PAGE_WITH_LINK_URL = "webkit/page_with_link.html";
76     // Not a real page, just triggers a 404 response.
77     public static final String NON_EXISTENT_PAGE_URL = "webkit/generate_404.html";
78     public static final String BAD_IMAGE_PAGE_URL = "webkit/test_bad_image_url.html";
79 
getFileUrl(String assetName)80     public static final String getFileUrl(String assetName) {
81         if (assetName.contains(":") || assetName.startsWith("/")) {
82             throw new IllegalArgumentException();
83         }
84         return "file:///android_asset/" + assetName;
85     }
86 }
87