From b3dba557f679f0bf4b1e4bb2e2b0b4ad44f514b0 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Mon, 31 Aug 2015 17:22:04 -0700 Subject: [PATCH] Add Dialog list, shadow, inflation tests Change-Id: I39a18854248e7b4783fb7475c7aa9cc258a3c394 --- tests/UiBench/AndroidManifest.xml | 36 ++++++++++++++-- tests/UiBench/res/layout/card_row.xml | 45 +++++++++++++++++++ .../android/test/uibench/DialogListActivity.java | 38 ++++++++++++++++ .../test/uibench/InflatingListActivity.java | 50 ++++++++++++++++++++++ .../android/test/uibench/ShadowGridActivity.java | 45 +++++++++++++++++++ .../android/test/uibench/TrivialListActivity.java | 2 +- 6 files changed, 211 insertions(+), 5 deletions(-) create mode 100644 tests/UiBench/res/layout/card_row.xml create mode 100644 tests/UiBench/src/com/android/test/uibench/DialogListActivity.java create mode 100644 tests/UiBench/src/com/android/test/uibench/InflatingListActivity.java create mode 100644 tests/UiBench/src/com/android/test/uibench/ShadowGridActivity.java diff --git a/tests/UiBench/AndroidManifest.xml b/tests/UiBench/AndroidManifest.xml index d9df9f88b50c..f892a68eea39 100644 --- a/tests/UiBench/AndroidManifest.xml +++ b/tests/UiBench/AndroidManifest.xml @@ -14,11 +14,13 @@ ~ limitations under the License --> + xmlns:tools="http://schemas.android.com/tools" + package="com.android.test.uibench"> + android:theme="@style/Theme.AppCompat.Light.DarkActionBar" + tools:ignore="MissingApplicationIcon"> @@ -34,6 +36,14 @@ + + + + + + @@ -74,10 +84,28 @@ - + + android:label="Rendering/Bitmap Upload" > + + + + + + + + + + + + + + diff --git a/tests/UiBench/res/layout/card_row.xml b/tests/UiBench/res/layout/card_row.xml new file mode 100644 index 000000000000..215f9df9b7fd --- /dev/null +++ b/tests/UiBench/res/layout/card_row.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/tests/UiBench/src/com/android/test/uibench/DialogListActivity.java b/tests/UiBench/src/com/android/test/uibench/DialogListActivity.java new file mode 100644 index 000000000000..7b579a1e3554 --- /dev/null +++ b/tests/UiBench/src/com/android/test/uibench/DialogListActivity.java @@ -0,0 +1,38 @@ +/* + * 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.test.uibench; + +import android.os.Bundle; +import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatActivity; +import android.widget.ArrayAdapter; +import android.widget.ListView; + +public class DialogListActivity extends AppCompatActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + ListView listView = new ListView(this); + listView.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, + TrivialListActivity.buildStringList())); + + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle("Dialog"); + builder.setView(listView); + builder.create().show(); + } +} diff --git a/tests/UiBench/src/com/android/test/uibench/InflatingListActivity.java b/tests/UiBench/src/com/android/test/uibench/InflatingListActivity.java new file mode 100644 index 000000000000..798c226bd235 --- /dev/null +++ b/tests/UiBench/src/com/android/test/uibench/InflatingListActivity.java @@ -0,0 +1,50 @@ +/* + * 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.test.uibench; + +import android.os.Bundle; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.ListFragment; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ListAdapter; + +public class InflatingListActivity extends AppCompatActivity { + private ListAdapter createListAdapter() { + return new ArrayAdapter(this, + android.R.layout.simple_list_item_1, TrivialListActivity.buildStringList()) { + @Override + public View getView(int position, View convertView, ViewGroup parent) { + // pathological getView behavior: drop convertView on the floor to force inflation + return super.getView(position, null, parent); + } + }; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + FragmentManager fm = getSupportFragmentManager(); + if (fm.findFragmentById(android.R.id.content) == null) { + ListFragment listFragment = new ListFragment(); + listFragment.setListAdapter(createListAdapter()); + fm.beginTransaction().add(android.R.id.content, listFragment).commit(); + } + } +} diff --git a/tests/UiBench/src/com/android/test/uibench/ShadowGridActivity.java b/tests/UiBench/src/com/android/test/uibench/ShadowGridActivity.java new file mode 100644 index 000000000000..e39ec03d750f --- /dev/null +++ b/tests/UiBench/src/com/android/test/uibench/ShadowGridActivity.java @@ -0,0 +1,45 @@ +/* + * 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.test.uibench; + +import android.os.Bundle; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.ListFragment; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.ArrayAdapter; + +public class ShadowGridActivity extends AppCompatActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + FragmentManager fm = getSupportFragmentManager(); + if (fm.findFragmentById(android.R.id.content) == null) { + ListFragment listFragment = new ListFragment() { + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + getListView().setDivider(null); + } + }; + + listFragment.setListAdapter(new ArrayAdapter<>(this, + R.layout.card_row, R.id.card_text, TrivialListActivity.buildStringList())); + fm.beginTransaction().add(android.R.id.content, listFragment).commit(); + } + } +} diff --git a/tests/UiBench/src/com/android/test/uibench/TrivialListActivity.java b/tests/UiBench/src/com/android/test/uibench/TrivialListActivity.java index 0af34717f82d..9c8ae9bcceea 100644 --- a/tests/UiBench/src/com/android/test/uibench/TrivialListActivity.java +++ b/tests/UiBench/src/com/android/test/uibench/TrivialListActivity.java @@ -47,7 +47,7 @@ public class TrivialListActivity extends AppCompatActivity { FragmentManager fm = getSupportFragmentManager(); if (fm.findFragmentById(android.R.id.content) == null) { ListFragment listFragment = new ListFragment(); - listFragment.setListAdapter(new ArrayAdapter<>(TrivialListActivity.this, + listFragment.setListAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, buildStringList())); fm.beginTransaction().add(android.R.id.content, listFragment).commit(); } -- 2.11.0