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

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

Issue 11567061: Throw exception when initialization failed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 11 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 | « content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java ('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;
(...skipping 27 matching lines...) Expand all
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 SystemMonitor.createForTests(this);
47 47
48 try { 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();
57 } 57 }
58 }.start(); 58 }.start();
59 } else { 59 } else {
60 // Post a task to run the tests. This allows us to not block 60 // Post a task to run the tests. This allows us to not block
61 // onCreate and still run tests on the main thread. 61 // onCreate and still run tests on the main thread.
62 new Handler().postDelayed(new Runnable() { 62 new Handler().postDelayed(new Runnable() {
63 @Override 63 @Override
64 public void run() { 64 public void run() {
65 runTests(); 65 runTests();
66 } 66 }
67 }, RUN_TESTS_DELAY_IN_MS); 67 }, RUN_TESTS_DELAY_IN_MS);
68 }
69 } catch (UnsatisfiedLinkError e) {
70 Log.e(TAG, "Unable to load lib" + mLibrary + ".so: " + e);
71 nativeTestFailed();
72 throw e;
73 } 68 }
74 } 69 }
75 70
76 private void runTests() { 71 private void runTests() {
77 // This directory is used by build/android/pylib/test_package_apk.py. 72 // This directory is used by build/android/pylib/test_package_apk.py.
78 nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext()) ; 73 nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext()) ;
79 } 74 }
80 75
81 // Signal a failure of the native test loader to python scripts 76 // Signal a failure of the native test loader to python scripts
82 // which run tests. For example, we look for 77 // which run tests. For example, we look for
83 // RUNNER_FAILED build/android/test_package.py. 78 // RUNNER_FAILED build/android/test_package.py.
84 private void nativeTestFailed() { 79 private void nativeTestFailed() {
85 Log.e(TAG, "[ RUNNER_FAILED ] could not load native library"); 80 Log.e(TAG, "[ RUNNER_FAILED ] could not load native library");
86 } 81 }
87 82
88 private void loadLibrary() throws UnsatisfiedLinkError { 83 private void loadLibrary() {
89 Log.i(TAG, "loading: " + mLibrary); 84 Log.i(TAG, "loading: " + mLibrary);
90 System.loadLibrary(mLibrary); 85 System.loadLibrary(mLibrary);
91 Log.i(TAG, "loaded: " + mLibrary); 86 Log.i(TAG, "loaded: " + mLibrary);
92 } 87 }
93 88
94 private native void nativeRunTests(String filesDir, Context appContext); 89 private native void nativeRunTests(String filesDir, Context appContext);
95 } 90 }
OLDNEW
« no previous file with comments | « content/shell/android/java/src/org/chromium/content_shell/ContentShellActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698