| 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 | |
| 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.view.LayoutInflater; |
| 11 | import android.view.View; |
| 12 | import android.util.Log; |
| 13 | |
| 14 | import org.chromium.base.JNINamespace; |
| 15 | import org.chromium.content.app.LibraryLoader; |
| 16 | import org.chromium.content.browser.AndroidBrowserProcess; |
| 17 | import org.chromium.content.common.ProcessInitException; |
| 18 | import org.chromium.content_shell.ShellManager; |
| 19 | import org.chromium.ui.WindowAndroid; |
| 20 | |
| 21 | @JNINamespace("content") |
| 22 | public class ContentBrowserTestsActivity extends Activity { |
| 23 | private static final String TAG = "ChromeBrowserTestsActivity"; |
| 24 | |
| 25 | private ShellManager mShellManager; |
| 26 | private WindowAndroid mWindowAndroid; |
| 27 | |
| 28 | @Override |
| 29 | public void onCreate(Bundle savedInstanceState) { |
| 30 | super.onCreate(savedInstanceState); |
| 31 | |
| 32 | try { |
| 33 | LibraryLoader.ensureInitialized(); |
| 34 | } catch (ProcessInitException e) { |
| 35 | Log.i(TAG, "Cannot load content_browsertests:" + e); |
| 36 | } |
| 37 | AndroidBrowserProcess.initChromiumBrowserProcessForTests(getApplicationContext()); |
| 38 | |
| 39 | LayoutInflater inflater = |
| 40 | (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 41 | View view = inflater.inflate(R.layout.test_activity, null); |
| 42 | mShellManager = (ShellManager) view.findViewById(R.id.shell_container); |
| 43 | mWindowAndroid = new WindowAndroid(this); |
| 44 | mShellManager.setWindow(mWindowAndroid); |
| 45 | |
| 46 | Log.i(TAG, "Running tests"); |
| 47 | runTests(); |
| 48 | Log.i(TAG, "Tests finished."); |
| 49 | finish(); |
| 50 | } |
| 51 | |
| 52 | private void runTests() { |
| 53 | nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext()); |
| 54 | } |
| 55 | |
| 56 | private native void nativeRunTests(String filesDir, Context appContext); |
| 57 | } |