Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java

Issue 11027024: Android: Integrates native and java SystemMonitor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initialize java side for tests. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/system_monitor/system_monitor_android.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.native_test; 5 package org.chromium.native_test;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Context; 8 import android.content.Context;
9 import android.os.Bundle; 9 import android.os.Bundle;
10 import android.os.Environment; 10 import android.os.Environment;
11 import android.os.Handler; 11 import android.os.Handler;
12 import android.util.Log; 12 import android.util.Log;
13 13
14 import org.chromium.base.PathUtils; 14 import org.chromium.base.PathUtils;
15 import org.chromium.base.SystemMonitor;
15 16
16 import java.io.File; 17 import java.io.File;
17 18
18 // Android's NativeActivity is mostly useful for pure-native code. 19 // Android's NativeActivity is mostly useful for pure-native code.
19 // Our tests need to go up to our own java classes, which is not possible using 20 // Our tests need to go up to our own java classes, which is not possible using
20 // the native activity class loader. 21 // the native activity class loader.
21 public class ChromeNativeTestActivity extends Activity { 22 public class ChromeNativeTestActivity extends Activity {
22 private final String TAG = "ChromeNativeTestActivity"; 23 private final String TAG = "ChromeNativeTestActivity";
23 private final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread"; 24 private final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread";
24 // We post a delayed task to run tests so that we do not block onCreate(). 25 // We post a delayed task to run tests so that we do not block onCreate().
25 private static long RUN_TESTS_DELAY_IN_MS = 300; 26 private static long RUN_TESTS_DELAY_IN_MS = 300;
26 27
27 // Name of our shlib as obtained from a string resource. 28 // Name of our shlib as obtained from a string resource.
28 private String mLibrary; 29 private String mLibrary;
29 30
30 @Override 31 @Override
31 public void onCreate(Bundle savedInstanceState) { 32 public void onCreate(Bundle savedInstanceState) {
32 super.onCreate(savedInstanceState); 33 super.onCreate(savedInstanceState);
33 34
34 mLibrary = getResources().getString(R.string.native_library); 35 mLibrary = getResources().getString(R.string.native_library);
35 if ((mLibrary == null) || mLibrary.startsWith("replace")) { 36 if ((mLibrary == null) || mLibrary.startsWith("replace")) {
36 nativeTestFailed(); 37 nativeTestFailed();
37 return; 38 return;
38 } 39 }
39 40
40 // Needed by path_utils_unittest.cc 41 // Needed by path_utils_unittest.cc
41 PathUtils.setPrivateDataDirectorySuffix("chrome"); 42 PathUtils.setPrivateDataDirectorySuffix("chrome");
42 43
44 // Needed by system_monitor_unittest.cc
Satish 2012/10/08 13:58:10 Since this is required only by 1 test, it is overh
bulach 2012/10/08 14:01:04 thanks! that's correct, there are no alternatives,
45 SystemMonitor.createForTests(this);
46
43 try { 47 try {
44 loadLibrary(); 48 loadLibrary();
45 Bundle extras = this.getIntent().getExtras(); 49 Bundle extras = this.getIntent().getExtras();
46 if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) { 50 if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) {
47 // Create a new thread and run tests on it. 51 // Create a new thread and run tests on it.
48 new Thread() { 52 new Thread() {
49 @Override 53 @Override
50 public void run() { 54 public void run() {
51 runTests(); 55 runTests();
52 } 56 }
(...skipping 28 matching lines...) Expand all
81 } 85 }
82 86
83 private void loadLibrary() throws UnsatisfiedLinkError { 87 private void loadLibrary() throws UnsatisfiedLinkError {
84 Log.i(TAG, "loading: " + mLibrary); 88 Log.i(TAG, "loading: " + mLibrary);
85 System.loadLibrary(mLibrary); 89 System.loadLibrary(mLibrary);
86 Log.i(TAG, "loaded: " + mLibrary); 90 Log.i(TAG, "loaded: " + mLibrary);
87 } 91 }
88 92
89 private native void nativeRunTests(String filesDir, Context appContext); 93 private native void nativeRunTests(String filesDir, Context appContext);
90 } 94 }
OLDNEW
« no previous file with comments | « base/system_monitor/system_monitor_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698