Hardware Acceleration Test
Bug 4186680
Tests the View#isHardwareAccelerated and Canvas#isHardwareAccelerated
methods. Since this required the addition of android:hardwareAccelerated
to the application, I decided to make a separate stub to avoid affecting
existing tests.
Change-Id: Ia56d7f98ded41d64885c36b9d5131045bb2c8e61
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index 7c0cd5e..a7eb516 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -26,6 +26,8 @@
# These test cases will be analyzed by the CTS API coverage tools.
CTS_COVERAGE_TEST_CASE_LIST := \
+ CtsAccelerationTestCases \
+ CtsAccelerationTestStubs \
CtsAccessibilityServiceTestCases \
CtsAccountManagerTestCases \
CtsAdminTestCases \
diff --git a/development/ide/eclipse/.classpath b/development/ide/eclipse/.classpath
index d700593..af2ce98 100644
--- a/development/ide/eclipse/.classpath
+++ b/development/ide/eclipse/.classpath
@@ -9,12 +9,14 @@
<classpathentry kind="src" path="cts/tests/ProcessTest/ShareUidApp/src"/>
<classpathentry kind="src" path="cts/tests/SignatureTest/src"/>
<classpathentry kind="src" path="cts/tests/SignatureTest/tests/src"/>
+ <classpathentry kind="src" path="cts/tests/acceleration/src"/>
<classpathentry kind="src" path="cts/tests/accessibilityservice/src"/>
<classpathentry kind="src" path="cts/tests/appsecurity-tests/src"/>
<classpathentry kind="src" path="cts/tests/appsecurity-tests/test-apps/AppWithData/src"/>
<classpathentry kind="src" path="cts/tests/core/runner/src"/>
<classpathentry kind="src" path="cts/tests/deviceadmin/src"/>
<classpathentry kind="src" path="cts/tests/src"/>
+ <classpathentry kind="src" path="cts/tests/tests/acceleration/src"/>
<classpathentry kind="src" path="cts/tests/tests/accessibilityservice/src"/>
<classpathentry kind="src" path="cts/tests/tests/accounts/src"/>
<classpathentry kind="src" path="cts/tests/tests/admin/src"/>
diff --git a/tests/acceleration/Android.mk b/tests/acceleration/Android.mk
new file mode 100644
index 0000000..6e30f59
--- /dev/null
+++ b/tests/acceleration/Android.mk
@@ -0,0 +1,31 @@
+# Copyright (C) 2011 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)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsAccelerationTestStubs
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/acceleration/AndroidManifest.xml b/tests/acceleration/AndroidManifest.xml
new file mode 100644
index 0000000..0c51d49
--- /dev/null
+++ b/tests/acceleration/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<!--
+ * Copyright (C) 2011 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.cts.acceleration.stub">
+
+ <application android:hardwareAccelerated="true" android:debuggable="true">
+ <activity android:name="android.acceleration.cts.HardwareAcceleratedActivity" />
+ <activity android:name="android.acceleration.cts.SoftwareAcceleratedActivity"
+ android:hardwareAccelerated="false" />
+ <activity android:name="android.acceleration.cts.WindowFlagHardwareAcceleratedActivity"
+ android:hardwareAccelerated="false" />
+ </application>
+
+</manifest>
+
diff --git a/tests/acceleration/res/layout/acceleration.xml b/tests/acceleration/res/layout/acceleration.xml
new file mode 100644
index 0000000..8dc027a
--- /dev/null
+++ b/tests/acceleration/res/layout/acceleration.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ >
+ <android.acceleration.cts.AcceleratedView android:id="@+id/hardware_accelerated_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layerType="hardware"
+ />
+ <android.acceleration.cts.AcceleratedView android:id="@+id/software_accelerated_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layerType="software"
+ />
+ <!-- Acceleration will be set via manual setLayerType calls from the activity. -->
+ <android.acceleration.cts.AcceleratedView android:id="@+id/manual_hardware_accelerated_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ />
+ <android.acceleration.cts.AcceleratedView android:id="@+id/manual_software_accelerated_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ />
+</LinearLayout>
diff --git a/tests/acceleration/src/android/acceleration/cts/AcceleratedView.java b/tests/acceleration/src/android/acceleration/cts/AcceleratedView.java
new file mode 100644
index 0000000..7d749a1
--- /dev/null
+++ b/tests/acceleration/src/android/acceleration/cts/AcceleratedView.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 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.acceleration.cts;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.util.AttributeSet;
+import android.view.View;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class AcceleratedView extends View {
+
+ private final CountDownLatch mDrawLatch = new CountDownLatch(1);
+
+ private boolean mIsHardwareAccelerated;
+
+ public AcceleratedView(Context context) {
+ super(context);
+ }
+
+ public AcceleratedView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public AcceleratedView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ synchronized (this) {
+ mIsHardwareAccelerated = canvas.isHardwareAccelerated();
+ }
+ mDrawLatch.countDown();
+ }
+
+ public boolean isCanvasHardwareAccelerated() {
+ try {
+ if (mDrawLatch.await(1, TimeUnit.SECONDS)) {
+ synchronized (this) {
+ return mIsHardwareAccelerated;
+ }
+ } else {
+ throw new IllegalStateException("View was not drawn...");
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/tests/acceleration/src/android/acceleration/cts/BaseAcceleratedActivity.java b/tests/acceleration/src/android/acceleration/cts/BaseAcceleratedActivity.java
new file mode 100644
index 0000000..8ef6a8e
--- /dev/null
+++ b/tests/acceleration/src/android/acceleration/cts/BaseAcceleratedActivity.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2011 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.acceleration.cts;
+
+import com.android.cts.acceleration.stub.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+
+abstract class BaseAcceleratedActivity extends Activity {
+
+ private AcceleratedView mHardwareAcceleratedView;
+ private AcceleratedView mSoftwareAcceleratedView;
+
+ private AcceleratedView mManualHardwareAcceleratedView;
+ private AcceleratedView mManualSoftwareAcceleratedView;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.acceleration);
+
+ mHardwareAcceleratedView = (AcceleratedView) findViewById(R.id.hardware_accelerated_view);
+ mSoftwareAcceleratedView = (AcceleratedView) findViewById(R.id.software_accelerated_view);
+
+ mManualHardwareAcceleratedView =
+ (AcceleratedView) findViewById(R.id.manual_hardware_accelerated_view);
+ mManualSoftwareAcceleratedView =
+ (AcceleratedView) findViewById(R.id.manual_software_accelerated_view);
+
+ mManualHardwareAcceleratedView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ mManualSoftwareAcceleratedView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ }
+
+ public AcceleratedView getHardwareAcceleratedView() {
+ return mHardwareAcceleratedView;
+ }
+
+ public AcceleratedView getSoftwareAcceleratedView() {
+ return mSoftwareAcceleratedView;
+ }
+
+ public AcceleratedView getManualHardwareAcceleratedView() {
+ return mManualHardwareAcceleratedView;
+ }
+
+ public AcceleratedView getManualSoftwareAcceleratedView() {
+ return mManualSoftwareAcceleratedView;
+ }
+}
diff --git a/tests/acceleration/src/android/acceleration/cts/HardwareAcceleratedActivity.java b/tests/acceleration/src/android/acceleration/cts/HardwareAcceleratedActivity.java
new file mode 100644
index 0000000..bb26202
--- /dev/null
+++ b/tests/acceleration/src/android/acceleration/cts/HardwareAcceleratedActivity.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2011 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.acceleration.cts;
+
+public class HardwareAcceleratedActivity extends BaseAcceleratedActivity {
+}
diff --git a/tests/acceleration/src/android/acceleration/cts/SoftwareAcceleratedActivity.java b/tests/acceleration/src/android/acceleration/cts/SoftwareAcceleratedActivity.java
new file mode 100644
index 0000000..0a6a3df
--- /dev/null
+++ b/tests/acceleration/src/android/acceleration/cts/SoftwareAcceleratedActivity.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2011 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.acceleration.cts;
+
+public class SoftwareAcceleratedActivity extends BaseAcceleratedActivity {
+}
diff --git a/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAcceleratedActivity.java b/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAcceleratedActivity.java
new file mode 100644
index 0000000..9def8b7
--- /dev/null
+++ b/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAcceleratedActivity.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 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.acceleration.cts;
+
+import android.os.Bundle;
+import android.view.WindowManager;
+
+public class WindowFlagHardwareAcceleratedActivity extends BaseAcceleratedActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
+ WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
+ }
+}
diff --git a/tests/tests/acceleration/Android.mk b/tests/tests/acceleration/Android.mk
new file mode 100644
index 0000000..3e2acac
--- /dev/null
+++ b/tests/tests/acceleration/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2011 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)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
+
+LOCAL_INSTRUMENTATION_FOR := CtsAccelerationTestStubs
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/acceleration/AndroidManifest.xml b/tests/tests/acceleration/AndroidManifest.xml
new file mode 100644
index 0000000..8a2f955
--- /dev/null
+++ b/tests/tests/acceleration/AndroidManifest.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ * Copyright (C) 2011 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.cts.acceleration">
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.android.cts.acceleration.stub"
+ android:label="Tests for the Hardware Acceleration APIs." />
+
+</manifest>
diff --git a/tests/tests/acceleration/src/android/acceleration/cts/BaseAccelerationTest.java b/tests/tests/acceleration/src/android/acceleration/cts/BaseAccelerationTest.java
new file mode 100644
index 0000000..d2f1d9f
--- /dev/null
+++ b/tests/tests/acceleration/src/android/acceleration/cts/BaseAccelerationTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2011 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.acceleration.cts;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.pm.ConfigurationInfo;
+import android.content.pm.FeatureInfo;
+import android.test.ActivityInstrumentationTestCase2;
+import android.view.View;
+
+abstract class BaseAccelerationTest<B extends BaseAcceleratedActivity>
+ extends ActivityInstrumentationTestCase2<B> {
+
+ protected B mActivity;
+
+ /** View with android:layerType="hardware" set */
+ protected AcceleratedView mHardwareView;
+
+ /** View with android:layerType="software" set */
+ protected AcceleratedView mSoftwareView;
+
+ /** View with setLayerType(HARDWARE) called */
+ protected AcceleratedView mManualHardwareView;
+
+ /** View with setLayerType(SOFTWARE) called */
+ protected AcceleratedView mManualSoftwareView;
+
+ BaseAccelerationTest(Class<B> clazz) {
+ super(clazz);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mActivity = getActivity();
+ mHardwareView = mActivity.getHardwareAcceleratedView();
+ mSoftwareView = mActivity.getSoftwareAcceleratedView();
+ mManualHardwareView = mActivity.getManualHardwareAcceleratedView();
+ mManualSoftwareView = mActivity.getManualSoftwareAcceleratedView();
+ }
+
+ public void testNotAttachedView() {
+ // Views that are not attached can't be attached to an accelerated window.
+ View view = new View(mActivity);
+ assertFalse(view.isHardwareAccelerated());
+ }
+
+ protected static int getGlEsVersion(Context context) {
+ ActivityManager activityManager =
+ (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ ConfigurationInfo configInfo = activityManager.getDeviceConfigurationInfo();
+ if (configInfo.reqGlEsVersion != ConfigurationInfo.GL_ES_VERSION_UNDEFINED) {
+ return getMajorVersion(configInfo.reqGlEsVersion);
+ } else {
+ return 1; // Lack of property means OpenGL ES version 1
+ }
+ }
+
+ /** @see FeatureInfo#getGlEsVersion() */
+ private static int getMajorVersion(int glEsVersion) {
+ return ((glEsVersion & 0xffff0000) >> 16);
+ }
+}
diff --git a/tests/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java b/tests/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
new file mode 100644
index 0000000..eddd34f
--- /dev/null
+++ b/tests/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 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.acceleration.cts;
+
+/**
+ * Test that uses an Activity with hardware acceleration enabled.
+ */
+public class HardwareAccelerationTest
+ extends BaseAccelerationTest<HardwareAcceleratedActivity> {
+
+ public HardwareAccelerationTest() {
+ super(HardwareAcceleratedActivity.class);
+ }
+
+ public void testIsHardwareAccelerated() {
+ // Hardware acceleration should be available on devices with GL ES 2 or higher...
+ if (getGlEsVersion(mActivity) >= 2) {
+ // Both of the views are attached to a hardware accelerated window
+ assertTrue(mHardwareView.isHardwareAccelerated());
+ assertTrue(mSoftwareView.isHardwareAccelerated());
+ assertTrue(mManualHardwareView.isHardwareAccelerated());
+ assertTrue(mManualSoftwareView.isHardwareAccelerated());
+
+ assertTrue(mHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mSoftwareView.isCanvasHardwareAccelerated());
+ assertTrue(mManualHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mManualSoftwareView.isCanvasHardwareAccelerated());
+ } else {
+ assertFalse(mHardwareView.isHardwareAccelerated());
+ assertFalse(mSoftwareView.isHardwareAccelerated());
+ assertFalse(mManualHardwareView.isHardwareAccelerated());
+ assertFalse(mManualSoftwareView.isHardwareAccelerated());
+
+ assertFalse(mHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mSoftwareView.isCanvasHardwareAccelerated());
+ assertFalse(mManualHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mManualSoftwareView.isCanvasHardwareAccelerated());
+ }
+ }
+}
diff --git a/tests/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java b/tests/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
new file mode 100644
index 0000000..146fa6a
--- /dev/null
+++ b/tests/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 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.acceleration.cts;
+
+/**
+ * Test that uses an Activity with hardware acceleration explicitly disabled
+ * and makes sure that all views are rendered using software acceleration.
+ */
+public class SoftwareAccelerationTest
+ extends BaseAccelerationTest<SoftwareAcceleratedActivity> {
+
+ public SoftwareAccelerationTest() {
+ super(SoftwareAcceleratedActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mActivity = getActivity();
+ }
+
+ public void testIsHardwareAccelerated() {
+ // Both of the views are not attached to a hardware accelerated window
+ assertFalse(mHardwareView.isHardwareAccelerated());
+ assertFalse(mSoftwareView.isHardwareAccelerated());
+ assertFalse(mManualHardwareView.isHardwareAccelerated());
+ assertFalse(mManualSoftwareView.isHardwareAccelerated());
+
+ assertFalse(mHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mSoftwareView.isCanvasHardwareAccelerated());
+ assertFalse(mManualHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mManualSoftwareView.isCanvasHardwareAccelerated());
+ }
+}
diff --git a/tests/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java b/tests/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
new file mode 100644
index 0000000..bfbbe63
--- /dev/null
+++ b/tests/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 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.acceleration.cts;
+
+/**
+ * Test that uses an Activity with hardware acceleration enabled.
+ */
+public class WindowFlagHardwareAccelerationTest
+ extends BaseAccelerationTest<WindowFlagHardwareAcceleratedActivity> {
+
+ public WindowFlagHardwareAccelerationTest() {
+ super(WindowFlagHardwareAcceleratedActivity.class);
+ }
+
+ public void testIsHardwareAccelerated() {
+ // Hardware acceleration should be available on devices with GL ES 2 or higher...
+ if (getGlEsVersion(mActivity) >= 2) {
+ // Both of the views are attached to a hardware accelerated window
+ assertTrue(mHardwareView.isHardwareAccelerated());
+ assertTrue(mSoftwareView.isHardwareAccelerated());
+ assertTrue(mManualHardwareView.isHardwareAccelerated());
+ assertTrue(mManualSoftwareView.isHardwareAccelerated());
+
+ assertTrue(mHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mSoftwareView.isCanvasHardwareAccelerated());
+ assertTrue(mManualHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mManualSoftwareView.isCanvasHardwareAccelerated());
+ } else {
+ assertFalse(mHardwareView.isHardwareAccelerated());
+ assertFalse(mSoftwareView.isHardwareAccelerated());
+ assertFalse(mManualHardwareView.isHardwareAccelerated());
+ assertFalse(mManualSoftwareView.isHardwareAccelerated());
+
+ assertFalse(mHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mSoftwareView.isCanvasHardwareAccelerated());
+ assertFalse(mManualHardwareView.isCanvasHardwareAccelerated());
+ assertFalse(mManualSoftwareView.isCanvasHardwareAccelerated());
+ }
+ }
+}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsSetup.java b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsSetup.java
index 7d952a3..9ae2197 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsSetup.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/targetprep/CtsSetup.java
@@ -37,6 +37,7 @@
private static final String RUNNER_APK_NAME = "android.core.tests.runner.apk";
// TODO: read this from configuration file rather than hardcoding
private static final String TEST_STUBS_APK = "CtsTestStubs.apk";
+ private static final String ACCELERATION_TEST_STUBS_APK = "CtsAccelerationTestStubs.apk";
/**
* Factory method to create a {@link CtsBuildHelper}.
@@ -93,6 +94,7 @@
private void installCtsPrereqs(ITestDevice device, CtsBuildHelper ctsBuild)
throws DeviceNotAvailableException, TargetSetupError, FileNotFoundException {
installApk(device, ctsBuild.getTestApp(TEST_STUBS_APK));
+ installApk(device, ctsBuild.getTestApp(ACCELERATION_TEST_STUBS_APK));
installApk(device, ctsBuild.getTestApp(RUNNER_APK_NAME));
}
}