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