TestWebViewClient.java revision 8862c1dd48ac83011411c469afb5065b6d0c32f9
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.browser;
18
19import android.graphics.Bitmap;
20import android.net.http.SslError;
21import android.os.Message;
22import android.view.KeyEvent;
23import android.webkit.ClientCertRequestHandler;
24import android.webkit.HttpAuthHandler;
25import android.webkit.SslErrorHandler;
26import android.webkit.WebView;
27import android.webkit.WebViewClient;
28
29/**
30 *
31 *
32 * WebViewClient for browser tests.
33 * Wraps around existing client so that specific methods can be overridden if needed.
34 *
35 */
36abstract class TestWebViewClient extends WebViewClient {
37
38  private WebViewClient mWrappedClient;
39
40  protected TestWebViewClient(WebViewClient wrappedClient) {
41    mWrappedClient = wrappedClient;
42  }
43
44  /** {@inheritDoc} */
45  @Override
46  public boolean shouldOverrideUrlLoading(WebView view, String url) {
47      return mWrappedClient.shouldOverrideUrlLoading(view, url);
48  }
49
50  /** {@inheritDoc} */
51  @Override
52  public void onPageStarted(WebView view, String url, Bitmap favicon) {
53    mWrappedClient.onPageStarted(view, url, favicon);
54  }
55
56  /** {@inheritDoc} */
57  @Override
58  public void onPageFinished(WebView view, String url) {
59    mWrappedClient.onPageFinished(view, url);
60  }
61
62  /** {@inheritDoc} */
63  @Override
64  public void onLoadResource(WebView view, String url) {
65    mWrappedClient.onLoadResource(view, url);
66  }
67
68  /** {@inheritDoc} */
69  @Deprecated
70  @Override
71  public void onTooManyRedirects(WebView view, Message cancelMsg,
72          Message continueMsg) {
73      mWrappedClient.onTooManyRedirects(view, cancelMsg, continueMsg);
74  }
75
76  /** {@inheritDoc} */
77  @Override
78  public void onReceivedError(WebView view, int errorCode,
79          String description, String failingUrl) {
80    mWrappedClient.onReceivedError(view, errorCode, description, failingUrl);
81  }
82
83  /** {@inheritDoc} */
84  @Override
85  public void onFormResubmission(WebView view, Message dontResend,
86          Message resend) {
87    mWrappedClient.onFormResubmission(view, dontResend, resend);
88  }
89
90  /** {@inheritDoc} */
91  @Override
92  public void doUpdateVisitedHistory(WebView view, String url,
93          boolean isReload) {
94    mWrappedClient.doUpdateVisitedHistory(view, url, isReload);
95  }
96
97  /** {@inheritDoc} */
98  @Override
99  public void onReceivedSslError(WebView view, SslErrorHandler handler,
100          SslError error) {
101      mWrappedClient.onReceivedSslError(view, handler, error);
102  }
103
104  /** {@inheritDoc} */
105  @Override
106  public void onReceivedClientCertRequest(WebView view, ClientCertRequestHandler handler,
107          String host_and_port) {
108      mWrappedClient.onReceivedClientCertRequest(view, handler, host_and_port);
109  }
110
111  /** {@inheritDoc} */
112  @Override
113  public void onReceivedHttpAuthRequest(WebView view,
114          HttpAuthHandler handler, String host, String realm) {
115      mWrappedClient.onReceivedHttpAuthRequest(view, handler, host, realm);
116  }
117
118  /** {@inheritDoc} */
119  @Override
120  public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
121      return mWrappedClient.shouldOverrideKeyEvent(view, event);
122  }
123
124  /** {@inheritDoc} */
125  @Override
126  public void onUnhandledKeyEvent(WebView view, KeyEvent event) {
127    mWrappedClient.onUnhandledKeyEvent(view, event);
128  }
129
130  /** {@inheritDoc} */
131  @Override
132  public void onScaleChanged(WebView view, float oldScale, float newScale) {
133    mWrappedClient.onScaleChanged(view, oldScale, newScale);
134  }
135}
136