Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / shell / android / browsertests_apk / src / org / chromium / content_browsertests_apk / ContentBrowserTestsActivity.java
1 // Copyright 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
5 package org.chromium.content_browsertests_apk;
6
7 import android.app.Activity;
8 import android.content.Context;
9 import android.os.Bundle;
10 import android.util.Log;
11 import android.view.LayoutInflater;
12 import android.view.View;
13
14 import org.chromium.base.JNINamespace;
15 import org.chromium.base.library_loader.LibraryLoader;
16 import org.chromium.base.library_loader.ProcessInitException;
17 import org.chromium.content.browser.BrowserStartupController;
18 import org.chromium.content_shell.ShellManager;
19 import org.chromium.ui.base.ActivityWindowAndroid;
20 import org.chromium.ui.base.WindowAndroid;
21
22 /**
23  * Android activity for running content browser tests
24  */
25 @JNINamespace("content")
26 public class ContentBrowserTestsActivity extends Activity {
27     private static final String TAG = "ChromeBrowserTestsActivity";
28
29     private ShellManager mShellManager;
30     private WindowAndroid mWindowAndroid;
31
32     @Override
33     public void onCreate(Bundle savedInstanceState) {
34         super.onCreate(savedInstanceState);
35
36         try {
37             LibraryLoader.ensureInitialized();
38         } catch (ProcessInitException e) {
39             Log.i(TAG, "Cannot load content_browsertests:" +  e);
40             System.exit(-1);
41         }
42         BrowserStartupController.get(getApplicationContext()).initChromiumBrowserProcessForTests();
43
44         LayoutInflater inflater =
45                 (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
46         View view = inflater.inflate(R.layout.test_activity, null);
47         mShellManager = (ShellManager) view.findViewById(R.id.shell_container);
48         mWindowAndroid = new ActivityWindowAndroid(this);
49         mShellManager.setWindow(mWindowAndroid);
50
51         Log.i(TAG, "Running tests");
52         runTests();
53         Log.i(TAG, "Tests finished.");
54         finish();
55     }
56
57     private void runTests() {
58         nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext());
59     }
60
61     private native void nativeRunTests(String filesDir, Context appContext);
62 }