d08e6f8eff7f5f4234d121fe1e3f5abadfdbf4ca
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / runtime / src / org / xwalk / runtime / XWalkWebChromeClientForTest.java
1 // Copyright (c) 2013 Intel Corporation. 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
5 package org.xwalk.runtime;
6
7 import android.content.Context;
8
9 import java.lang.reflect.Method;
10
11 import org.xwalk.core.XWalkDefaultWebChromeClient;
12 import org.xwalk.core.XWalkView;
13
14 class XWalkWebChromeClientForTest extends XWalkDefaultWebChromeClient{
15     private Object mCallbackForTest;
16
17     public XWalkWebChromeClientForTest(Context context, XWalkView view) {
18         super(context, view);
19     }
20
21     public void setCallbackForTest(Object callback) {
22         mCallbackForTest = callback;
23     }
24
25     @Override
26     public void onReceivedTitle(XWalkView view, String title) {
27         if (mCallbackForTest != null) {
28             try {
29                 Class<?> objectClass = mCallbackForTest.getClass();
30                 Method onReceivedTitle = objectClass.getMethod("onReceivedTitle", String.class);
31                 onReceivedTitle.invoke(mCallbackForTest, title);
32             } catch (Exception e) {
33                 e.printStackTrace();
34             }
35         }
36     }
37 }