1/*
2 * Copyright (C) 2007 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
17package com.android.dumprendertree;
18
19import java.util.Vector;
20import android.util.*;
21
22public class FileFilter {
23
24    private static final String LOGTAG = "FileFilter";
25
26    // Returns whether we should ignore this test and skip running it.
27    // Currently we use this only for tests that crash or hang DumpRenderTree.
28    // TODO: Fix these and eliminate this method.
29    public static boolean ignoreTest(String file) {
30        for (int i = 0; i < ignoreTestList.length; i++) {
31            if (file.endsWith(ignoreTestList[i])) {
32                Log.v(LOGTAG, "File path in list of ignored tests: " + file);
33                return true;
34            }
35        }
36        return false;
37    }
38
39    // Returns whether a directory does not contain layout tests and so can be
40    // ignored.
41    public static boolean isNonTestDir(String file) {
42        for (int i = 0; i < nonTestDirs.length; i++) {
43            if (file.endsWith(nonTestDirs[i])) {
44                return true;
45            }
46        }
47        return false;
48    }
49
50    // Returns whether we should ignore the result of this test.
51    public static boolean ignoreResult(String file) {
52        for (int i = 0; i < ignoreResultList.size(); i++) {
53            if (file.endsWith(ignoreResultList.get(i))) {
54                Log.v(LOGTAG, "File path in list of ignored results: " + file);
55                return true;
56            }
57        }
58        return false;
59    }
60
61    final static Vector<String> ignoreResultList = new Vector<String>();
62
63    static {
64        fillIgnoreResultList();
65    }
66
67    static final String[] nonTestDirs = {
68        ".", // ignore hidden directories and files
69        "resources", // ignore resource directories
70        ".svn", // don't run anything under .svn folder
71        "platform"  // No-Android specific tests
72    };
73
74    static final String[] ignoreTestList = {
75        "canvas/philip/tests/2d.drawImage.broken.html", // blocks test, http://b/2982500
76        "editing/selection/move-left-right.html", // Causes DumpRenderTree to hang
77        "fast/js/excessive-comma-usage.html", // Tests huge initializer list, causes OOM.
78        "fast/js/regexp-charclass-crash.html", // RegExp is too large, causing OOM
79        "fast/js/regexp-overflow.html", // Result is too large, causing OOM when reading by DRT, http://b/2697589
80        "fast/regex/test1.html", // Causes DumpRenderTree to hang with V8
81        "fast/regex/slow.html", // Causes DumpRenderTree to hang with V8
82    };
83
84    static void fillIgnoreResultList() {
85        // This first block of tests are for features for which Android
86        // should pass all tests. They are skipped only temporarily.
87        // TODO: Fix these failing tests and remove them from this list.
88        ignoreResultList.add("fast/dom/HTMLKeygenElement/keygen.html"); // Missing layoutTestController.shadowRoot()
89        ignoreResultList.add("fast/dom/Geolocation/window-close-crash.html"); // Missing layoutTestContoller.setCloseRemainingWindowsWhenComplete()
90        ignoreResultList.add("fast/dom/Geolocation/page-reload-cancel-permission-requests.html"); // Missing layoutTestController.numberOfPendingGeolocationPermissionRequests()
91        ignoreResultList.add("fast/dom/HTMLLinkElement/link-and-subresource-test.html"); // Missing layoutTestController.dumpResourceResponseMIMETypes()
92        ignoreResultList.add("fast/dom/HTMLLinkElement/prefetch.html"); // Missing layoutTestController.dumpResourceResponseMIMETypes()
93        ignoreResultList.add("fast/dom/HTMLLinkElement/subresource.html"); // Missing layoutTestController.dumpResourceResponseMIMETypes()
94        ignoreResultList.add("fast/encoding/char-decoding.html"); // fails in Java HTTP stack, see http://b/issue?id=3047156
95        ignoreResultList.add("fast/encoding/hanarei-blog32-fc2-com.html"); // fails in Java HTTP stack, see http://b/issue?id=3046986
96        ignoreResultList.add("fast/encoding/mailto-always-utf-8.html"); // Requires waitForPolicyDelegate(), see http://b/issue?id=3043468
97        ignoreResultList.add("fast/encoding/percent-escaping.html"); // fails in Java HTTP stack, see http://b/issue?id=3046984
98        ignoreResultList.add("http/tests/appcache/empty-manifest.html"); // flaky
99        ignoreResultList.add("http/tests/appcache/fallback.html"); // http://b/issue?id=2713004
100        ignoreResultList.add("http/tests/appcache/foreign-fallback.html"); // Flaky, may be due to DRT, see http://b/3285647
101        ignoreResultList.add("http/tests/appcache/foreign-iframe-main.html"); // flaky - skips states
102        ignoreResultList.add("http/tests/appcache/manifest-with-empty-file.html"); // flaky
103        ignoreResultList.add("http/tests/appcache/origin-quota.html"); // needs clearAllApplicationCaches(), see http://b/issue?id=2944196
104        ignoreResultList.add("storage/database-lock-after-reload.html"); // Succeeds but DumpRenderTree does not read result correctly
105        ignoreResultList.add("storage/hash-change-with-xhr.html"); // Succeeds but DumpRenderTree does not read result correctly
106        ignoreResultList.add("storage/open-database-creation-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
107        ignoreResultList.add("storage/statement-error-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
108        ignoreResultList.add("storage/statement-success-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
109        ignoreResultList.add("storage/storageinfo-query-usage.html"); // Need window.webkitStorageInfo
110        ignoreResultList.add("storage/transaction-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
111        ignoreResultList.add("storage/transaction-error-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
112        ignoreResultList.add("storage/transaction-success-callback-isolated-world.html"); // Requires layoutTestController.evaluateScriptInIsolatedWorld()
113        ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-1-prepare.html"); // Missing layoutTestController.originsWithLocalStorage()
114        ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-2-create.html"); // Missing layoutTestController.originsWithLocalStorage()
115        ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-3-delete-all.html"); // Missing layoutTestController.originsWithLocalStorage()
116        ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-4-create.html"); // Missing layoutTestController.originsWithLocalStorage()
117        ignoreResultList.add("storage/domstorage/localstorage/storagetracker/storage-tracker-5-delete-one.html"); // Missing layoutTestController.originsWithLocalStorage()
118
119
120        // Expected failures due to unsupported features or tests unsuitable for Android.
121        ignoreResultList.add("fast/encoding/char-decoding-mac.html"); // Mac-specific encodings (also marked Won't Fix in Chromium, bug 7388)
122        ignoreResultList.add("fast/encoding/char-encoding-mac.html"); // Mac-specific encodings (also marked Won't Fix in Chromium, bug 7388)
123        ignoreResultList.add("fast/encoding/idn-security.html"); // Mac-specific IDN checks (also marked Won't Fix in Chromium, bug 21814)
124        ignoreResultList.add("fast/events/touch/basic-multi-touch-events.html"); // Requires multi-touch gestures not supported by Android system
125        ignoreResultList.add("fast/events/touch/touch-coords-in-zoom-and-scroll.html"); // Requires eventSender.zoomPageIn(),zoomPageOut()
126        ignoreResultList.add("fast/events/touch/touch-target.html"); // Requires multi-touch gestures not supported by Android system
127        ignoreResultList.add("fast/workers"); // workers not supported
128        ignoreResultList.add("http/tests/cookies/third-party-cookie-relaxing.html"); // We don't support conditional acceptance of third-party cookies
129        ignoreResultList.add("http/tests/eventsource/workers"); // workers not supported
130        ignoreResultList.add("http/tests/workers"); // workers not supported
131        ignoreResultList.add("http/tests/xmlhttprequest/workers"); // workers not supported
132        ignoreResultList.add("storage/domstorage/localstorage/private-browsing-affects-storage.html"); // private browsing not supported
133        ignoreResultList.add("storage/domstorage/sessionstorage/private-browsing-affects-storage.html"); // private browsing not supported
134        ignoreResultList.add("storage/indexeddb"); // indexeddb not supported
135        ignoreResultList.add("storage/private-browsing-noread-nowrite.html"); // private browsing not supported
136        ignoreResultList.add("storage/private-browsing-readonly.html"); // private browsing not supported
137        ignoreResultList.add("websocket/tests/workers"); // workers not supported
138        ignoreResultList.add("dom/xhtml/level2/html/htmldocument04.xhtml"); // /mnt/sdcard on SR uses lowercase filesystem, this test checks filename and is case senstive.
139        ignoreResultList.add("dom/html/level2/html/htmldocument04.html"); // ditto
140
141        // Expected failures due to missing expected results
142        ignoreResultList.add("dom/xhtml/level3/core/canonicalform08.xhtml");
143        ignoreResultList.add("dom/xhtml/level3/core/canonicalform09.xhtml");
144        ignoreResultList.add("dom/xhtml/level3/core/documentgetinputencoding03.xhtml");
145        ignoreResultList.add("dom/xhtml/level3/core/entitygetinputencoding02.xhtml");
146        ignoreResultList.add("dom/xhtml/level3/core/entitygetxmlversion02.xhtml");
147        ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri05.xhtml");
148        ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri07.xhtml");
149        ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri09.xhtml");
150        ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri10.xhtml");
151        ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri11.xhtml");
152        ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri15.xhtml");
153        ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri17.xhtml");
154        ignoreResultList.add("dom/xhtml/level3/core/nodegetbaseuri18.xhtml");
155        ignoreResultList.add("dom/xhtml/level3/core/nodelookupnamespaceuri01.xhtml");
156        ignoreResultList.add("dom/xhtml/level3/core/nodelookupprefix19.xhtml");
157
158        // TODO: These need to be triaged
159        ignoreResultList.add("fast/css/case-transform.html"); // will not fix #619707
160        ignoreResultList.add("fast/dom/Element/offsetLeft-offsetTop-body-quirk.html"); // different screen size result in extra spaces in Apple compared to us
161        ignoreResultList.add("fast/dom/Window/Plug-ins.html"); // need test plugin
162        ignoreResultList.add("fast/dom/Window/window-screen-properties.html"); // pixel depth
163        ignoreResultList.add("fast/dom/Window/window-xy-properties.html"); // requires eventSender.mouseDown(),mouseUp()
164        ignoreResultList.add("fast/dom/attribute-namespaces-get-set.html"); // http://b/733229
165        ignoreResultList.add("fast/dom/object-embed-plugin-scripting.html"); // dynamic plugins not supported
166        ignoreResultList.add("fast/dom/tabindex-clamp.html"); // there is extra spacing in the file due to multiple input boxes fitting on one line on Apple, ours are wrapped. Space at line ends are stripped.
167        ignoreResultList.add("fast/events/anchor-image-scrolled-x-y.html"); // requires eventSender.mouseDown(),mouseUp()
168        ignoreResultList.add("fast/events/arrow-navigation.html"); // http://b/735233
169        ignoreResultList.add("fast/events/capture-on-target.html"); // requires eventSender.mouseDown(),mouseUp()
170        ignoreResultList.add("fast/events/dblclick-addEventListener.html"); // requires eventSender.mouseDown(),mouseUp()
171        ignoreResultList.add("fast/events/drag-in-frames.html"); // requires eventSender.mouseDown(),mouseUp()
172        ignoreResultList.add("fast/events/drag-outside-window.html"); // requires eventSender.mouseDown(),mouseUp()
173        ignoreResultList.add("fast/events/event-view-toString.html"); // requires eventSender.mouseDown(),mouseUp()
174        ignoreResultList.add("fast/events/frame-click-focus.html"); // requires eventSender.mouseDown(),mouseUp()
175        ignoreResultList.add("fast/events/frame-tab-focus.html"); // http://b/734308
176        ignoreResultList.add("fast/events/iframe-object-onload.html"); // there is extra spacing in the file due to multiple frame boxes fitting on one line on Apple, ours are wrapped. Space at line ends are stripped.
177        ignoreResultList.add("fast/events/input-image-scrolled-x-y.html"); // requires eventSender.mouseDown(),mouseUp()
178        ignoreResultList.add("fast/events/mouseclick-target-and-positioning.html"); // requires eventSender.mouseDown(),mouseUp()
179        ignoreResultList.add("fast/events/mouseover-mouseout.html"); // requires eventSender.mouseDown(),mouseUp()
180        ignoreResultList.add("fast/events/mouseover-mouseout2.html"); // requires eventSender.mouseDown(),mouseUp()
181        ignoreResultList.add("fast/events/mouseup-outside-button.html"); // requires eventSender.mouseDown(),mouseUp()
182        ignoreResultList.add("fast/events/mouseup-outside-document.html"); // requires eventSender.mouseDown(),mouseUp()
183        ignoreResultList.add("fast/events/onclick-list-marker.html"); // requires eventSender.mouseDown(),mouseUp()
184        ignoreResultList.add("fast/events/ondragenter.html"); // requires eventSender.mouseDown(),mouseUp()
185        ignoreResultList.add("fast/events/onload-webkit-before-webcore.html"); // missing space in textrun, ok as text is wrapped. ignore. #714933
186        ignoreResultList.add("fast/events/option-tab.html"); // http://b/734308
187        ignoreResultList.add("fast/events/window-events-bubble.html"); // requires eventSender.mouseDown(),mouseUp()
188        ignoreResultList.add("fast/events/window-events-bubble2.html"); // requires eventSender.mouseDown(),mouseUp()
189        ignoreResultList.add("fast/events/window-events-capture.html"); // requires eventSender.mouseDown(),mouseUp()
190        ignoreResultList.add("fast/forms/drag-into-textarea.html"); // requires eventSender.mouseDown(),mouseUp()
191        ignoreResultList.add("fast/forms/focus-control-to-page.html"); // http://b/716638
192        ignoreResultList.add("fast/forms/focus2.html"); // http://b/735111
193        ignoreResultList.add("fast/forms/form-data-encoding-2.html"); // charset convert. #516936 ignore, won't fix
194        ignoreResultList.add("fast/forms/form-data-encoding.html"); // charset convert. #516936 ignore, won't fix
195        ignoreResultList.add("fast/forms/input-appearance-maxlength.html"); // execCommand "insertText" not supported
196        ignoreResultList.add("fast/forms/input-select-on-click.html"); // requires eventSender.mouseDown(),mouseUp()
197        ignoreResultList.add("fast/forms/listbox-onchange.html"); // requires eventSender.mouseDown(),mouseUp()
198        ignoreResultList.add("fast/forms/listbox-selection.html"); // http://b/735116
199        ignoreResultList.add("fast/forms/onselect-textarea.html"); // requires eventSender.mouseMoveTo, mouseDown & mouseUp and abs. position of mouse to select a word. ignore, won't fix #716583
200        ignoreResultList.add("fast/forms/onselect-textfield.html"); // requires eventSender.mouseMoveTo, mouseDown & mouseUp and abs. position of mouse to select a word. ignore, won't fix #716583
201        ignoreResultList.add("fast/forms/plaintext-mode-1.html"); // not implemented queryCommandEnabled:BackColor, Undo & Redo
202        ignoreResultList.add("fast/forms/search-cancel-button-mouseup.html"); // requires eventSender.mouseDown(),mouseUp()
203        ignoreResultList.add("fast/forms/search-event-delay.html"); // http://b/735120
204        ignoreResultList.add("fast/forms/select-empty-list.html"); // requires eventSender.mouseDown(),mouseUp()
205        ignoreResultList.add("fast/forms/select-type-ahead-non-latin.html"); // http://b/735244
206        ignoreResultList.add("fast/forms/selected-index-assert.html"); // not capturing the console messages
207        ignoreResultList.add("fast/forms/selection-functions.html"); // there is extra spacing as the text areas and input boxes fit next to each other on Apple, but are wrapped on our screen.
208        ignoreResultList.add("fast/forms/textarea-appearance-wrap.html"); // Our text areas are a little thinner than Apples. Also RTL test failes
209        ignoreResultList.add("fast/forms/textarea-initial-caret-position.html"); // Text selection done differently on our platform. When a inputbox gets focus, the entire block is selected.
210        ignoreResultList.add("fast/forms/textarea-no-scroll-on-blur.html"); // Text selection done differently on our platform. When a inputbox gets focus, the entire block is selected.
211        ignoreResultList.add("fast/forms/textarea-paste-newline.html"); // Copy&Paste commands not supported
212        ignoreResultList.add("fast/forms/textarea-scrolled-endline-caret.html"); // requires eventSender.mouseDown(),mouseUp()
213        ignoreResultList.add("fast/frames/iframe-window-focus.html"); // http://b/735140
214        ignoreResultList.add("fast/frames/frameElement-widthheight.html"); // screen width&height are different
215        ignoreResultList.add("fast/frames/frame-js-url-clientWidth.html"); // screen width&height are different
216        ignoreResultList.add("fast/html/tab-order.html"); // http://b/719289
217        ignoreResultList.add("fast/js/navigator-mimeTypes-length.html"); // dynamic plugins not supported
218        ignoreResultList.add("fast/js/string-capitalization.html"); // http://b/516936
219        ignoreResultList.add("fast/loader/local-JavaScript-from-local.html"); // Requires LayoutTests to exist at /tmp/LayoutTests
220        ignoreResultList.add("fast/loader/local-iFrame-source-from-local.html"); // Requires LayoutTests to exist at /tmp/LayoutTests
221        ignoreResultList.add("fast/loader/opaque-base-url.html"); // extra spacing because iFrames rendered next to each other on Apple
222        ignoreResultList.add("fast/overflow/scroll-vertical-not-horizontal.html"); // http://b/735196
223        ignoreResultList.add("fast/parser/script-tag-with-trailing-slash.html"); // not capturing the console messages
224        ignoreResultList.add("fast/replaced/image-map.html"); // requires eventSender.mouseDown(),mouseUp()
225        ignoreResultList.add("fast/text/plain-text-line-breaks.html"); // extra spacing because iFrames rendered next to each other on Apple
226        ignoreResultList.add("profiler"); // profiler is not supported
227    }
228
229}
230