Upstream version 9.38.204.0
[platform/framework/web/crosswalk.git] / src / xwalk / test / android / util / runtime_client / src / org / xwalk / test / util / XWalkRuntimeClientTestGeneric.java
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2013 Intel Corporation. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 package org.xwalk.test.util;
7
8 import android.app.Activity;
9 import android.content.Context;
10 import android.test.ActivityInstrumentationTestCase2;
11
12 import org.xwalk.app.runtime.XWalkRuntimeView;
13 import org.xwalk.app.XWalkRuntimeActivityBase;
14 import org.xwalk.test.util.XWalkRuntimeClientTestUtilBase.PageStatusCallback;
15
16 public class XWalkRuntimeClientTestGeneric<T extends XWalkRuntimeActivityBase>
17         extends ActivityInstrumentationTestCase2<T> {
18     private XWalkRuntimeView mRuntimeView;
19     XWalkRuntimeClientTestUtilBase mTestUtil;
20
21     @Override
22     protected void setUp() throws Exception {
23         super.setUp();
24
25         final XWalkRuntimeActivityBase activity = getActivity();
26         getInstrumentation().runOnMainSync(new Runnable() {
27             @Override
28             public void run() {
29                 if (mRuntimeView == null) {
30                     mRuntimeView = activity.getRuntimeView();
31                 }
32                 mTestUtil = new XWalkRuntimeClientTestUtilBase(mRuntimeView,
33                         getInstrumentation());
34                 PageStatusCallback callback = mTestUtil.new PageStatusCallback();
35                 mRuntimeView.setCallbackForTest((Object)callback);
36                 postSetUp();
37             }
38         });
39     }
40
41     public void postSetUp() {
42     }
43
44     public XWalkRuntimeClientTestGeneric(Class<T> activityClass) {
45         super(activityClass);
46     }
47
48     public XWalkRuntimeClientTestUtilBase getTestUtil() {
49         return mTestUtil;
50     }
51 }