EMMA Coverage Report (generated Fri Aug 23 16:39:17 PDT 2013)
[all classes][org.chromium.native_test]

COVERAGE SUMMARY FOR SOURCE FILE [ChromeNativeTestActivity.java]

nameclass, %method, %block, %line, %
ChromeNativeTestActivity.java0%   (0/3)0%   (0/10)0%   (0/116)0%   (0/23)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ChromeNativeTestActivity0%   (0/1)0%   (0/6)0%   (0/96)0%   (0/19)
ChromeNativeTestActivity (): void 0%   (0/1)0%   (0/3)0%   (0/1)
access$000 (ChromeNativeTestActivity): void 0%   (0/1)0%   (0/3)0%   (0/1)
loadLibraries (): void 0%   (0/1)0%   (0/41)0%   (0/5)
nativeTestFailed (): void 0%   (0/1)0%   (0/5)0%   (0/2)
onCreate (Bundle): void 0%   (0/1)0%   (0/36)0%   (0/9)
runTests (): void 0%   (0/1)0%   (0/8)0%   (0/2)
     
class ChromeNativeTestActivity$10%   (0/1)0%   (0/2)0%   (0/10)0%   (0/3)
ChromeNativeTestActivity$1 (ChromeNativeTestActivity): void 0%   (0/1)0%   (0/6)0%   (0/1)
run (): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class ChromeNativeTestActivity$20%   (0/1)0%   (0/2)0%   (0/10)0%   (0/3)
ChromeNativeTestActivity$2 (ChromeNativeTestActivity): void 0%   (0/1)0%   (0/6)0%   (0/1)
run (): void 0%   (0/1)0%   (0/4)0%   (0/2)

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 
5package org.chromium.native_test;
6 
7import android.app.Activity;
8import android.content.Context;
9import android.os.Bundle;
10import android.os.Environment;
11import android.os.Handler;
12import android.util.Log;
13 
14import org.chromium.base.ChromiumActivity;
15import org.chromium.base.PathUtils;
16import org.chromium.base.PowerMonitor;
17 
18// TODO(cjhopman): This should not refer to content. NativeLibraries should be moved to base.
19import org.chromium.content.app.NativeLibraries;
20 
21import java.io.File;
22 
23// Android's NativeActivity is mostly useful for pure-native code.
24// Our tests need to go up to our own java classes, which is not possible using
25// the native activity class loader.
26public class ChromeNativeTestActivity extends ChromiumActivity {
27    private static final String TAG = "ChromeNativeTestActivity";
28    private static final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread";
29    // We post a delayed task to run tests so that we do not block onCreate().
30    private static final long RUN_TESTS_DELAY_IN_MS = 300;
31 
32    @Override
33    public void onCreate(Bundle savedInstanceState) {
34        super.onCreate(savedInstanceState);
35        // Needed by path_utils_unittest.cc
36        PathUtils.setPrivateDataDirectorySuffix("chrome");
37 
38        // Needed by system_monitor_unittest.cc
39        PowerMonitor.createForTests(this);
40 
41        loadLibraries();
42        Bundle extras = this.getIntent().getExtras();
43        if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) {
44            // Create a new thread and run tests on it.
45            new Thread() {
46                @Override
47                public void run() {
48                    runTests();
49                }
50            }.start();
51        } else {
52            // Post a task to run the tests. This allows us to not block
53            // onCreate and still run tests on the main thread.
54            new Handler().postDelayed(new Runnable() {
55                  @Override
56                  public void run() {
57                      runTests();
58                  }
59              }, RUN_TESTS_DELAY_IN_MS);
60        }
61    }
62 
63    private void runTests() {
64        // This directory is used by build/android/pylib/test_package_apk.py.
65        nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext());
66    }
67 
68    // Signal a failure of the native test loader to python scripts
69    // which run tests.  For example, we look for
70    // RUNNER_FAILED build/android/test_package.py.
71    private void nativeTestFailed() {
72        Log.e(TAG, "[ RUNNER_FAILED ] could not load native library");
73    }
74 
75    private void loadLibraries() {
76        for (String library: NativeLibraries.libraries) {
77            Log.i(TAG, "loading: " + library);
78            System.loadLibrary(library);
79            Log.i(TAG, "loaded: " + library);
80        }
81    }
82 
83    private native void nativeRunTests(String filesDir, Context appContext);
84}

[all classes][org.chromium.native_test]
EMMA 2.0.5312 (C) Vladimir Roubtsov