aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2015-09-01 14:09:43 -0700
committerAdnan Begovic <adnan@cyngn.com>2015-09-01 14:13:03 -0700
commitc0c27a6f94d8dd4204810b06132df3771c948beb (patch)
tree27f6879f65ee951428a97c3b4366f16623649ce0 /tests
parent3a502e91b2271c71108f0c8833145373b50bcd01 (diff)
downloadvendor_cmsdk-c0c27a6f94d8dd4204810b06132df3771c948beb.zip
vendor_cmsdk-c0c27a6f94d8dd4204810b06132df3771c948beb.tar.gz
vendor_cmsdk-c0c27a6f94d8dd4204810b06132df3771c948beb.tar.bz2
cmsdk: Add preliminary hardware manager tests.
Change-Id: Ic01898fc9c1ae4d9c3b52ade8737ec6ab8388670
Diffstat (limited to 'tests')
-rw-r--r--tests/AndroidManifest.xml8
-rw-r--r--tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java4
-rw-r--r--tests/src/org/cyanogenmod/tests/hardware/CMHardwareTest.java338
-rw-r--r--tests/src/org/cyanogenmod/tests/hardware/unit/CMHardwareManagerTest.java46
-rw-r--r--tests/src/org/cyanogenmod/tests/hardware/unit/DisplayModeTest.java56
5 files changed, 450 insertions, 2 deletions
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index b999e4d..a543fd2 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -16,6 +16,7 @@
<uses-permission android:name="cyanogenmod.alarmclock.permission.READ_ALARMS" />
<uses-permission android:name="cyanogenmod.permission.MODIFY_MSIM_PHONE_STATE" />
<uses-permission android:name="cyanogenmod.permission.READ_MSIM_PHONE_STATE" />
+ <uses-permission android:name="cyanogenmod.permission.HARDWARE_ABSTRACTION_ACCESS" />
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<uses-library android:name="android.test.runner" />
@@ -61,6 +62,13 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
+ <activity android:name=".hardware.CMHardwareTest"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
<activity android:name=".customtiles.DummySettings"
android:label="@string/app_name" />
</application>
diff --git a/tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java b/tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java
index d208a1b..67e311c 100644
--- a/tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java
+++ b/tests/src/org/cyanogenmod/tests/customtiles/unit/CMStatusBarManagerTest.java
@@ -41,7 +41,7 @@ public class CMStatusBarManagerTest extends AndroidTestCase {
@SmallTest
public void testManagerServiceIsAvailable() {
- ICMStatusBarManager icmStatusBarManager = mCMStatusBarManager.getService();
- assertNotNull(icmStatusBarManager);
+ ICMStatusBarManager icmHardwareManagerService = mCMStatusBarManager.getService();
+ assertNotNull(icmHardwareManagerService);
}
}
diff --git a/tests/src/org/cyanogenmod/tests/hardware/CMHardwareTest.java b/tests/src/org/cyanogenmod/tests/hardware/CMHardwareTest.java
new file mode 100644
index 0000000..6bec010
--- /dev/null
+++ b/tests/src/org/cyanogenmod/tests/hardware/CMHardwareTest.java
@@ -0,0 +1,338 @@
+/**
+ * Copyright (c) 2015, The CyanogenMod 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 org.cyanogenmod.tests.hardware;
+
+import android.os.Bundle;
+
+import android.widget.Toast;
+
+import java.util.Arrays;
+import java.util.List;
+
+import cyanogenmod.hardware.CMHardwareManager;
+import cyanogenmod.hardware.DisplayMode;
+
+import org.cyanogenmod.tests.TestActivity;
+
+/**
+ * Created by adnan on 8/31/15.
+ */
+public class CMHardwareTest extends TestActivity {
+ private CMHardwareManager mHardwareManager;
+
+ private static final List<Integer> FEATURES = Arrays.asList(
+ CMHardwareManager.FEATURE_ADAPTIVE_BACKLIGHT,
+ CMHardwareManager.FEATURE_COLOR_ENHANCEMENT,
+ CMHardwareManager.FEATURE_DISPLAY_COLOR_CALIBRATION,
+ CMHardwareManager.FEATURE_DISPLAY_GAMMA_CALIBRATION,
+ CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY,
+ CMHardwareManager.FEATURE_KEY_DISABLE,
+ CMHardwareManager.FEATURE_LONG_TERM_ORBITS,
+ CMHardwareManager.FEATURE_SERIAL_NUMBER,
+ CMHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT,
+ CMHardwareManager.FEATURE_TAP_TO_WAKE,
+ CMHardwareManager.FEATURE_TOUCH_HOVERING,
+ CMHardwareManager.FEATURE_AUTO_CONTRAST,
+ CMHardwareManager.FEATURE_DISPLAY_MODES
+ );
+
+ private static final List<Integer> BOOLEAN_FEATURES = Arrays.asList(
+ CMHardwareManager.FEATURE_ADAPTIVE_BACKLIGHT,
+ CMHardwareManager.FEATURE_COLOR_ENHANCEMENT,
+ CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY,
+ CMHardwareManager.FEATURE_KEY_DISABLE,
+ CMHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT,
+ CMHardwareManager.FEATURE_TAP_TO_WAKE,
+ CMHardwareManager.FEATURE_TOUCH_HOVERING,
+ CMHardwareManager.FEATURE_AUTO_CONTRAST
+ );
+
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ mHardwareManager = CMHardwareManager.getInstance(this);
+ }
+
+ @Override
+ protected String tag() {
+ return null;
+ }
+
+ @Override
+ protected Test[] tests() {
+ return mTests;
+ }
+
+ private boolean vibratorSupported() {
+ if (mHardwareManager.isSupported(CMHardwareManager.FEATURE_VIBRATOR)) {
+ return true;
+ } else {
+ Toast.makeText(CMHardwareTest.this, "Vibrator not supported",
+ Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ }
+
+ private boolean displayColorCalibrationSupported() {
+ if (mHardwareManager.isSupported(CMHardwareManager.FEATURE_DISPLAY_COLOR_CALIBRATION)) {
+ return true;
+ } else {
+ Toast.makeText(CMHardwareTest.this, "Display Color Calibration not supported",
+ Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ }
+
+ private boolean ltoSupported() {
+ if (mHardwareManager.isSupported(CMHardwareManager.FEATURE_LONG_TERM_ORBITS)) {
+ return true;
+ } else {
+ Toast.makeText(CMHardwareTest.this, "Long Term Orbits not supported",
+ Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ }
+
+ private boolean serialSupported() {
+ if (mHardwareManager.isSupported(CMHardwareManager.FEATURE_SERIAL_NUMBER)) {
+ return true;
+ } else {
+ Toast.makeText(CMHardwareTest.this, "Serial number not supported",
+ Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ }
+
+ private boolean displayModesSupported() {
+ if (mHardwareManager.isSupported(CMHardwareManager.FEATURE_DISPLAY_MODES)) {
+ return true;
+ } else {
+ Toast.makeText(CMHardwareTest.this, "Serial number not supported",
+ Toast.LENGTH_SHORT).show();
+ return false;
+ }
+ }
+
+ private Test[] mTests = new Test[] {
+ new Test("Test get supported features") {
+ public void run() {
+ Toast.makeText(CMHardwareTest.this, "Supported features " +
+ mHardwareManager.getSupportedFeatures(),
+ Toast.LENGTH_SHORT).show();
+ }
+ },
+ new Test("Test features supported") {
+ @Override
+ protected void run() {
+ StringBuilder builder = new StringBuilder();
+ for (int feature : FEATURES) {
+ builder.append("Feature " + feature + "\n")
+ .append("is supported " + mHardwareManager.isSupported(feature)
+ + "\n");
+ }
+ Toast.makeText(CMHardwareTest.this, "Supported features " +
+ builder.toString(),
+ Toast.LENGTH_SHORT).show();
+ }
+ },
+ new Test("Test boolean features enabled") {
+ @Override
+ protected void run() {
+ StringBuilder builder = new StringBuilder();
+ for (int feature : BOOLEAN_FEATURES) {
+ builder.append("Feature " + feature + "\n")
+ .append("is enabled " + mHardwareManager.isSupported(feature)
+ + "\n");
+ }
+ Toast.makeText(CMHardwareTest.this, "Features " +
+ builder.toString(),
+ Toast.LENGTH_SHORT).show();
+ }
+ },
+ new Test("Test get vibrator intensity") {
+ @Override
+ protected void run() {
+ if (vibratorSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Vibrator intensity " +
+ mHardwareManager.getVibratorIntensity(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test get vibrator default intensity") {
+ @Override
+ protected void run() {
+ if (vibratorSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Vibrator default intensity " +
+ mHardwareManager.getVibratorDefaultIntensity(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test get vibrator max intensity") {
+ @Override
+ protected void run() {
+ if (vibratorSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Vibrator max intensity " +
+ mHardwareManager.getVibratorMaxIntensity(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test get vibrator min intensity") {
+ @Override
+ protected void run() {
+ if (vibratorSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Vibrator min intensity " +
+ mHardwareManager.getVibratorMinIntensity(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test get vibrator min intensity") {
+ @Override
+ protected void run() {
+ if (vibratorSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Vibrator min intensity " +
+ mHardwareManager.getVibratorWarningIntensity(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Display Color Calibration") {
+ @Override
+ protected void run() {
+ if (displayColorCalibrationSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Display Color Calibration " +
+ mHardwareManager.getDisplayColorCalibration(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Default Display Color Calibration") {
+ @Override
+ protected void run() {
+ if (displayColorCalibrationSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Default Display Color Calibration " +
+ mHardwareManager.getDisplayColorCalibrationDefault(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Display Color Calibration Max") {
+ @Override
+ protected void run() {
+ if (displayColorCalibrationSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Display Color Calibration Max " +
+ mHardwareManager.getDisplayColorCalibrationMax(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Display Color Calibration Min") {
+ @Override
+ protected void run() {
+ if (displayColorCalibrationSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Display Color Calibration Min " +
+ mHardwareManager.getDisplayColorCalibrationMin(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Set Display Color Calibration") {
+ @Override
+ protected void run() {
+ if (displayColorCalibrationSupported()) {
+ mHardwareManager.setDisplayColorCalibration(new int[] {0,0,0});
+ }
+ }
+ },
+ new Test("Test Get Long Term Orbits Source") {
+ @Override
+ protected void run() {
+ if (ltoSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Long Term Orbit Source " +
+ mHardwareManager.getLtoSource(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Get Long Term Orbits Destination") {
+ @Override
+ protected void run() {
+ if (ltoSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Long Term Orbit Destination " +
+ mHardwareManager.getLtoDestination(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Get Long Term Orbits Interval") {
+ @Override
+ protected void run() {
+ if (ltoSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Long Term Orbit Download Interval " +
+ mHardwareManager.getLtoDownloadInterval(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Get Serial Number") {
+ @Override
+ protected void run() {
+ if (serialSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Serial number " +
+ mHardwareManager.getSerialNumber(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Get Display Modes") {
+ @Override
+ protected void run() {
+ if (displayModesSupported()) {
+ StringBuilder builder = new StringBuilder();
+ for (DisplayMode displayMode : mHardwareManager.getDisplayModes()) {
+ builder.append("Display mode " + displayMode.name + "\n");
+ }
+ Toast.makeText(CMHardwareTest.this, "Display modes: \n"
+ + builder.toString(), Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Get Current Display Mode") {
+ @Override
+ protected void run() {
+ if (displayModesSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Default Display Mode " +
+ mHardwareManager.getCurrentDisplayMode(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ new Test("Test Get Default Display Mode") {
+ @Override
+ protected void run() {
+ if (displayModesSupported()) {
+ Toast.makeText(CMHardwareTest.this, "Default Display Mode " +
+ mHardwareManager.getCurrentDisplayMode(),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ },
+ };
+}
diff --git a/tests/src/org/cyanogenmod/tests/hardware/unit/CMHardwareManagerTest.java b/tests/src/org/cyanogenmod/tests/hardware/unit/CMHardwareManagerTest.java
new file mode 100644
index 0000000..8e2af14
--- /dev/null
+++ b/tests/src/org/cyanogenmod/tests/hardware/unit/CMHardwareManagerTest.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2015, The CyanogenMod 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 org.cyanogenmod.tests.hardware.unit;
+
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import cyanogenmod.hardware.CMHardwareManager;
+import cyanogenmod.hardware.ICMHardwareService;
+
+/**
+ * Created by adnan on 9/1/15.
+ */
+public class CMHardwareManagerTest extends AndroidTestCase {
+ private CMHardwareManager mCMHardwareManager;
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mCMHardwareManager = CMHardwareManager.getInstance(mContext);
+ }
+
+ @SmallTest
+ public void testManagerExists() {
+ assertNotNull(mCMHardwareManager);
+ }
+
+ @SmallTest
+ public void testManagerServiceIsAvailable() {
+ ICMHardwareService icmStatusBarManager = mCMHardwareManager.getService();
+ assertNotNull(icmStatusBarManager);
+ }
+}
diff --git a/tests/src/org/cyanogenmod/tests/hardware/unit/DisplayModeTest.java b/tests/src/org/cyanogenmod/tests/hardware/unit/DisplayModeTest.java
new file mode 100644
index 0000000..a642b2c
--- /dev/null
+++ b/tests/src/org/cyanogenmod/tests/hardware/unit/DisplayModeTest.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2015, The CyanogenMod 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 org.cyanogenmod.tests.hardware.unit;
+
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+
+import android.test.suitebuilder.annotation.SmallTest;
+import cyanogenmod.hardware.DisplayMode;
+
+/**
+ * Created by adnan on 9/1/15.
+ */
+public class DisplayModeTest extends AndroidTestCase {
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @SmallTest
+ public void testDisplayModeUnravelFromParcel() {
+ int expectedId = 1337;
+ String expectedName = "test";
+ DisplayMode expectedDisplayMode = new DisplayMode(expectedId, expectedName);
+ // Write to parcel
+ Parcel parcel = Parcel.obtain();
+ expectedDisplayMode.writeToParcel(parcel, 0);
+
+ // Rewind
+ parcel.setDataPosition(0);
+
+ // Verify data when unraveling
+ DisplayMode fromParcel = DisplayMode.CREATOR.createFromParcel(parcel);
+
+ assertNotNull(expectedDisplayMode.id);
+ assertNotNull(expectedDisplayMode.name);
+
+ assertEquals(expectedDisplayMode.id, fromParcel.id );
+ assertEquals(expectedDisplayMode.name,
+ fromParcel.name);
+ }
+}