summaryrefslogtreecommitdiff
path: root/chromium/testing/android
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2013-12-11 21:33:03 +0100
committerAndras Becsi <andras.becsi@digia.com>2013-12-13 12:34:07 +0100
commitf2a33ff9cbc6d19943f1c7fbddd1f23d23975577 (patch)
tree0586a32aa390ade8557dfd6b4897f43a07449578 /chromium/testing/android
parent5362912cdb5eea702b68ebe23702468d17c3017a (diff)
downloadqtwebengine-chromium-f2a33ff9cbc6d19943f1c7fbddd1f23d23975577.tar.gz
Update Chromium to branch 1650 (31.0.1650.63)
Change-Id: I57d8c832eaec1eb2364e0a8e7352a6dd354db99f Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'chromium/testing/android')
-rw-r--r--chromium/testing/android/AndroidManifest.xml33
-rw-r--r--chromium/testing/android/OWNERS2
-rw-r--r--chromium/testing/android/README.chromium2
-rw-r--r--chromium/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java84
-rw-r--r--chromium/testing/android/native_test_launcher.cc202
-rw-r--r--chromium/testing/android/native_test_util.cc54
-rw-r--r--chromium/testing/android/native_test_util.h37
7 files changed, 0 insertions, 414 deletions
diff --git a/chromium/testing/android/AndroidManifest.xml b/chromium/testing/android/AndroidManifest.xml
deleted file mode 100644
index 73a0c148819..00000000000
--- a/chromium/testing/android/AndroidManifest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-Copyright (c) 2012 The Chromium Authors. All rights reserved.
-Use of this source code is governed by a BSD-style license that can be
-found in the LICENSE file.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.chromium.native_test"
- android:versionCode="1"
- android:versionName="1.0">
-
- <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17" />
-
- <application android:label="ChromeNativeTests">
- <activity android:name=".ChromeNativeTestActivity"
- android:label="ChromeNativeTest"
- android:configChanges="orientation|keyboardHidden">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
- <uses-permission android:name="android.permission.RECORD_AUDIO"/>
- <uses-permission android:name="android.permission.WAKE_LOCK"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
-
-</manifest>
diff --git a/chromium/testing/android/OWNERS b/chromium/testing/android/OWNERS
deleted file mode 100644
index 87d5d224978..00000000000
--- a/chromium/testing/android/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-bulach@chromium.org
-yfriedman@chromium.org
diff --git a/chromium/testing/android/README.chromium b/chromium/testing/android/README.chromium
deleted file mode 100644
index c00255a43af..00000000000
--- a/chromium/testing/android/README.chromium
+++ /dev/null
@@ -1,2 +0,0 @@
-apk-based runner for Chromium unit test bundles. This is a simple wrapper APK
-that should include a single gtest native library.
diff --git a/chromium/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java b/chromium/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
deleted file mode 100644
index 6486a14f3cb..00000000000
--- a/chromium/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.native_test;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.Handler;
-import android.util.Log;
-
-import org.chromium.base.ChromiumActivity;
-import org.chromium.base.PathUtils;
-import org.chromium.base.PowerMonitor;
-
-// TODO(cjhopman): This should not refer to content. NativeLibraries should be moved to base.
-import org.chromium.content.app.NativeLibraries;
-
-import java.io.File;
-
-// Android's NativeActivity is mostly useful for pure-native code.
-// Our tests need to go up to our own java classes, which is not possible using
-// the native activity class loader.
-public class ChromeNativeTestActivity extends ChromiumActivity {
- private static final String TAG = "ChromeNativeTestActivity";
- private static final String EXTRA_RUN_IN_SUB_THREAD = "RunInSubThread";
- // We post a delayed task to run tests so that we do not block onCreate().
- private static final long RUN_TESTS_DELAY_IN_MS = 300;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Needed by path_utils_unittest.cc
- PathUtils.setPrivateDataDirectorySuffix("chrome");
-
- // Needed by system_monitor_unittest.cc
- PowerMonitor.createForTests(this);
-
- loadLibraries();
- Bundle extras = this.getIntent().getExtras();
- if (extras != null && extras.containsKey(EXTRA_RUN_IN_SUB_THREAD)) {
- // Create a new thread and run tests on it.
- new Thread() {
- @Override
- public void run() {
- runTests();
- }
- }.start();
- } else {
- // Post a task to run the tests. This allows us to not block
- // onCreate and still run tests on the main thread.
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- runTests();
- }
- }, RUN_TESTS_DELAY_IN_MS);
- }
- }
-
- private void runTests() {
- // This directory is used by build/android/pylib/test_package_apk.py.
- nativeRunTests(getFilesDir().getAbsolutePath(), getApplicationContext());
- }
-
- // Signal a failure of the native test loader to python scripts
- // which run tests. For example, we look for
- // RUNNER_FAILED build/android/test_package.py.
- private void nativeTestFailed() {
- Log.e(TAG, "[ RUNNER_FAILED ] could not load native library");
- }
-
- private void loadLibraries() {
- for (String library: NativeLibraries.libraries) {
- Log.i(TAG, "loading: " + library);
- System.loadLibrary(library);
- Log.i(TAG, "loaded: " + library);
- }
- }
-
- private native void nativeRunTests(String filesDir, Context appContext);
-}
diff --git a/chromium/testing/android/native_test_launcher.cc b/chromium/testing/android/native_test_launcher.cc
deleted file mode 100644
index e39eb2bdccb..00000000000
--- a/chromium/testing/android/native_test_launcher.cc
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This class sets up the environment for running the native tests inside an
-// android application. It outputs (to a fifo) markers identifying the
-// START/PASSED/CRASH of the test suite, FAILURE/SUCCESS of individual tests,
-// etc.
-// These markers are read by the test runner script to generate test results.
-// It installs signal handlers to detect crashes.
-
-#include <android/log.h>
-#include <signal.h>
-
-#include "base/android/base_jni_registrar.h"
-#include "base/android/fifo_utils.h"
-#include "base/android/jni_android.h"
-#include "base/android/jni_string.h"
-#include "base/android/scoped_java_ref.h"
-#include "base/at_exit.h"
-#include "base/base_switches.h"
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/logging.h"
-#include "base/strings/stringprintf.h"
-#include "gtest/gtest.h"
-#include "testing/android/native_test_util.h"
-#include "testing/jni/ChromeNativeTestActivity_jni.h"
-
-using testing::native_test_util::ArgsToArgv;
-using testing::native_test_util::ParseArgsFromCommandLineFile;
-using testing::native_test_util::ScopedMainEntryLogger;
-
-// The main function of the program to be wrapped as a test apk.
-extern int main(int argc, char** argv);
-
-namespace {
-
-// These two command line flags are supported for DumpRenderTree, which needs
-// three fifos rather than a combined one: one for stderr, stdin and stdout.
-const char kSeparateStderrFifo[] = "separate-stderr-fifo";
-const char kCreateStdinFifo[] = "create-stdin-fifo";
-
-// The test runner script writes the command line file in
-// "/data/local/tmp".
-static const char kCommandLineFilePath[] =
- "/data/local/tmp/chrome-native-tests-command-line";
-
-const char kLogTag[] = "chromium";
-const char kCrashedMarker[] = "[ CRASHED ]\n";
-
-// The list of signals which are considered to be crashes.
-const int kExceptionSignals[] = {
- SIGSEGV, SIGABRT, SIGFPE, SIGILL, SIGBUS, -1
-};
-
-struct sigaction g_old_sa[NSIG];
-
-// This function runs in a compromised context. It should not allocate memory.
-void SignalHandler(int sig, siginfo_t* info, void* reserved) {
- // Output the crash marker.
- write(STDOUT_FILENO, kCrashedMarker, sizeof(kCrashedMarker));
- g_old_sa[sig].sa_sigaction(sig, info, reserved);
-}
-
-// TODO(nileshagrawal): now that we're using FIFO, test scripts can detect EOF.
-// Remove the signal handlers.
-void InstallHandlers() {
- struct sigaction sa;
- memset(&sa, 0, sizeof(sa));
-
- sa.sa_sigaction = SignalHandler;
- sa.sa_flags = SA_SIGINFO;
-
- for (unsigned int i = 0; kExceptionSignals[i] != -1; ++i) {
- sigaction(kExceptionSignals[i], &sa, &g_old_sa[kExceptionSignals[i]]);
- }
-}
-
-// Writes printf() style string to Android's logger where |priority| is one of
-// the levels defined in <android/log.h>.
-void AndroidLog(int priority, const char* format, ...) {
- va_list args;
- va_start(args, format);
- __android_log_vprint(priority, kLogTag, format, args);
- va_end(args);
-}
-
-// Ensures that the fifo at |path| is created by deleting whatever is at |path|
-// prior to (re)creating the fifo, otherwise logs the error and terminates the
-// program.
-void EnsureCreateFIFO(const base::FilePath& path) {
- unlink(path.value().c_str());
- if (base::android::CreateFIFO(path, 0666))
- return;
-
- AndroidLog(ANDROID_LOG_ERROR, "Failed to create fifo %s: %s\n",
- path.value().c_str(), strerror(errno));
- exit(EXIT_FAILURE);
-}
-
-// Ensures that |stream| is redirected to |path|, otherwise logs the error and
-// terminates the program.
-void EnsureRedirectStream(FILE* stream,
- const base::FilePath& path,
- const char* mode) {
- if (base::android::RedirectStream(stream, path, mode))
- return;
-
- AndroidLog(ANDROID_LOG_ERROR, "Failed to redirect stream to file: %s: %s\n",
- path.value().c_str(), strerror(errno));
- exit(EXIT_FAILURE);
-}
-
-} // namespace
-
-// This method is called on a separate java thread so that we won't trigger
-// an ANR.
-static void RunTests(JNIEnv* env,
- jobject obj,
- jstring jfiles_dir,
- jobject app_context) {
- base::AtExitManager exit_manager;
-
- // Command line initialized basically, will be fully initialized later.
- static const char* const kInitialArgv[] = { "ChromeTestActivity" };
- CommandLine::Init(arraysize(kInitialArgv), kInitialArgv);
-
- // Set the application context in base.
- base::android::ScopedJavaLocalRef<jobject> scoped_context(
- env, env->NewLocalRef(app_context));
- base::android::InitApplicationContext(scoped_context);
- base::android::RegisterJni(env);
-
- std::vector<std::string> args;
- ParseArgsFromCommandLineFile(kCommandLineFilePath, &args);
-
- std::vector<char*> argv;
- int argc = ArgsToArgv(args, &argv);
-
- // Fully initialize command line with arguments.
- CommandLine::ForCurrentProcess()->AppendArguments(
- CommandLine(argc, &argv[0]), false);
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
-
- base::FilePath files_dir(
- base::android::ConvertJavaStringToUTF8(env, jfiles_dir));
-
- // A few options, such "--gtest_list_tests", will just use printf directly
- // Always redirect stdout to a known file.
- base::FilePath fifo_path(files_dir.Append(base::FilePath("test.fifo")));
- EnsureCreateFIFO(fifo_path);
-
- base::FilePath stderr_fifo_path, stdin_fifo_path;
-
- // DumpRenderTree needs a separate fifo for the stderr output. For all
- // other tests, insert stderr content to the same fifo we use for stdout.
- if (command_line.HasSwitch(kSeparateStderrFifo)) {
- stderr_fifo_path = files_dir.Append(base::FilePath("stderr.fifo"));
- EnsureCreateFIFO(stderr_fifo_path);
- }
-
- // DumpRenderTree uses stdin to receive input about which test to run.
- if (command_line.HasSwitch(kCreateStdinFifo)) {
- stdin_fifo_path = files_dir.Append(base::FilePath("stdin.fifo"));
- EnsureCreateFIFO(stdin_fifo_path);
- }
-
- // Only redirect the streams after all fifos have been created.
- EnsureRedirectStream(stdout, fifo_path, "w");
- if (!stdin_fifo_path.empty())
- EnsureRedirectStream(stdin, stdin_fifo_path, "r");
- if (!stderr_fifo_path.empty())
- EnsureRedirectStream(stderr, stderr_fifo_path, "w");
- else
- dup2(STDOUT_FILENO, STDERR_FILENO);
-
- if (command_line.HasSwitch(switches::kWaitForDebugger)) {
- AndroidLog(ANDROID_LOG_VERBOSE,
- "Native test waiting for GDB because flag %s was supplied",
- switches::kWaitForDebugger);
- base::debug::WaitForDebugger(24 * 60 * 60, false);
- }
-
- ScopedMainEntryLogger scoped_main_entry_logger;
- main(argc, &argv[0]);
-}
-
-// This is called by the VM when the shared library is first loaded.
-JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
- // Install signal handlers to detect crashes.
- InstallHandlers();
-
- base::android::InitVM(vm);
- JNIEnv* env = base::android::AttachCurrentThread();
- if (!RegisterNativesImpl(env)) {
- return -1;
- }
-
- return JNI_VERSION_1_4;
-}
diff --git a/chromium/testing/android/native_test_util.cc b/chromium/testing/android/native_test_util.cc
deleted file mode 100644
index c0ea7b0fef8..00000000000
--- a/chromium/testing/android/native_test_util.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "testing/android/native_test_util.h"
-
-#include "base/file_util.h"
-#include "base/files/file_path.h"
-#include "base/strings/string_tokenizer.h"
-#include "base/strings/string_util.h"
-
-namespace {
-
-void ParseArgsFromString(const std::string& command_line,
- std::vector<std::string>* args) {
- base::StringTokenizer tokenizer(command_line, kWhitespaceASCII);
- tokenizer.set_quote_chars("\"");
- while (tokenizer.GetNext()) {
- std::string token;
- RemoveChars(tokenizer.token(), "\"", &token);
- args->push_back(token);
- }
-}
-
-} // namespace
-
-namespace testing {
-namespace native_test_util {
-
-void ParseArgsFromCommandLineFile(
- const char* path, std::vector<std::string>* args) {
- base::FilePath command_line(path);
- std::string command_line_string;
- if (file_util::ReadFileToString(command_line, &command_line_string)) {
- ParseArgsFromString(command_line_string, args);
- }
-}
-
-int ArgsToArgv(const std::vector<std::string>& args,
- std::vector<char*>* argv) {
- // We need to pass in a non-const char**.
- int argc = args.size();
-
- argv->resize(argc + 1);
- for (int i = 0; i < argc; ++i) {
- (*argv)[i] = const_cast<char*>(args[i].c_str());
- }
- (*argv)[argc] = NULL; // argv must be NULL terminated.
-
- return argc;
-}
-
-} // namespace native_test_util
-} // namespace testing
diff --git a/chromium/testing/android/native_test_util.h b/chromium/testing/android/native_test_util.h
deleted file mode 100644
index a7567392b1e..00000000000
--- a/chromium/testing/android/native_test_util.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef TESTING_ANDROID_NATIVE_TEST_UTIL_
-#define TESTING_ANDROID_NATIVE_TEST_UTIL_
-
-#include <stdio.h>
-#include <string>
-#include <vector>
-
-// Helper methods for setting up environment for running gtest tests
-// inside an APK.
-namespace testing {
-namespace native_test_util {
-
-class ScopedMainEntryLogger {
- public:
- ScopedMainEntryLogger() {
- printf(">>ScopedMainEntryLogger\n");
- }
-
- ~ScopedMainEntryLogger() {
- printf("<<ScopedMainEntryLogger\n");
- fflush(stdout);
- fflush(stderr);
- }
-};
-
-void ParseArgsFromCommandLineFile(
- const char* path, std::vector<std::string>* args);
-int ArgsToArgv(const std::vector<std::string>& args, std::vector<char*>* argv);
-
-} // namespace native_test_util
-} // namespace testing
-
-#endif // TESTING_ANDROID_NATIVE_TEST_UTIL_