Merge "Revert "Revert "Delete CtsUiDeviceTestCases"""
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index e2c1901..247e4ea 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -18,6 +18,7 @@
tests/tests/hardware/
tests/tests/print/
tests/tests/text/
+ tests/tests/theme/
tests/tests/transition/
tests/tests/uirendering/
tests/tests/view/
diff --git a/tests/jank/AndroidTest.xml b/tests/jank/AndroidTest.xml
index 9c409a5..1b4fd1f 100644
--- a/tests/jank/AndroidTest.xml
+++ b/tests/jank/AndroidTest.xml
@@ -19,7 +19,6 @@
<option name="config-descriptor:metadata" key="component" value="graphics" />
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="cleanup-apks" value="true" />
- <option name="test-file-name" value="CtsUiDeviceTestCases.apk" />
<option name="test-file-name" value="CtsJankDeviceTestCases.apk" />
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
diff --git a/tests/ui/src/android/ui/cts/WatchPercentageScreenDimenTest.java b/tests/tests/theme/src/android/theme/cts/WatchPercentageScreenDimenTest.java
similarity index 78%
rename from tests/ui/src/android/ui/cts/WatchPercentageScreenDimenTest.java
rename to tests/tests/theme/src/android/theme/cts/WatchPercentageScreenDimenTest.java
index c550f82..9bfd2d5 100644
--- a/tests/ui/src/android/ui/cts/WatchPercentageScreenDimenTest.java
+++ b/tests/tests/theme/src/android/theme/cts/WatchPercentageScreenDimenTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2019 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.
@@ -13,17 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package android.ui.cts;
+package android.theme.cts;
+
+import static org.junit.Assert.assertEquals;
import android.content.Context;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.content.res.TypedArray;
import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.SmallTest;
import android.util.DisplayMetrics;
-import junit.framework.Assert;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -60,13 +61,13 @@
float expectedDelta = getMaxErrorRatio() * expected;
TypedArray attrs = mContext.obtainStyledAttributes(new int[] {
- android.R.attr.listPreferredItemPaddingEnd
+ android.R.attr.listPreferredItemPaddingEnd
});
- Assert.assertEquals("invalid number of attributes", 1, attrs.length());
+ assertEquals("invalid number of attributes", 1, attrs.length());
for (int i = 0; i < attrs.length(); ++i) {
float actual = attrs.getDimension(i, -1);
- Assert.assertEquals("screen_percentage_10 is not 10% of screen width",
+ assertEquals("screen_percentage_10 is not 10% of screen width",
expected, actual, expectedDelta + 0.01f);
}
}
@@ -81,16 +82,16 @@
float expectedDelta = getMaxErrorRatio() * expected;
TypedArray attrs = mContext.obtainStyledAttributes(new int[] {
- android.R.attr.dialogPreferredPadding,
- android.R.attr.listPreferredItemPaddingLeft,
- android.R.attr.listPreferredItemPaddingRight,
- android.R.attr.listPreferredItemPaddingStart
+ android.R.attr.dialogPreferredPadding,
+ android.R.attr.listPreferredItemPaddingLeft,
+ android.R.attr.listPreferredItemPaddingRight,
+ android.R.attr.listPreferredItemPaddingStart
});
- Assert.assertEquals("invalid number of attributes", 4, attrs.length());
+ assertEquals("invalid number of attributes", 4, attrs.length());
for (int i = 0; i < attrs.length(); ++i) {
float actual = attrs.getDimension(i, -1);
- Assert.assertEquals("screen_percentage_15 is not 15% of screen width",
+ assertEquals("screen_percentage_15 is not 15% of screen width",
expected, actual, expectedDelta + 0.01f);
}
}
diff --git a/tests/ui/Android.mk b/tests/ui/Android.mk
deleted file mode 100644
index 2ff427d..0000000
--- a/tests/ui/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2012 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-# don't include this package in any target
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
-
-LOCAL_JAVA_LIBRARIES := android.test.runner.stubs android.test.base.stubs
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := CtsUiDeviceTestCases
-
-# Tag this module as a cts test artifact
-LOCAL_COMPATIBILITY_SUITE := cts vts general-tests cts_instant
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_CTS_PACKAGE)
-
-
diff --git a/tests/ui/AndroidManifest.xml b/tests/ui/AndroidManifest.xml
deleted file mode 100644
index 56826f9..0000000
--- a/tests/ui/AndroidManifest.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2012 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="android.ui.cts"
- android:targetSandboxVersion="2">
-
- <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-
- <application>
- <uses-library android:name="android.test.runner" />
-
- <activity
- android:name=".ScrollingActivity"
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
- <instrumentation
- android:name="android.support.test.runner.AndroidJUnitRunner"
- android:label="UI Latency measurement"
- android:targetPackage="android.ui.cts" >
- <meta-data
- android:name="listener"
- android:value="com.android.cts.runner.CtsTestRunListener" />
- </instrumentation>
-
-</manifest>
diff --git a/tests/ui/AndroidTest.xml b/tests/ui/AndroidTest.xml
deleted file mode 100644
index 9e51fba..0000000
--- a/tests/ui/AndroidTest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?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.
--->
-<configuration description="Config for CTS UI test cases">
- <option name="test-suite-tag" value="cts" />
- <option name="config-descriptor:metadata" key="component" value="uitoolkit" />
- <option name="config-descriptor:metadata" key="parameter" value="instant_app" />
- <option name="not-shardable" value="true" />
- <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
- <option name="cleanup-apks" value="true" />
- <option name="test-file-name" value="CtsUiDeviceTestCases.apk" />
- </target_preparer>
- <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
- <option name="package" value="android.ui.cts" />
- <option name="runtime-hint" value="12m" />
- <!-- test-timeout unit is ms, value = 30 min -->
- <option name="test-timeout" value="1800000" />
- </test>
-</configuration>
diff --git a/tests/ui/src/android/ui/cts/ScrollingActivity.java b/tests/ui/src/android/ui/cts/ScrollingActivity.java
deleted file mode 100644
index d5fc4b0..0000000
--- a/tests/ui/src/android/ui/cts/ScrollingActivity.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2012 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 android.ui.cts;
-
-import android.app.ListActivity;
-import android.os.Bundle;
-import android.widget.AbsListView;
-import android.widget.AbsListView.OnScrollListener;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Activity for measuring scrolling time of long list.
- */
-public class ScrollingActivity extends ListActivity implements OnScrollListener {
- static final String TAG = "ScrollingActivity";
- private static final String NUM_ELEMENTS_EXTRA = "num_elements";
- private static final int NUM_ELEMENTS_DEFAULT = 10000;
- private static final int SCROLL_TIME_IN_MS = 1;
- private static final int WAIT_TIMEOUT_IN_SECS = 5 * 60;
- private String[] mItems;
- private CountDownLatch mLatchStop = null;
- private int mTargetLoc;
- private int mNumElements;
-
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- mNumElements = getIntent().getIntExtra(NUM_ELEMENTS_EXTRA, NUM_ELEMENTS_DEFAULT);
- mItems = new String[mNumElements];
- for (int i = 0; i < mNumElements; i++) {
- mItems[i] = Integer.toString(i);
- }
- setListAdapter(new ArrayAdapter<String>(this,
- android.R.layout.simple_list_item_1, mItems));
- ListView view = getListView();
- view.setOnScrollListener(this);
- }
-
- public boolean scrollToTop() {
- return doScroll(0);
- }
- public boolean scrollToBottom() {
- return doScroll(mNumElements - 1);
- }
-
- private boolean doScroll(final int loc) {
- mLatchStop = new CountDownLatch(1);
- mTargetLoc = loc;
- final ListView view = getListView();
- runOnUiThread( new Runnable() {
- @Override
- public void run() {
- view.smoothScrollToPositionFromTop(loc, 0, SCROLL_TIME_IN_MS);
- }
- });
- boolean result = false;
- try {
- result = mLatchStop.await(WAIT_TIMEOUT_IN_SECS, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- // ignore
- }
- mLatchStop = null;
- return result;
- }
-
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {
-
- }
-
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem,
- int visibleItemCount, int totalItemCount) {
- //Log.i(TAG, "onScroll " + firstVisibleItem + " " + visibleItemCount);
- if ((mTargetLoc >= firstVisibleItem) &&
- (mTargetLoc <= (firstVisibleItem + visibleItemCount))) {
- if (mLatchStop != null) {
- mLatchStop.countDown();
- }
- }
- }
-}
diff --git a/tests/ui/src/android/ui/cts/ScrollingTest.java b/tests/ui/src/android/ui/cts/ScrollingTest.java
deleted file mode 100644
index 6546b98..0000000
--- a/tests/ui/src/android/ui/cts/ScrollingTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2012 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 android.ui.cts;
-
-import android.test.ActivityInstrumentationTestCase2;
-
-import com.android.compatibility.common.util.DeviceReportLog;
-import com.android.compatibility.common.util.MeasureRun;
-import com.android.compatibility.common.util.MeasureTime;
-import com.android.compatibility.common.util.ResultType;
-import com.android.compatibility.common.util.ResultUnit;
-import com.android.compatibility.common.util.Stat;
-
-import java.io.IOException;
-
-public class ScrollingTest extends ActivityInstrumentationTestCase2<ScrollingActivity> {
-
- private static final String REPORT_LOG_NAME = "CtsUiDeviceTestCases";
-
- private ScrollingActivity mActivity;
-
- public ScrollingTest() {
- super(ScrollingActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mActivity = getActivity();
- getInstrumentation().waitForIdleSync();
- try {
- runTestOnUiThread(new Runnable() {
- @Override
- public void run() {
- }
- });
- } catch (Throwable e) {
- e.printStackTrace();
- fail();
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- mActivity = null;
- super.tearDown();
- }
-
- public void testFullScrolling() throws Exception {
- final int NUMBER_REPEAT = 10;
- final ScrollingActivity activity = mActivity;
- double[] results = MeasureTime.measure(NUMBER_REPEAT, new MeasureRun() {
-
- @Override
- public void run(int i) throws IOException {
- assertTrue(activity.scrollToBottom());
- assertTrue(activity.scrollToTop());
- }
- });
- String streamName = "test_full_scrolling";
- DeviceReportLog report = new DeviceReportLog(REPORT_LOG_NAME, streamName);
- report.addValues("scrolling_time", results, ResultType.LOWER_BETTER,ResultUnit.MS);
- Stat.StatResult stat = Stat.getStat(results);
- report.setSummary("scrolling_time_average", stat.mAverage,
- ResultType.LOWER_BETTER,ResultUnit.MS);
- report.submit(getInstrumentation());
- }
-}