This source file includes following definitions.
- notifyCalled
 
- getUrl
 
- notifyCalled
 
- getUrl
 
- notifyCalled
 
- getErrorCode
 
- getDescription
 
- getFailingUrl
 
- evaluateJavaScript
 
- hasValue
 
- getJsonResultAndClear
 
- getHasValueCriteria
 
- waitUntilHasValue
 
- waitUntilHasValue
 
- notifyCalled
 
- notifyCalled
 
- getIntentUrl
 
- getOnPageStartedHelper
 
- getOnPageFinishedHelper
 
- getOnReceivedErrorHelper
 
- getOnEvaluateJavaScriptResultHelper
 
- getOnStartContentIntentHelper
 
package org.chromium.content.browser.test.util;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewCore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class TestCallbackHelperContainer {
    private TestContentViewClient mTestContentViewClient;
    private TestWebContentsObserver mTestWebContentsObserver;
    public TestCallbackHelperContainer(ContentView contentView) {
        mTestContentViewClient = new TestContentViewClient();
        contentView.getContentViewCore().setContentViewClient(mTestContentViewClient);
        mTestWebContentsObserver = new TestWebContentsObserver(contentView.getContentViewCore());
    }
    protected TestCallbackHelperContainer(
            TestContentViewClient viewClient, TestWebContentsObserver contentsObserver) {
        mTestContentViewClient = viewClient;
        mTestWebContentsObserver = contentsObserver;
    }
    public static class OnPageFinishedHelper extends CallbackHelper {
        private String mUrl;
        public void notifyCalled(String url) {
            mUrl = url;
            notifyCalled();
        }
        public String getUrl() {
            assert getCallCount() > 0;
            return mUrl;
        }
    }
    public static class OnPageStartedHelper extends CallbackHelper {
        private String mUrl;
        public void notifyCalled(String url) {
            mUrl = url;
            notifyCalled();
        }
        public String getUrl() {
            assert getCallCount() > 0;
            return mUrl;
        }
    }
    public static class OnReceivedErrorHelper extends CallbackHelper {
        private int mErrorCode;
        private String mDescription;
        private String mFailingUrl;
        public void notifyCalled(int errorCode, String description, String failingUrl) {
            mErrorCode = errorCode;
            mDescription = description;
            mFailingUrl = failingUrl;
            notifyCalled();
        }
        public int getErrorCode() {
            assert getCallCount() > 0;
            return mErrorCode;
        }
        public String getDescription() {
            assert getCallCount() > 0;
            return mDescription;
        }
        public String getFailingUrl() {
            assert getCallCount() > 0;
            return mFailingUrl;
        }
    }
    public static class OnEvaluateJavaScriptResultHelper extends CallbackHelper {
        private String mJsonResult;
        
        public void evaluateJavaScript(ContentViewCore contentViewCore, String code) {
            ContentViewCore.JavaScriptCallback callback =
                new ContentViewCore.JavaScriptCallback() {
                    @Override
                    public void handleJavaScriptResult(String jsonResult) {
                        notifyCalled(jsonResult);
                    }
                };
            contentViewCore.evaluateJavaScript(code, callback);
            mJsonResult = null;
        }
        
        public boolean hasValue() {
            return mJsonResult != null;
        }
        
        public String getJsonResultAndClear() {
            assert hasValue();
            String result = mJsonResult;
            mJsonResult = null;
            return result;
        }
        
        public Criteria getHasValueCriteria() {
            return new Criteria() {
                @Override
                public boolean isSatisfied() {
                    return hasValue();
                }
            };
        }
        
        public boolean waitUntilHasValue(long timeout, TimeUnit timeoutUnits)
                throws InterruptedException, TimeoutException {
            waitUntilCriteria(getHasValueCriteria(), timeout, timeoutUnits);
            return hasValue();
        }
        public boolean waitUntilHasValue() throws InterruptedException, TimeoutException {
            waitUntilCriteria(getHasValueCriteria());
            return hasValue();
        }
        public void notifyCalled(String jsonResult) {
            assert !hasValue();
            mJsonResult = jsonResult;
            notifyCalled();
        }
    }
    public static class OnStartContentIntentHelper extends CallbackHelper {
        private String mIntentUrl;
        public void notifyCalled(String intentUrl) {
            mIntentUrl = intentUrl;
            notifyCalled();
        }
        public String getIntentUrl() {
            assert getCallCount() > 0;
            return mIntentUrl;
        }
    }
    public OnPageStartedHelper getOnPageStartedHelper() {
        return mTestWebContentsObserver.getOnPageStartedHelper();
    }
    public OnPageFinishedHelper getOnPageFinishedHelper() {
        return mTestWebContentsObserver.getOnPageFinishedHelper();
    }
    public OnReceivedErrorHelper getOnReceivedErrorHelper() {
        return mTestWebContentsObserver.getOnReceivedErrorHelper();
    }
    public OnEvaluateJavaScriptResultHelper getOnEvaluateJavaScriptResultHelper() {
        return mTestContentViewClient.getOnEvaluateJavaScriptResultHelper();
    }
    public OnStartContentIntentHelper getOnStartContentIntentHelper() {
        return mTestContentViewClient.getOnStartContentIntentHelper();
    }
}