LayoutTestController.java revision dd4bff62b54033bedc254f517397ae8f954d0dc9
1/*
2 * Copyright (C) 2010 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.dumprendertree2;
18
19import android.net.Uri;
20import android.util.Log;
21import android.webkit.WebStorage;
22
23import java.io.File;
24
25/**
26 * A class that is registered as JS interface for webview in LayoutTestExecutor
27 */
28public class LayoutTestController {
29    private static final String LOG_TAG = "LayoutTestController";
30
31    LayoutTestsExecutor mLayoutTestsExecutor;
32
33    public LayoutTestController(LayoutTestsExecutor layoutTestsExecutor) {
34        mLayoutTestsExecutor = layoutTestsExecutor;
35    }
36
37    public void waitUntilDone() {
38        mLayoutTestsExecutor.waitUntilDone();
39    }
40
41    public void notifyDone() {
42        mLayoutTestsExecutor.notifyDone();
43    }
44
45    public void dumpAsText() {
46        dumpAsText(false);
47    }
48
49    public void dumpAsText(boolean enablePixelTest) {
50        mLayoutTestsExecutor.dumpAsText(enablePixelTest);
51    }
52
53    public void dumpChildFramesAsText() {
54        mLayoutTestsExecutor.dumpChildFramesAsText();
55    }
56
57    public void clearAllDatabases() {
58        Log.w(LOG_TAG + "::clearAllDatabases", "called");
59        WebStorage.getInstance().deleteAllData();
60    }
61
62    public void setCanOpenWindows() {
63        mLayoutTestsExecutor.setCanOpenWindows();
64    }
65
66    public void dumpDatabaseCallbacks() {
67        mLayoutTestsExecutor.dumpDatabaseCallbacks();
68    }
69
70    public void setDatabaseQuota(long quota) {
71        /** TODO: Reset this before every test! */
72        Log.w(LOG_TAG + "::setDatabaseQuota", "called with: " + quota);
73        WebStorage.getInstance().setQuotaForOrigin(Uri.fromFile(new File("")).toString(),
74                quota);
75    }
76}