TestContentViewClient.java revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5package org.chromium.content.browser.test.util; 6 7import android.content.Context; 8 9import org.chromium.content.browser.ContentViewClient; 10import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnEvaluateJavaScriptResultHelper; 11import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnStartContentIntentHelper; 12 13/** 14 * The default ContentViewClient used by ContentView tests. 15 * <p> 16 * Tests that need to supply their own ContentViewClient should do that 17 * by extending this one. 18 */ 19public class TestContentViewClient extends ContentViewClient { 20 21 private OnEvaluateJavaScriptResultHelper mOnEvaluateJavaScriptResultHelper; 22 private OnStartContentIntentHelper mOnStartContentIntentHelper; 23 24 public TestContentViewClient() { 25 mOnEvaluateJavaScriptResultHelper = new OnEvaluateJavaScriptResultHelper(); 26 mOnStartContentIntentHelper = new OnStartContentIntentHelper(); 27 } 28 29 public OnEvaluateJavaScriptResultHelper getOnEvaluateJavaScriptResultHelper() { 30 return mOnEvaluateJavaScriptResultHelper; 31 } 32 33 public OnStartContentIntentHelper getOnStartContentIntentHelper() { 34 return mOnStartContentIntentHelper; 35 } 36 37 /** 38 * ATTENTION!: When overriding the following method, be sure to call 39 * the corresponding method in the super class. Otherwise 40 * {@link CallbackHelper#waitForCallback()} methods will 41 * stop working! 42 */ 43 44 @Override 45 public void onStartContentIntent(Context context, String contentUrl) { 46 mOnStartContentIntentHelper.notifyCalled(contentUrl); 47 } 48} 49