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

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

Issue 10959020: SystemMonitor refactoring: move power state monitor into a separate class called PowerMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Use holder class for lazy initialization on Android Created 7 years, 8 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
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | webkit/blob/blob_url_request_job.h » ('j') | 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.ChromiumActivity; 14 import org.chromium.base.ChromiumActivity;
15 import org.chromium.base.PathUtils; 15 import org.chromium.base.PathUtils;
16 import org.chromium.base.SystemMonitor; 16 import org.chromium.base.PowerMonitor;
17 17
18 import java.io.File; 18 import java.io.File;
19 19
20 // Android's NativeActivity is mostly useful for pure-native code. 20 // Android's NativeActivity is mostly useful for pure-native code.
21 // Our tests need to go up to our own java classes, which is not possible using 21 // Our tests need to go up to our own java classes, which is not possible using
22 // the native activity class loader. 22 // the native activity class loader.
23 public class ChromeNativeTestActivity extends ChromiumActivity { 23 public class ChromeNativeTestActivity extends ChromiumActivity {
24 private static final String TAG = "ChromeNativeTestActivity"; 24 private static final String TAG = "ChromeNativeTestActivity";
25 private static final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread"; 25 private static final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread";
26 // We post a delayed task to run tests so that we do not block onCreate(). 26 // We post a delayed task to run tests so that we do not block onCreate().
27 private static final long RUN_TESTS_DELAY_IN_MS = 300; 27 private static final long RUN_TESTS_DELAY_IN_MS = 300;
28 28
29 // Name of our shlib as obtained from a string resource. 29 // Name of our shlib as obtained from a string resource.
30 private String mLibrary; 30 private String mLibrary;
31 31
32 @Override 32 @Override
33 public void onCreate(Bundle savedInstanceState) { 33 public void onCreate(Bundle savedInstanceState) {
34 super.onCreate(savedInstanceState); 34 super.onCreate(savedInstanceState);
35 35
36 mLibrary = getResources().getString(R.string.native_library); 36 mLibrary = getResources().getString(R.string.native_library);
37 if ((mLibrary == null) || mLibrary.startsWith("replace")) { 37 if ((mLibrary == null) || mLibrary.startsWith("replace")) {
38 nativeTestFailed(); 38 nativeTestFailed();
39 return; 39 return;
40 } 40 }
41 41
42 // Needed by path_utils_unittest.cc 42 // Needed by path_utils_unittest.cc
43 PathUtils.setPrivateDataDirectorySuffix("chrome"); 43 PathUtils.setPrivateDataDirectorySuffix("chrome");
44 44
45 // Needed by system_monitor_unittest.cc 45 // Needed by system_monitor_unittest.cc
46 SystemMonitor.createForTests(this); 46 PowerMonitor.createForTests(this);
47 47
48 48
49 loadLibrary(); 49 loadLibrary();
50 Bundle extras = this.getIntent().getExtras(); 50 Bundle extras = this.getIntent().getExtras();
51 if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) { 51 if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) {
52 // Create a new thread and run tests on it. 52 // Create a new thread and run tests on it.
53 new Thread() { 53 new Thread() {
54 @Override 54 @Override
55 public void run() { 55 public void run() {
56 runTests(); 56 runTests();
(...skipping 24 matching lines...) Expand all
81 } 81 }
82 82
83 private void loadLibrary() { 83 private void loadLibrary() {
84 Log.i(TAG, "loading: " + mLibrary); 84 Log.i(TAG, "loading: " + mLibrary);
85 System.loadLibrary(mLibrary); 85 System.loadLibrary(mLibrary);
86 Log.i(TAG, "loaded: " + mLibrary); 86 Log.i(TAG, "loaded: " + mLibrary);
87 } 87 }
88 88
89 private native void nativeRunTests(String filesDir, Context appContext); 89 private native void nativeRunTests(String filesDir, Context appContext);
90 } 90 }
OLDNEW
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | webkit/blob/blob_url_request_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698