Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5fbd41b authored by Joel Fernandes's avatar Joel Fernandes
Browse files

JankBench: make it build and run in Android build



JankBench is a tool heavily used for scheduler and graphics testing.
JankBench has been an android studio project and traditionally its APK
has been built outside of the Android tree using studio. This patch
makes it possible to build it using Android source tree without needing
studio.

Some library imports needed renaming and an xml file had a typo, also
resource IDs need to be 16-bits so I fixed that up. List fragments can't
be anonymous instantiations anymore so changed it to be non-anonymous.

Bug: 31544438
Test: Run all Jankbench benchmarks manually in the app.
Change-Id: Ib5e4351fcc72acdec20424ae30598c205e7803f7
Signed-off-by: default avatarJoel Fernandes <joelaf@google.com>
parent 7467d044
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := tests

LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml

LOCAL_SDK_VERSION := current

LOCAL_USE_AAPT2 := true

# omit gradle 'build' dir
LOCAL_SRC_FILES := $(call all-java-files-under,app/src/main/java)

# use appcompat/support lib from the tree, so improvements/
# regressions are reflected in test data
LOCAL_RESOURCE_DIR := \
    $(LOCAL_PATH)/app/src/main/res \


LOCAL_STATIC_ANDROID_LIBRARIES := \
    android-support-design \
    android-support-v4 \
    android-support-v7-appcompat \
    android-support-v7-cardview \
    android-support-v7-recyclerview \
    android-support-v17-leanback \

LOCAL_STATIC_JAVA_LIBRARIES := \
    apache-commons-math \
    junit


LOCAL_PACKAGE_NAME := JankBench

LOCAL_COMPATIBILITY_SUITE := device-tests

include $(BUILD_PACKAGE)
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the
 * License.
 *
 */

package com.android.benchmark;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
 * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
 */
public class ApplicationTest extends ApplicationTestCase<Application> {
    public ApplicationTest() {
        super(Application.class);
    }
}
+62 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2015 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~        http://www.apache.org/licenses/LICENSE-2.0
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and limitations under the
  ~ License.
  ~
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.benchmark">

    <uses-sdk android:minSdkVersion="24" />

    <android:uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <android:uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".app.HomeActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".app.RunLocalBenchmarksActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="com.android.benchmark.ACTION_BENCHMARK" />
            </intent-filter>

            <meta-data
                android:name="com.android.benchmark.benchmark_group"
                android:resource="@xml/benchmark" />
        </activity>
        <activity android:name=".ui.ListViewScrollActivity" />
        <activity android:name=".ui.ImageListViewScrollActivity" />
        <activity android:name=".ui.ShadowGridActivity" />
        <activity android:name=".ui.TextScrollActivity" />
        <activity android:name=".ui.EditTextInputActivity" />
        <activity android:name=".synthetic.MemoryActivity" />
        <activity android:name=".ui.FullScreenOverdrawActivity"></activity>
        <activity android:name=".ui.BitmapUploadActivity"></activity>
    </application>

</manifest>
 No newline at end of file
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the
 * License.
 *
 */

package com.android.benchmark.app;

import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.benchmark.R;

/**
 * Fragment for the Benchmark dashboard
 */
public class BenchmarkDashboardFragment extends Fragment {

    public BenchmarkDashboardFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_dashboard, container, false);
    }
}
+126 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the
 * License.
 *
 */

package com.android.benchmark.app;

import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.android.benchmark.registry.BenchmarkGroup;
import com.android.benchmark.registry.BenchmarkRegistry;
import com.android.benchmark.R;

/**
 *
 */
public class BenchmarkListAdapter extends BaseExpandableListAdapter {

    private final LayoutInflater mInflater;
    private final BenchmarkRegistry mRegistry;

    BenchmarkListAdapter(LayoutInflater inflater,
                         BenchmarkRegistry registry) {
        mInflater = inflater;
        mRegistry = registry;
    }

    @Override
    public int getGroupCount() {
        return mRegistry.getGroupCount();
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return mRegistry.getBenchmarkCount(groupPosition);
    }

    @Override
    public Object getGroup(int groupPosition) {
        return mRegistry.getBenchmarkGroup(groupPosition);
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        BenchmarkGroup benchmarkGroup = mRegistry.getBenchmarkGroup(groupPosition);

        if (benchmarkGroup != null) {
           return benchmarkGroup.getBenchmarks()[childPosition];
        }

        return null;
    }

    @Override
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        BenchmarkGroup group = (BenchmarkGroup) getGroup(groupPosition);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.benchmark_list_group_row, null);
        }

        TextView title = (TextView) convertView.findViewById(R.id.group_name);
        title.setTypeface(null, Typeface.BOLD);
        title.setText(group.getTitle());
        return convertView;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                             View convertView, ViewGroup parent) {
        BenchmarkGroup.Benchmark benchmark =
                (BenchmarkGroup.Benchmark) getChild(groupPosition, childPosition);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.benchmark_list_item, null);
        }

        TextView name = (TextView) convertView.findViewById(R.id.benchmark_name);
        name.setText(benchmark.getName());
        CheckBox enabledBox = (CheckBox) convertView.findViewById(R.id.benchmark_enable_checkbox);
        enabledBox.setOnClickListener(benchmark);
        enabledBox.setChecked(benchmark.isEnabled());

        return convertView;
    }

    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }

    public int getChildrenHeight() {
        // TODO
        return 1024;
    }
}
Loading