diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 7a0b6002..00000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# 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.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- org.lineageos.platform.internal \
- android-support-test \
- mockito-target
-
-LOCAL_DEX_PREOPT := false
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files, src/)
-
-LOCAL_PACKAGE_NAME := LineagePlatformTests
-LOCAL_CERTIFICATE := platform
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_PROGUARD_ENABLED := optimization
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-LOCAL_PRIVATE_PLATFORM_APIS := true
-
-include $(BUILD_PACKAGE)
-
-# Register as LineageTS
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- org.lineageos.platform.internal \
- android-support-test \
- mockito-target
-
-LOCAL_DEX_PREOPT := false
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files, src/)
-
-LOCAL_PACKAGE_NAME := CmtsPlatformSDKTests
-LOCAL_CERTIFICATE := platform
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_PROGUARD_ENABLED := optimization
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-include $(BUILD_LineageTS_PACKAGE)
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
deleted file mode 100644
index 614d2946..00000000
--- a/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/README.md b/tests/README.md
deleted file mode 100644
index 6e077dde..00000000
--- a/tests/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-## Lineage Platform SDK Tests
-The tests package contains both functional manual tests as well as unit
-tests which can be ran utilizing the InstrumentationTestRunner from android.
-
-To run the tests (on a live device):
-
- ```adb shell am instrument -w org.lineageos.tests/androidx.test.runner.AndroidJUnitRunner```
diff --git a/tests/proguard.flags b/tests/proguard.flags
deleted file mode 100644
index 86ec0505..00000000
--- a/tests/proguard.flags
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (C) 2016 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.
-
-# Don't skip non public library classes, make sure we're not keeping anything which will get mapped against api verification.
--dontskipnonpubliclibraryclasses
-
-# Do the same with class members
--dontskipnonpubliclibraryclassmembers
-
-# Keep test packages
--keep class androidx.** { *; }
--keep class android.test.** { *; }
--keep public class * extends androidx.** { *; }
--keep public class * extends android.test.** { *; }
--keep interface androidx.** { *; }
--keep interface android.test.** { *; }
-
-# Keep all junit classes
--keep class junit.** { *; }
--keep class org.junit.** { *; }
--keep interface junit.** { *; }
--keep interface org.junit.** { *; }
-
-# Keep compiled java classes from declared aidl's within the test package
--keep public class * extends android.os.IInterface { *; }
-
-# Don't warn about the Android Support Test JUnit Runner
--dontwarn androidx.**
--dontwarn android.test.**
-
-# Don't warn about junit
--dontwarn junit.**
--dontwarn org.junit.**
-
-# keep mockito methods
--keep class org.mockito.** { *; }
--keep interface org.mockito.** { *; }
--keep class com.google.dexmaker.** { *; }
--keep interface com.google.dexmaker.** { *; }
-
-# Always process
--forceprocessing
-
-# Make sure not to obfuscate the output
--dontobfuscate
diff --git a/tests/res/drawable-hdpi/ic_launcher.png b/tests/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcc..00000000
Binary files a/tests/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/tests/res/drawable-hdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-hdpi/ic_whatshot_white_24dp.png
deleted file mode 100644
index 46ed1f8b..00000000
Binary files a/tests/res/drawable-hdpi/ic_whatshot_white_24dp.png and /dev/null differ
diff --git a/tests/res/drawable-mdpi/ic_launcher.png b/tests/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cb..00000000
Binary files a/tests/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/tests/res/drawable-mdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-mdpi/ic_whatshot_white_24dp.png
deleted file mode 100644
index 4cf6f85f..00000000
Binary files a/tests/res/drawable-mdpi/ic_whatshot_white_24dp.png and /dev/null differ
diff --git a/tests/res/drawable-xhdpi/ic_launcher.png b/tests/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e..00000000
Binary files a/tests/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/tests/res/drawable-xhdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-xhdpi/ic_whatshot_white_24dp.png
deleted file mode 100644
index 3651d061..00000000
Binary files a/tests/res/drawable-xhdpi/ic_whatshot_white_24dp.png and /dev/null differ
diff --git a/tests/res/drawable-xxhdpi/ic_launcher.png b/tests/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cd..00000000
Binary files a/tests/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/tests/res/drawable-xxhdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-xxhdpi/ic_whatshot_white_24dp.png
deleted file mode 100644
index 8eaf3755..00000000
Binary files a/tests/res/drawable-xxhdpi/ic_whatshot_white_24dp.png and /dev/null differ
diff --git a/tests/res/drawable-xxxhdpi/ic_whatshot_white_24dp.png b/tests/res/drawable-xxxhdpi/ic_whatshot_white_24dp.png
deleted file mode 100644
index 5c5d8687..00000000
Binary files a/tests/res/drawable-xxxhdpi/ic_whatshot_white_24dp.png and /dev/null differ
diff --git a/tests/res/layout/main.xml b/tests/res/layout/main.xml
deleted file mode 100644
index 15b422cd..00000000
--- a/tests/res/layout/main.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/res/layout/remote_view.xml b/tests/res/layout/remote_view.xml
deleted file mode 100644
index 6988cf95..00000000
--- a/tests/res/layout/remote_view.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tests/res/values/strings.xml b/tests/res/values/strings.xml
deleted file mode 100644
index 5cbd37c5..00000000
--- a/tests/res/values/strings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- Lineage Platform Tests
- Lineage Platform Settings Tests
- Lineage Platform Alarm Clock Tests
-
diff --git a/tests/src/org/lineageos/tests/LineageOSTestApplication.java b/tests/src/org/lineageos/tests/LineageOSTestApplication.java
deleted file mode 100644
index 0eb754e9..00000000
--- a/tests/src/org/lineageos/tests/LineageOSTestApplication.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) 2016, 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.lineageos.tests;
-
-import android.app.Application;
-import android.content.Context;
-
-/**
- * Created by adnan on 2/4/16.
- */
-public class LineageOSTestApplication extends Application {
- private static Context sApplicationContext;
-
- @Override
- public void onCreate() {
- super.onCreate();
- sApplicationContext = getApplicationContext();
- }
-
- public static Context getStaticApplicationContext() {
- return sApplicationContext;
- }
-}
diff --git a/tests/src/org/lineageos/tests/TestActivity.java b/tests/src/org/lineageos/tests/TestActivity.java
deleted file mode 100644
index 9c8d8604..00000000
--- a/tests/src/org/lineageos/tests/TestActivity.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2008 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 org.lineageos.tests;
-
-import android.app.ListActivity;
-import android.os.Bundle;
-
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-public abstract class TestActivity extends ListActivity
-{
- Test[] mTests;
-
- protected abstract String tag();
- protected abstract Test[] tests();
-
- protected abstract class Test {
- protected String name;
- protected Test(String n) {
- name = n;
- }
- protected abstract void run();
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- mTests = tests();
-
- String[] labels = new String[mTests.length];
- for (int i=0; i(this, android.R.layout.simple_list_item_1, labels));
- }
-
- @Override
- public void onListItemClick(ListView l, View v, int position, long id)
- {
- Test t = mTests[position];
- android.util.Log.d(tag(), "Test: " + t.name);
- t.run();
- }
-
-}
\ No newline at end of file
diff --git a/tests/src/org/lineageos/tests/common/MockIBinderStubForInterface.java b/tests/src/org/lineageos/tests/common/MockIBinderStubForInterface.java
deleted file mode 100644
index 4a51d9a0..00000000
--- a/tests/src/org/lineageos/tests/common/MockIBinderStubForInterface.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright (c) 2016, 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.lineageos.tests.common;
-
-import android.os.IBinder;
-import android.os.IInterface;
-import org.junit.Assert;
-import org.mockito.Mockito;
-
-import java.lang.reflect.Field;
-
-/**
- * Helper class to mock stubs for IInterfaces
- * Ensures that when querying the local interface
- * we return the instance itself as to preserve the mock instance
- */
-public final class MockIBinderStubForInterface {
- private MockIBinderStubForInterface() {}
-
- private static String getStubDescriptor(Class stubClass) {
- String descriptor = null;
- try {
- Field f = stubClass.getDeclaredField("DESCRIPTOR");
- f.setAccessible(true);
- descriptor = (String) f.get(stubClass);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- Assert.fail(e.getMessage());
- }
- return descriptor;
- }
-
- public static T getMockInterface(Class stub) {
- String descriptor = getStubDescriptor(stub);
- T mockInterface = Mockito.mock(stub);
- Mockito.doReturn(mockInterface)
- .when(mockInterface)
- .queryLocalInterface(descriptor == null ?
- Mockito.anyString() : Mockito.eq(descriptor));
- Mockito.doReturn(Mockito.mock(IBinder.class))
- .when((IInterface) mockInterface)
- .asBinder();
- return mockInterface;
- }
-}
diff --git a/tests/src/org/lineageos/tests/common/ThreadServiceTestCase.java b/tests/src/org/lineageos/tests/common/ThreadServiceTestCase.java
deleted file mode 100644
index 55807c5c..00000000
--- a/tests/src/org/lineageos/tests/common/ThreadServiceTestCase.java
+++ /dev/null
@@ -1,200 +0,0 @@
-package org.lineageos.tests.common;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.IBinder;
-import android.os.Looper;
-import android.test.InstrumentationTestCase;
-import android.test.ServiceTestCase;
-
-/**
- * Tests a service in its own Thread.
- *
- *
- *
- * The {@link ServiceTestCase} class creates the service in the same thread the
- * test is running. In consequence Handlers and other constructs that depend on
- * the fact that the service methods are always run on the main thread
- * won't work.
- *
- *
- *
- * To circumvent this, this test class creates a {@link HandlerThread} on setup
- * to simulate the main tread and provides helper constructs to ease the
- * communication between the Service and the test class :
- *
- *
- *
- *
The {@link #runOnServiceThread(Runnable)} methods allows to run code on
- * the service pseudo-main thread.
- *
The {@link #startService(boolean, ServiceRunnable)} mehod allows starting
- * the service in its own thread with some additional initialization code.
- *
- *
- *
- * @author Antoine Martin
- *
- */
-public abstract class ThreadServiceTestCase extends ServiceTestCase {
-
- /** Typical maximum wait time for something to happen on the service */
- public static final long WAIT_TIME = 5 * 1000;
-
- /*
- * This class provides final mutable values through indirection
- */
- static class Holder {
- H value;
- }
-
- protected Handler serviceHandler;
- protected Looper serviceLooper;
- /*
- * Got to catch this again because of damn package visibility of
- * mServiceClass in base class.
- */
- protected Class serviceClass;
-
- public ThreadServiceTestCase(Class serviceClass) {
- super(serviceClass);
- this.serviceClass = serviceClass;
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // Setup service thread
- HandlerThread serviceThread = new HandlerThread("[" + serviceClass.getSimpleName() + "Thread]");
- serviceThread.start();
- serviceLooper = serviceThread.getLooper();
- serviceHandler = new Handler(serviceLooper);
- }
-
- @Override
- public void testServiceTestCaseSetUpProperly() throws Exception {
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- // teardown service thread
- if (serviceLooper != null)
- serviceLooper.quit();
- serviceHandler = null;
- }
-
- /**
- * Runs the specified runnable on the service tread and waits for its
- * completion.
- *
- * @see InstrumentationTestCase#runTestOnUiThread(Runnable)
- * @param r
- * The runnable to run on the pseudo-main thread.
- */
- protected void runOnServiceThread(final Runnable r) {
- final CountDownLatch serviceSignal = new CountDownLatch(1);
- serviceHandler.post(new Runnable() {
-
- @Override
- public void run() {
- r.run();
- serviceSignal.countDown();
- }
- });
-
- try {
- serviceSignal.await();
- } catch (InterruptedException ie) {
- fail("The Service thread has been interrupted");
- }
- }
-
- /**
- * Runnable interface allowing service initialization personalization.
- *
- * @author Antoine Martin
- *
- */
- protected interface ServiceRunnable {
- public void run(Service service);
- }
-
- /**
- * Initialize the service in its own thread and returns it.
- *
- * @param bound
- * if {@code true}, the service will be created as if it was
- * bound by a client. if {@code false}, it will be created by a
- * {@code startService} call.
- * @param r
- * {@link ServiceRunnable} instance that will be called with the
- * created service.
- * @return The created service.
- */
- protected T startService(final ServiceRunnable r) {
- final Holder serviceHolder = new Holder();
-
- // I want to create my service in its own 'Main thread'
- // So it can use its handler
- runOnServiceThread(new Runnable() {
-
- @Override
- public void run() {
- T service = null;
- startService(new Intent(getContext(), serviceClass));
- service = getService();
- if (r != null)
- r.run(service);
- serviceHolder.value = service;
- }
- });
-
- return serviceHolder.value;
- }
-
- protected IBinder bindService(final ServiceRunnable r) {
- final Holder serviceHolder = new Holder();
-
- // I want to create my service in its own 'Main thread'
- // So it can use its handler
- runOnServiceThread(new Runnable() {
-
- @Override
- public void run() {
- T service = null;
- IBinder binder = bindService(new Intent(getContext(), serviceClass));
- service = getService();
- if (r != null)
- r.run(service);
- serviceHolder.value = binder;
- }
- });
-
- return serviceHolder.value;
- }
-
- public static class ServiceSyncHelper {
- // The semaphore will wakeup clients
- protected final Semaphore semaphore = new Semaphore(0);
-
- /**
- * Waits for some response coming from the service.
- *
- * @param timeout
- * The maximum time to wait.
- * @throws InterruptedException
- * if the Thread is interrupted or reaches the timeout.
- */
- public synchronized void waitListener(long timeout) throws InterruptedException {
- if (!semaphore.tryAcquire(timeout, TimeUnit.MILLISECONDS))
- throw new InterruptedException();
- }
- }
-
-}
\ No newline at end of file
diff --git a/tests/src/org/lineageos/tests/hardware/LineageHardwareTest.java b/tests/src/org/lineageos/tests/hardware/LineageHardwareTest.java
deleted file mode 100644
index d9507956..00000000
--- a/tests/src/org/lineageos/tests/hardware/LineageHardwareTest.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/**
- * Copyright (c) 2015-2016, 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.lineageos.tests.hardware;
-
-import android.os.Bundle;
-
-import android.widget.Toast;
-
-import java.util.Arrays;
-import java.util.List;
-
-import lineageos.hardware.LineageHardwareManager;
-import lineageos.hardware.DisplayMode;
-
-import org.lineageos.tests.TestActivity;
-
-/**
- * Created by adnan on 8/31/15.
- */
-public class LineageHardwareTest extends TestActivity {
- private LineageHardwareManager mHardwareManager;
-
- private static final List FEATURES = Arrays.asList(
- LineageHardwareManager.FEATURE_ADAPTIVE_BACKLIGHT,
- LineageHardwareManager.FEATURE_COLOR_ENHANCEMENT,
- LineageHardwareManager.FEATURE_DISPLAY_COLOR_CALIBRATION,
- LineageHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY,
- LineageHardwareManager.FEATURE_KEY_DISABLE,
- LineageHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT,
- LineageHardwareManager.FEATURE_TOUCH_HOVERING,
- LineageHardwareManager.FEATURE_AUTO_CONTRAST,
- LineageHardwareManager.FEATURE_DISPLAY_MODES
- );
-
- private static final List FEATURE_STRINGS = Arrays.asList(
- "FEATURE_ADAPTIVE_BACKLIGHT",
- "FEATURE_COLOR_ENHANCEMENT",
- "FEATURE_DISPLAY_COLOR_CALIBRATION",
- "FEATURE_HIGH_TOUCH_SENSITIVITY",
- "FEATURE_KEY_DISABLE",
- "FEATURE_SUNLIGHT_ENHANCEMENT",
- "FEATURE_TOUCH_HOVERING",
- "FEATURE_AUTO_CONTRAST",
- "FEATURE_DISPLAY_MODES"
- );
-
- private static final List BOOLEAN_FEATURES = Arrays.asList(
- LineageHardwareManager.FEATURE_ADAPTIVE_BACKLIGHT,
- LineageHardwareManager.FEATURE_COLOR_ENHANCEMENT,
- LineageHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY,
- LineageHardwareManager.FEATURE_KEY_DISABLE,
- LineageHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT,
- LineageHardwareManager.FEATURE_TOUCH_HOVERING,
- LineageHardwareManager.FEATURE_AUTO_CONTRAST
- );
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- mHardwareManager = LineageHardwareManager.getInstance(this);
- }
-
- @Override
- protected String tag() {
- return null;
- }
-
- @Override
- protected Test[] tests() {
- return mTests;
- }
-
- private boolean vibratorSupported() {
- if (mHardwareManager.isSupported(LineageHardwareManager.FEATURE_VIBRATOR)) {
- return true;
- } else {
- Toast.makeText(LineageHardwareTest.this, "Vibrator not supported",
- Toast.LENGTH_SHORT).show();
- return false;
- }
- }
-
- private boolean displayColorCalibrationSupported() {
- if (mHardwareManager.isSupported(LineageHardwareManager.FEATURE_DISPLAY_COLOR_CALIBRATION)) {
- return true;
- } else {
- Toast.makeText(LineageHardwareTest.this, "Display Color Calibration not supported",
- Toast.LENGTH_SHORT).show();
- return false;
- }
- }
-
- private boolean displayModesSupported() {
- if (mHardwareManager.isSupported(LineageHardwareManager.FEATURE_DISPLAY_MODES)) {
- return true;
- } else {
- Toast.makeText(LineageHardwareTest.this, "Display modes not supported",
- Toast.LENGTH_SHORT).show();
- return false;
- }
- }
-
- private Test[] mTests = new Test[] {
- new Test("Test get supported features") {
- public void run() {
- Toast.makeText(LineageHardwareTest.this, "Supported features " +
- mHardwareManager.getSupportedFeatures(),
- Toast.LENGTH_SHORT).show();
- }
- },
- new Test("Test features supported") {
- @Override
- protected void run() {
- StringBuilder builder = new StringBuilder();
- int i = 0;
- for (int feature : FEATURES) {
- boolean supported = mHardwareManager.isSupported(feature);
- if (mHardwareManager.isSupported(FEATURE_STRINGS.get(i)) != supported) {
- throw new RuntimeException("Internal error, feature string lookup failed");
- }
- i++;
- builder.append("Feature " + feature + "\n")
- .append("is supported " + supported + "\n");
- }
- Toast.makeText(LineageHardwareTest.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(LineageHardwareTest.this, "Features " +
- builder.toString(),
- Toast.LENGTH_SHORT).show();
- }
- },
- new Test("Test get vibrator intensity") {
- @Override
- protected void run() {
- if (vibratorSupported()) {
- Toast.makeText(LineageHardwareTest.this, "Vibrator intensity " +
- mHardwareManager.getVibratorIntensity(),
- Toast.LENGTH_SHORT).show();
- }
- }
- },
- new Test("Test get vibrator default intensity") {
- @Override
- protected void run() {
- if (vibratorSupported()) {
- Toast.makeText(LineageHardwareTest.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(LineageHardwareTest.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(LineageHardwareTest.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(LineageHardwareTest.this, "Vibrator min intensity " +
- mHardwareManager.getVibratorWarningIntensity(),
- Toast.LENGTH_SHORT).show();
- }
- }
- },
- new Test("Test Display Color Calibration") {
- @Override
- protected void run() {
- if (displayColorCalibrationSupported()) {
- Toast.makeText(LineageHardwareTest.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(LineageHardwareTest.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(LineageHardwareTest.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(LineageHardwareTest.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 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(LineageHardwareTest.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(LineageHardwareTest.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(LineageHardwareTest.this, "Default Display Mode " +
- mHardwareManager.getCurrentDisplayMode(),
- Toast.LENGTH_SHORT).show();
- }
- }
- },
- };
-}
diff --git a/tests/src/org/lineageos/tests/hardware/unit/DisplayModeTest.java b/tests/src/org/lineageos/tests/hardware/unit/DisplayModeTest.java
deleted file mode 100644
index 01a24771..00000000
--- a/tests/src/org/lineageos/tests/hardware/unit/DisplayModeTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.lineageos.tests.hardware.unit;
-
-import android.os.Parcel;
-import android.test.AndroidTestCase;
-
-import android.test.suitebuilder.annotation.SmallTest;
-import lineageos.app.LineageContextConstants;
-import lineageos.hardware.DisplayMode;
-
-/**
- * Created by adnan on 9/1/15.
- */
-public class DisplayModeTest extends AndroidTestCase {
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // Only run this if we support hardware abstraction
- org.junit.Assume.assumeTrue(mContext.getPackageManager().hasSystemFeature(
- LineageContextConstants.Features.HARDWARE_ABSTRACTION));
- }
-
- @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);
- }
-}
diff --git a/tests/src/org/lineageos/tests/hardware/unit/LineageHardwareManagerTest.java b/tests/src/org/lineageos/tests/hardware/unit/LineageHardwareManagerTest.java
deleted file mode 100644
index 01a8145f..00000000
--- a/tests/src/org/lineageos/tests/hardware/unit/LineageHardwareManagerTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.lineageos.tests.hardware.unit;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import lineageos.app.LineageContextConstants;
-import lineageos.hardware.LineageHardwareManager;
-import lineageos.hardware.ILineageHardwareService;
-
-/**
- * Created by adnan on 9/1/15.
- */
-public class LineageHardwareManagerTest extends AndroidTestCase {
- private LineageHardwareManager mLineageHardwareManager;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // Only run this if we support hardware abstraction
- org.junit.Assume.assumeTrue(mContext.getPackageManager().hasSystemFeature(
- LineageContextConstants.Features.HARDWARE_ABSTRACTION));
- mLineageHardwareManager = LineageHardwareManager.getInstance(mContext);
- }
-
- @SmallTest
- public void testManagerExists() {
- assertNotNull(mLineageHardwareManager);
- }
-
- @SmallTest
- public void testManagerServiceIsAvailable() {
- ILineageHardwareService ilineageStatusBarManager = mLineageHardwareManager.getService();
- assertNotNull(ilineageStatusBarManager);
- }
-}
diff --git a/tests/src/org/lineageos/tests/hardware/unit/LiveDisplayManagerTest.java b/tests/src/org/lineageos/tests/hardware/unit/LiveDisplayManagerTest.java
deleted file mode 100644
index 2f0eec9c..00000000
--- a/tests/src/org/lineageos/tests/hardware/unit/LiveDisplayManagerTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package org.lineageos.tests.hardware.unit;
-
-import android.content.Context;
-import android.os.PowerManager;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import org.junit.Assume;
-
-import lineageos.app.LineageContextConstants;
-import lineageos.hardware.LineageHardwareManager;
-import lineageos.hardware.ILiveDisplayService;
-import lineageos.hardware.LiveDisplayConfig;
-import lineageos.hardware.LiveDisplayManager;
-import lineageos.util.ColorUtils;
-
-public class LiveDisplayManagerTest extends AndroidTestCase {
-
- private static final String TAG = "LiveDisplayManagerTest";
-
- private LiveDisplayManager mLiveDisplay;
- private LineageHardwareManager mHardware;
-
- private PowerManager mPower;
- private PowerManager.WakeLock mWakeLock;
-
- private LiveDisplayConfig mConfig;
- private int mInitialMode;
-
- @SuppressWarnings("deprecation")
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- Assume.assumeTrue(mContext.getPackageManager().hasSystemFeature(
- LineageContextConstants.Features.LIVEDISPLAY));
-
- mLiveDisplay = LiveDisplayManager.getInstance(mContext);
- if (mLiveDisplay.getConfig().hasModeSupport()) {
- mInitialMode = mLiveDisplay.getMode();
- }
- mConfig = mLiveDisplay.getConfig();
-
- mHardware = LineageHardwareManager.getInstance(mContext);
- mPower = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
- mWakeLock = mPower.newWakeLock(
- PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);
- mWakeLock.acquire();
- }
-
- @Override
- protected void tearDown() {
- mLiveDisplay.setMode(mInitialMode);
- mWakeLock.release();
- }
-
- @SmallTest
- public void testManagerExists() {
- assertNotNull(mLiveDisplay);
- }
-
- @SmallTest
- public void testManagerServiceIsAvailable() {
- ILiveDisplayService service = LiveDisplayManager.getService();
- assertNotNull(service);
- }
-
- @SmallTest
- public void testConfig() {
- assertNotNull(mConfig);
-
- // at least GPU mode should be available
- assertTrue(mConfig.isAvailable());
- }
-
- @SmallTest
- public void testNightMode() throws Exception {
- Assume.assumeTrue(mConfig.hasModeSupport());
-
- int day = mLiveDisplay.getDayColorTemperature();
- int night = mLiveDisplay.getNightColorTemperature();
-
- mLiveDisplay.setMode(LiveDisplayManager.MODE_NIGHT);
- assertColorTemperature(night);
-
- // custom value
- mLiveDisplay.setNightColorTemperature(3300);
- assertColorTemperature(3300);
-
- // "default"
- mLiveDisplay.setNightColorTemperature(mConfig.getDefaultNightTemperature());
- assertColorTemperature(mConfig.getDefaultNightTemperature());
-
- mLiveDisplay.setNightColorTemperature(night);
-
- // day should not have changed
- assertEquals(day, mLiveDisplay.getDayColorTemperature());
- }
-
- @SmallTest
- public void testDayMode() throws Exception {
- Assume.assumeTrue(mConfig.hasModeSupport());
-
- int day = mLiveDisplay.getDayColorTemperature();
- int night = mLiveDisplay.getNightColorTemperature();
-
- mLiveDisplay.setMode(LiveDisplayManager.MODE_DAY);
- assertColorTemperature(day);
-
- // custom value
- mLiveDisplay.setDayColorTemperature(8000);
- assertColorTemperature(8000);
-
- // "default"
- mLiveDisplay.setDayColorTemperature(mConfig.getDefaultDayTemperature());
- assertColorTemperature(mConfig.getDefaultDayTemperature());
-
- mLiveDisplay.setDayColorTemperature(day);
-
- // night should not have changed
- assertEquals(night, mLiveDisplay.getNightColorTemperature());
- }
-
- @SmallTest
- public void testOutdoorMode() throws Exception {
- Assume.assumeTrue(mConfig.hasFeature(LiveDisplayManager.MODE_OUTDOOR));
-
- assertTrue(mHardware.isSupported(LineageHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT));
-
- mLiveDisplay.setMode(LiveDisplayManager.MODE_OUTDOOR);
- Thread.sleep(1000);
- assertTrue(mHardware.get(LineageHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT));
-
- mLiveDisplay.setMode(LiveDisplayManager.MODE_OFF);
- Thread.sleep(1000);
- assertFalse(mHardware.get(LineageHardwareManager.FEATURE_SUNLIGHT_ENHANCEMENT));
- }
-
- private void assertColorTemperature(int degK) throws Exception {
- Thread.sleep(2000);
- assertEquals(degK, LiveDisplayManager.getService().getColorTemperature());
- checkHardwareValue(ColorUtils.temperatureToRGB(degK));
- }
-
- private void checkHardwareValue(float[] expected) {
- int[] hardware = mHardware.getDisplayColorCalibration();
- int max = mHardware.getDisplayColorCalibrationMax();
- assertEquals((int)Math.floor(expected[0] * max), hardware[0]);
- assertEquals((int)Math.floor(expected[1] * max), hardware[1]);
- assertEquals((int)Math.floor(expected[2] * max), hardware[2]);
- }
-}
diff --git a/tests/src/org/lineageos/tests/profiles/ProfileTest.java b/tests/src/org/lineageos/tests/profiles/ProfileTest.java
deleted file mode 100644
index e47ac0a3..00000000
--- a/tests/src/org/lineageos/tests/profiles/ProfileTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * 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.lineageos.tests.profiles;
-
-import android.media.AudioManager;
-import android.os.Bundle;
-
-import lineageos.app.Profile;
-import lineageos.app.Profile.Type;
-
-import lineageos.app.ProfileManager;
-import lineageos.profiles.AirplaneModeSettings;
-import lineageos.profiles.BrightnessSettings;
-import lineageos.profiles.ConnectionSettings;
-import lineageos.profiles.LockSettings;
-import lineageos.profiles.RingModeSettings;
-import lineageos.profiles.StreamSettings;
-import org.lineageos.tests.TestActivity;
-
-import java.util.ArrayList;
-import java.util.UUID;
-
-/**
- * Created by adnan on 6/26/15.
- */
-public class ProfileTest extends TestActivity {
- private ProfileManager mProfileManager;
- private ArrayList mProfileUuidList;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- mProfileManager = ProfileManager.getInstance(this);
- mProfileUuidList = new ArrayList();
- }
-
- @Override
- protected Test[] tests() {
- return mTests;
- }
-
- @Override
- protected String tag() {
- return null;
- }
-
- private Test[] mTests = new Test[] {
- new Test("test create random Profile") {
- public void run() {
- Profile profile = new Profile("Test Profile");
- profile.setProfileType(Type.TOGGLE);
- profile.setDozeMode(Profile.DozeMode.DEFAULT);
- profile.setScreenLockMode(new LockSettings(Profile.LockMode.DISABLE));
- mProfileUuidList.add(profile.getUuid());
- mProfileManager.addProfile(profile);
- }
- },
- new Test("test add static Profile") {
- public void run() {
- Profile profile = new Profile("Test Profile-Active",
- 0, UUID.fromString("65cd0d0c-1c42-11e5-9a21-1697f925ec7b"));
- profile.setProfileType(Type.TOGGLE);
- profile.setDozeMode(Profile.DozeMode.DEFAULT);
- profile.setScreenLockMode(new LockSettings(Profile.LockMode.DISABLE));
- mProfileUuidList.add(profile.getUuid());
- mProfileManager.addProfile(profile);
- mProfileManager.setActiveProfile(profile.getUuid());
- }
- },
- new Test("test remove static Profile") {
- public void run() {
- mProfileManager.removeProfile(
- mProfileManager.getProfile("65cd0d0c-1c42-11e5-9a21-1697f925ec7b"));
- }
- },
- new Test("test create Profile and Set Active") {
- public void run() {
- Profile profile = new Profile("Test Profile-Active");
- profile.setProfileType(Type.TOGGLE);
- profile.setDozeMode(Profile.DozeMode.DEFAULT);
- profile.setScreenLockMode(new LockSettings(Profile.LockMode.DISABLE));
- mProfileUuidList.add(profile.getUuid());
- mProfileManager.addProfile(profile);
- mProfileManager.setActiveProfile(profile.getUuid());
- }
- },
- new Test("test create Profile, override airplane settings, and set active") {
- @Override
- protected void run() {
- Profile profile = new Profile("Test Profile-Override-AIR-Active");
- profile.setProfileType(Type.TOGGLE);
- AirplaneModeSettings airplaneModeSettings =
- new AirplaneModeSettings(
- AirplaneModeSettings.BooleanState.STATE_ENABLED, true);
- profile.setAirplaneMode(airplaneModeSettings);
- mProfileUuidList.add(profile.getUuid());
- mProfileManager.addProfile(profile);
- mProfileManager.setActiveProfile(profile.getUuid());
- }
- },
- new Test("test create Profile, override ring stream settings, and set active") {
- @Override
- protected void run() {
- Profile profile = new Profile("Test Profile-Override-RNG-Active");
- profile.setProfileType(Type.TOGGLE);
- StreamSettings streamSettings =
- new StreamSettings(AudioManager.STREAM_RING, 0, true);
- profile.setStreamSettings(streamSettings);
- mProfileUuidList.add(profile.getUuid());
- mProfileManager.addProfile(profile);
- mProfileManager.setActiveProfile(profile.getUuid());
- }
- },
- new Test("test create Profile, override BT connection settings, and set active") {
- @Override
- protected void run() {
- Profile profile = new Profile("Test Profile-Override-CNNCT-Active");
- profile.setProfileType(Type.TOGGLE);
- ConnectionSettings connectionSettings =
- new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH,
- ConnectionSettings.BooleanState.STATE_ENABLED, true);
- profile.setConnectionSettings(connectionSettings);
- mProfileUuidList.add(profile.getUuid());
- mProfileManager.addProfile(profile);
- mProfileManager.setActiveProfile(profile.getUuid());
- }
- },
- new Test("test create Profile, override brightness settings, and set active") {
- @Override
- protected void run() {
- Profile profile = new Profile("Test Profile-Override-BRGHT-Active");
- profile.setProfileType(Type.TOGGLE);
- BrightnessSettings brightnessSettings =
- new BrightnessSettings(0, true);
- profile.setBrightness(brightnessSettings);
- mProfileUuidList.add(profile.getUuid());
- mProfileManager.addProfile(profile);
- mProfileManager.setActiveProfile(profile.getUuid());
- }
- },
- new Test("test create Profile, override ringmode settings, and set active") {
- @Override
- protected void run() {
- Profile profile = new Profile("Test Profile-Override-RNGMD-Active");
- profile.setProfileType(Type.TOGGLE);
- RingModeSettings ringSettings = new RingModeSettings(
- RingModeSettings.RING_MODE_MUTE, true);
- profile.setRingMode(ringSettings);
- mProfileUuidList.add(profile.getUuid());
- mProfileManager.addProfile(profile);
- mProfileManager.setActiveProfile(profile.getUuid());
- }
- },
- new Test("Reset All") {
- @Override
- protected void run() {
- // make sure we remove our own
- for (UUID uuid: mProfileUuidList) {
- Profile profile = mProfileManager.getProfile(uuid);
- if (profile != null) {
- mProfileManager.removeProfile(profile);
- }
- }
- mProfileManager.resetAll();
- }
- }
- };
-}
diff --git a/tests/src/org/lineageos/tests/profiles/unit/AirplaneModeSettingsTest.java b/tests/src/org/lineageos/tests/profiles/unit/AirplaneModeSettingsTest.java
deleted file mode 100644
index 995c3af1..00000000
--- a/tests/src/org/lineageos/tests/profiles/unit/AirplaneModeSettingsTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Copyright (C) 2016 The CyanogenMod Project
- * 2020 The LineageOS 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.lineageos.tests.profiles.unit;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import lineageos.profiles.AirplaneModeSettings;
-
-public class AirplaneModeSettingsTest extends AndroidTestCase {
-
- @SmallTest
- public void testConstructWholly() {
- AirplaneModeSettings airplaneModeSettings =
- new AirplaneModeSettings(
- AirplaneModeSettings.BooleanState.STATE_ENABLED, true);
- assertEquals(AirplaneModeSettings.BooleanState.STATE_ENABLED, airplaneModeSettings.getValue());
- assertEquals(true, airplaneModeSettings.isOverride());
- }
-
- @SmallTest
- public void testVerifyOverride() {
- AirplaneModeSettings airplaneModeSettings =
- new AirplaneModeSettings(
- AirplaneModeSettings.BooleanState.STATE_ENABLED, true);
- airplaneModeSettings.setOverride(false);
- assertEquals(false, airplaneModeSettings.isOverride());
- }
-
- @SmallTest
- public void testVerifyValue() {
- int expectedValue = AirplaneModeSettings.BooleanState.STATE_DISABLED;
- AirplaneModeSettings airplaneModeSettings =
- new AirplaneModeSettings(
- AirplaneModeSettings.BooleanState.STATE_ENABLED, true);
- airplaneModeSettings.setValue(expectedValue);
- assertEquals(expectedValue, airplaneModeSettings.getValue());
- }
-}
diff --git a/tests/src/org/lineageos/tests/profiles/unit/BrightnessSettingsTest.java b/tests/src/org/lineageos/tests/profiles/unit/BrightnessSettingsTest.java
deleted file mode 100644
index 73814d88..00000000
--- a/tests/src/org/lineageos/tests/profiles/unit/BrightnessSettingsTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (c) 2016, 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.lineageos.tests.profiles.unit;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import lineageos.profiles.BrightnessSettings;
-
-public class BrightnessSettingsTest extends AndroidTestCase {
-
- @SmallTest
- public void testConstructWholly() {
- BrightnessSettings brightnessSettings =
- new BrightnessSettings(0, true);
- assertEquals(0, brightnessSettings.getValue());
- assertEquals(true, brightnessSettings.isOverride());
- }
-
- @SmallTest
- public void testVerifyOverride() {
- BrightnessSettings brightnessSettings =
- new BrightnessSettings(0, true);
- brightnessSettings.setOverride(false);
- assertEquals(false, brightnessSettings.isOverride());
- }
-
- @SmallTest
- public void testVerifyValue() {
- int expectedValue = 30;
- BrightnessSettings brightnessSettings =
- new BrightnessSettings(0, true);
- brightnessSettings.setValue(expectedValue);
- assertEquals(expectedValue, brightnessSettings.getValue());
- }
-}
diff --git a/tests/src/org/lineageos/tests/profiles/unit/ConnectionSettingsTest.java b/tests/src/org/lineageos/tests/profiles/unit/ConnectionSettingsTest.java
deleted file mode 100644
index e730cd15..00000000
--- a/tests/src/org/lineageos/tests/profiles/unit/ConnectionSettingsTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Copyright (C) 2016 The CyanogenMod Project
- * 2020 The LineageOS 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.lineageos.tests.profiles.unit;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import lineageos.profiles.ConnectionSettings;
-
-public class ConnectionSettingsTest extends AndroidTestCase {
-
- @SmallTest
- public void testConstructManually() {
- ConnectionSettings connectionSettings = new ConnectionSettings(
- ConnectionSettings.PROFILE_CONNECTION_LOCATION);
- assertEquals(ConnectionSettings.PROFILE_CONNECTION_LOCATION,
- connectionSettings.getConnectionId());
- assertNotNull(connectionSettings);
- }
-
- @SmallTest
- public void testConstructWholly() {
- ConnectionSettings connectionSettings =
- new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_LOCATION,
- ConnectionSettings.BooleanState.STATE_DISABLED, true);
- assertEquals(true, connectionSettings.isOverride());
- assertEquals(ConnectionSettings.BooleanState.STATE_DISABLED,
- connectionSettings.getValue());
- assertEquals(ConnectionSettings.PROFILE_CONNECTION_LOCATION,
- connectionSettings.getConnectionId());
- assertNotNull(connectionSettings);
- }
-
- @SmallTest
- public void testVerifyOverride() {
- ConnectionSettings connectionSettings = new ConnectionSettings(
- ConnectionSettings.PROFILE_CONNECTION_LOCATION);
- connectionSettings.setOverride(true);
- assertEquals(true, connectionSettings.isOverride());
- }
-
- @SmallTest
- public void testVerifySubId() {
- int expectedSubId = 2;
- ConnectionSettings connectionSettings = new ConnectionSettings(
- ConnectionSettings.PROFILE_CONNECTION_2G3G4G);
- connectionSettings.setSubId(expectedSubId);
- assertEquals(expectedSubId, connectionSettings.getSubId());
- }
-
- @SmallTest
- public void testVerifyValue() {
- int expectedValue = ConnectionSettings.BooleanState.STATE_DISABLED;
- ConnectionSettings connectionSettings = new ConnectionSettings(
- ConnectionSettings.PROFILE_CONNECTION_2G3G4G);
- connectionSettings.setValue(expectedValue);
- assertEquals(expectedValue, connectionSettings.getValue());
- }
-}
diff --git a/tests/src/org/lineageos/tests/profiles/unit/LockSettingsTest.java b/tests/src/org/lineageos/tests/profiles/unit/LockSettingsTest.java
deleted file mode 100644
index f3a47570..00000000
--- a/tests/src/org/lineageos/tests/profiles/unit/LockSettingsTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (c) 2016, 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.lineageos.tests.profiles.unit;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import lineageos.app.Profile;
-import lineageos.profiles.LockSettings;
-
-public class LockSettingsTest extends AndroidTestCase {
-
- @SmallTest
- public void testConstructWholly() {
- LockSettings lockSettings = new LockSettings(Profile.LockMode.INSECURE);
- assertEquals(Profile.LockMode.INSECURE, lockSettings.getValue());
- }
-
- @SmallTest
- public void testVerifyValue() {
- int expectedValue = Profile.LockMode.DEFAULT;
- LockSettings lockSettings = new LockSettings(Profile.LockMode.INSECURE);
- lockSettings.setValue(expectedValue);
- assertEquals(expectedValue, lockSettings.getValue());
- }
-}
diff --git a/tests/src/org/lineageos/tests/profiles/unit/ProfileManagerTest.java b/tests/src/org/lineageos/tests/profiles/unit/ProfileManagerTest.java
deleted file mode 100644
index 1cbc230c..00000000
--- a/tests/src/org/lineageos/tests/profiles/unit/ProfileManagerTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/**
- * 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.lineageos.tests.profiles.unit;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import lineageos.app.LineageContextConstants;
-import lineageos.app.Profile;
-import lineageos.app.ProfileManager;
-import lineageos.app.IProfileManager;
-import lineageos.providers.LineageSettings;
-
-import java.util.Arrays;
-import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-
-public class ProfileManagerTest extends AndroidTestCase {
- private static final String TAG = ProfileManagerTest.class.getSimpleName();
- private static final int COUNTDOWN = 1;
- private ProfileManager mProfileManager;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mProfileManager = ProfileManager.getInstance(mContext);
- // Only run this if we support profiles service
- org.junit.Assume.assumeTrue(mContext.getPackageManager().hasSystemFeature(
- LineageContextConstants.Features.PROFILES));
- }
-
- @SmallTest
- public void testManagerExists() {
- assertNotNull(mProfileManager);
- }
-
- @SmallTest
- public void testManagerServiceIsAvailable() {
- IProfileManager iProfileManager = mProfileManager.getService();
- assertNotNull(iProfileManager);
- }
-
- @SmallTest
- public void testManagerProfileIsEnabled() {
- // first enable profiles
- final String enabledValue = "1";
- assertTrue(LineageSettings.System.putString(getContext().getContentResolver(),
- LineageSettings.System.SYSTEM_PROFILES_ENABLED, enabledValue));
-
- // check that we successfully enabled them via system setting
- assertEquals(enabledValue, LineageSettings.System.getString(getContext().getContentResolver(),
- LineageSettings.System.SYSTEM_PROFILES_ENABLED));
-
- // check that profile manger returns true
- assertTrue(mProfileManager.isProfilesEnabled());
-
- // now disable the setting
- final String disabledValue = "0";
- assertTrue(LineageSettings.System.putString(getContext().getContentResolver(),
- LineageSettings.System.SYSTEM_PROFILES_ENABLED, disabledValue));
-
- // check that we successfully disable them via system setting
- assertEquals(disabledValue, LineageSettings.System.getString(getContext().getContentResolver(),
- LineageSettings.System.SYSTEM_PROFILES_ENABLED));
-
- assertFalse(mProfileManager.isProfilesEnabled());
- }
-
- private void ensureProfilesEnabled() {
- final String enabledValue = "1";
- assertTrue(LineageSettings.System.putString(getContext().getContentResolver(),
- LineageSettings.System.SYSTEM_PROFILES_ENABLED, enabledValue));
- }
-
- @SmallTest
- public void testGetActiveProfile() {
- ensureProfilesEnabled();
- final CountDownLatch signal = new CountDownLatch(COUNTDOWN);
- final Profile expectedActiveProfile = new Profile("TEST ACTIVE PROFILE");
- mProfileManager.addProfile(expectedActiveProfile);
-
- BroadcastReceiver intentReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- signal.countDown();
- }
- };
-
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(ProfileManager.INTENT_ACTION_PROFILE_SELECTED);
- intentFilter.addAction(ProfileManager.INTENT_ACTION_PROFILE_UPDATED);
-
- mContext.registerReceiver(intentReceiver, intentFilter);
-
- mProfileManager.setActiveProfile(expectedActiveProfile.getName());
-
- // Lock
- try {
- signal.await();
- } catch (InterruptedException e) {
- throw new AssertionError(e);
- }
-
- assertEquals(expectedActiveProfile.getName(),
- mProfileManager.getActiveProfile().getName());
- mProfileManager.resetAll();
-
- mContext.unregisterReceiver(intentReceiver);
- }
-
- @SmallTest
- public void testGetProfileNames() {
- ensureProfilesEnabled();
- String[] expectedProfileNames = new String[5];
- // These defaults are pulled from the default xml in the lineage platform resource package
- Profile expectedProfile1 = mProfileManager.getProfile(
- UUID.fromString("6a181391-12ef-4f43-a701-32b11ed69449"));
- Profile expectedProfile2 = mProfileManager.getProfile(
- UUID.fromString("0230226d-0d05-494a-a9bd-d222a1117655"));
- Profile expectedProfile3 = mProfileManager.getProfile(
- UUID.fromString("e4e77d03-82ce-4417-9257-7d6c9ffb8fd1"));
-
- // Add extras
- Profile expectedProfile4 = new Profile("PROFILE 1");
- Profile expectedProfile5 = new Profile("PROFILE 2");
-
- expectedProfileNames[0] = expectedProfile1.getName();
- expectedProfileNames[1] = expectedProfile2.getName();
- expectedProfileNames[2] = expectedProfile3.getName();
- expectedProfileNames[3] = expectedProfile4.getName();
- expectedProfileNames[4] = expectedProfile5.getName();
-
- mProfileManager.addProfile(expectedProfile1);
- mProfileManager.addProfile(expectedProfile2);
-
- String[] actualProfileNames = mProfileManager.getProfileNames();
- for (int i = 0; i < actualProfileNames.length; i++) {
- assertEquals(expectedProfileNames[i], actualProfileNames[i]);
- }
- mProfileManager.resetAll();
- }
-
- @SmallTest
- public void testGetProfiles() {
- ensureProfilesEnabled();
- Profile[] expectedProfiles = new Profile[5];
- // These defaults are pulled from the default xml in the lineage platform resource package
- Profile expectedProfile1 = mProfileManager.getProfile(
- UUID.fromString("6a181391-12ef-4f43-a701-32b11ed69449"));
- Profile expectedProfile2 = mProfileManager.getProfile(
- UUID.fromString("0230226d-0d05-494a-a9bd-d222a1117655"));
- Profile expectedProfile3 = mProfileManager.getProfile(
- UUID.fromString("e4e77d03-82ce-4417-9257-7d6c9ffb8fd1"));
-
- // Add extras
- Profile expectedProfile4 = new Profile("PROFILE 1");
- Profile expectedProfile5 = new Profile("PROFILE 2");
-
- expectedProfiles[0] = expectedProfile1;
- expectedProfiles[1] = expectedProfile2;
- expectedProfiles[2] = expectedProfile3;
- expectedProfiles[3] = expectedProfile4;
- expectedProfiles[4] = expectedProfile5;
-
- // The actual results come back in alphabetical order, :/
- Arrays.sort(expectedProfiles);
-
- mProfileManager.addProfile(expectedProfile4);
- mProfileManager.addProfile(expectedProfile5);
-
- Profile[] actualProfiles = mProfileManager.getProfiles();
- for (int i = 0; i < actualProfiles.length; i++) {
- assertEquals(expectedProfiles[i].getName(), actualProfiles[i].getName());
- }
- mProfileManager.resetAll();
- }
-
- @SmallTest
- public void testProfileExists() {
- ensureProfilesEnabled();
- assertTrue(mProfileManager.profileExists(
- UUID.fromString("6a181391-12ef-4f43-a701-32b11ed69449")));
- assertTrue(mProfileManager.profileExists(
- UUID.fromString("0230226d-0d05-494a-a9bd-d222a1117655")));
- assertTrue(mProfileManager.profileExists(
- UUID.fromString("e4e77d03-82ce-4417-9257-7d6c9ffb8fd1")));
- String expectedProfileName = "PROFILE 1";
- Profile expectedProfile = new Profile(expectedProfileName);
- mProfileManager.addProfile(expectedProfile);
- assertTrue(mProfileManager.profileExists(expectedProfileName));
- mProfileManager.resetAll();
- }
-
- @SmallTest
- public void testUpdateProfile() {
- ensureProfilesEnabled();
- String originalProfileName = "PROFILE 1";
- String expectedProfileName = "PROFILE 2";
- Profile expectedProfile = new Profile(originalProfileName);
- mProfileManager.addProfile(expectedProfile);
- expectedProfile.setName(expectedProfileName);
- mProfileManager.updateProfile(expectedProfile);
- assertNotSame(originalProfileName, expectedProfile.getName());
- assertEquals(expectedProfileName, expectedProfile.getName());
- mProfileManager.resetAll();
- }
-}
diff --git a/tests/src/org/lineageos/tests/profiles/unit/ProfileTest.java b/tests/src/org/lineageos/tests/profiles/unit/ProfileTest.java
deleted file mode 100644
index c1fefdac..00000000
--- a/tests/src/org/lineageos/tests/profiles/unit/ProfileTest.java
+++ /dev/null
@@ -1,532 +0,0 @@
-/**
- * Copyright (C) 2015 The CyanogenMod Project
- * 2020 The LineageOS 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.lineageos.tests.profiles.unit;
-
-import android.media.AudioManager;
-import android.os.Parcel;
-import android.test.AndroidTestCase;
-
-import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import lineageos.app.LineageContextConstants;
-import lineageos.app.Profile;
-import lineageos.profiles.AirplaneModeSettings;
-import lineageos.profiles.BrightnessSettings;
-import lineageos.profiles.ConnectionSettings;
-import lineageos.profiles.LockSettings;
-import lineageos.profiles.RingModeSettings;
-import lineageos.profiles.StreamSettings;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
-
-public class ProfileTest extends AndroidTestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // Only run this if we support profiles service
- org.junit.Assume.assumeTrue(mContext.getPackageManager().hasSystemFeature(
- LineageContextConstants.Features.PROFILES));
- }
-
- @MediumTest
- public void testProfileConnectionSettingsUnravelFromParcel() {
- Profile profile = new Profile("Connection Profile");
- ConnectionSettings expectedConnectionSettings =
- new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_LOCATION,
- ConnectionSettings.BooleanState.STATE_DISABLED, true);
- profile.setConnectionSettings(expectedConnectionSettings);
-
- // Write to parcel
- Parcel parcel = Parcel.obtain();
- profile.writeToParcel(parcel, 0);
-
- // Rewind
- parcel.setDataPosition(0);
-
- // Verify data when unraveling
- Profile fromParcel = Profile.CREATOR.createFromParcel(parcel);
-
- assertNotNull(fromParcel);
- ConnectionSettings actualConnectionSettings = fromParcel.getSettingsForConnection(
- expectedConnectionSettings.getConnectionId());
-
- assertEquals(expectedConnectionSettings.getConnectionId(),
- actualConnectionSettings.getConnectionId());
- assertEquals(expectedConnectionSettings.getValue(),
- actualConnectionSettings.getValue());
- assertEquals(expectedConnectionSettings.isDirty(),
- actualConnectionSettings.isDirty());
- assertEquals(expectedConnectionSettings.isOverride(),
- actualConnectionSettings.isOverride());
- }
-
- @MediumTest
- public void testProfileAirplaneModeSettingsUnravelFromParcel() {
- Profile profile = new Profile("AirplaneMode Profile");
- AirplaneModeSettings expectedAirplaneModeSettings =
- new AirplaneModeSettings(AirplaneModeSettings.BooleanState.STATE_ENABLED, true);
- profile.setAirplaneMode(expectedAirplaneModeSettings);
-
- // Write to parcel
- Parcel parcel = Parcel.obtain();
- profile.writeToParcel(parcel, 0);
-
- // Rewind
- parcel.setDataPosition(0);
-
- // Verify data when unraveling
- Profile fromParcel = Profile.CREATOR.createFromParcel(parcel);
-
- assertNotNull(fromParcel);
- AirplaneModeSettings actualAirplaneModeSettings = fromParcel.getAirplaneMode();
-
- assertEquals(expectedAirplaneModeSettings.getValue(),
- actualAirplaneModeSettings.getValue());
- assertEquals(expectedAirplaneModeSettings.isDirty(),
- actualAirplaneModeSettings.isDirty());
- assertEquals(expectedAirplaneModeSettings.isOverride(),
- expectedAirplaneModeSettings.isOverride());
- }
-
- @MediumTest
- public void testProfileBrightnessSettingsUnravelFromParcel() {
- Profile profile = new Profile("Brightness Profile");
- BrightnessSettings expectedBrightnessSettings = new BrightnessSettings(0, true);
- profile.setBrightness(expectedBrightnessSettings);
-
- // Write to parcel
- Parcel parcel = Parcel.obtain();
- profile.writeToParcel(parcel, 0);
-
- // Rewind
- parcel.setDataPosition(0);
-
- // Verify data when unraveling
- Profile fromParcel = Profile.CREATOR.createFromParcel(parcel);
-
- assertNotNull(fromParcel);
- BrightnessSettings actualBrightnessSettings = fromParcel.getBrightness();
-
- assertEquals(expectedBrightnessSettings.getValue(), actualBrightnessSettings.getValue());
- assertEquals(expectedBrightnessSettings.isOverride(),
- actualBrightnessSettings.isOverride());
- assertEquals(expectedBrightnessSettings.isDirty(), actualBrightnessSettings.isDirty());
- }
-
- @MediumTest
- public void testProfileRingmodeSettingsUnravelFromParcel() {
- Profile profile = new Profile("Ringmode Profile");
- RingModeSettings expectedRingModeSettings =
- new RingModeSettings(RingModeSettings.RING_MODE_MUTE, true);
- profile.setRingMode(expectedRingModeSettings);
-
- // Write to parcel
- Parcel parcel = Parcel.obtain();
- profile.writeToParcel(parcel, 0);
-
- // Rewind
- parcel.setDataPosition(0);
-
- // Verify data when unraveling
- Profile fromParcel = Profile.CREATOR.createFromParcel(parcel);
-
- RingModeSettings actualRingModeSettings = fromParcel.getRingMode();
-
- assertNotNull(fromParcel);
- assertEquals(expectedRingModeSettings.getValue(), actualRingModeSettings.getValue());
- assertEquals(expectedRingModeSettings.isDirty(), actualRingModeSettings.isDirty());
- assertEquals(expectedRingModeSettings.isOverride(), actualRingModeSettings.isOverride());
- }
-
- @MediumTest
- public void testProfileStreamSettingsUnravelFromParcel() {
- Profile profile = new Profile("Stream Profile");
- StreamSettings expectedStreamSettings =
- new StreamSettings(AudioManager.STREAM_RING, 0, true);
- profile.setStreamSettings(expectedStreamSettings);
-
- // Write to parcel
- Parcel parcel = Parcel.obtain();
- profile.writeToParcel(parcel, 0);
-
- // Rewind
- parcel.setDataPosition(0);
-
- // Verify data when unraveling
- Profile fromParcel = Profile.CREATOR.createFromParcel(parcel);
-
- StreamSettings actualStreamSettings = fromParcel.getSettingsForStream(
- expectedStreamSettings.getStreamId());
-
- assertNotNull(fromParcel);
- assertEquals(expectedStreamSettings.getValue(), actualStreamSettings.getValue());
- assertEquals(expectedStreamSettings.isOverride(), actualStreamSettings.isOverride());
- assertEquals(expectedStreamSettings.isDirty(), actualStreamSettings.isDirty());
- }
-
- @MediumTest
- public void testProfileLockSettingsUnravelFromParcel() {
- Profile profile = new Profile("Lock Profile");
- LockSettings expectedLockSettings = new LockSettings(Profile.LockMode.INSECURE);
- profile.setScreenLockMode(expectedLockSettings);
-
- // Write to parcel
- Parcel parcel = Parcel.obtain();
- profile.writeToParcel(parcel, 0);
-
- // Rewind
- parcel.setDataPosition(0);
-
- // Verify data when unraveling
- Profile fromParcel = Profile.CREATOR.createFromParcel(parcel);
-
- LockSettings actualLockSettings = fromParcel.getScreenLockMode();
-
- assertNotNull(fromParcel);
- assertEquals(expectedLockSettings.getValue(), actualLockSettings.getValue());
- assertEquals(expectedLockSettings.isDirty(), actualLockSettings.isDirty());
- }
-
- @MediumTest
- public void testProfileUnravelFromParcel() {
- Profile profile = new Profile("Single Profile");
- profile.setProfileType(Profile.Type.TOGGLE);
- profile.setDozeMode(Profile.DozeMode.ENABLE);
- profile.setStatusBarIndicator(true);
-
- // Write to parcel
- Parcel parcel = Parcel.obtain();
- profile.writeToParcel(parcel, 0);
-
- // Rewind
- parcel.setDataPosition(0);
-
- // Verify data when unraveling
- Profile fromParcel = Profile.CREATOR.createFromParcel(parcel);
-
- assertNotNull(fromParcel);
- assertEquals(profile.getName(), fromParcel.getName());
- assertEquals(profile.getProfileType(), fromParcel.getProfileType());
- assertEquals(profile.getDozeMode(), fromParcel.getDozeMode());
- assertEquals(profile.getStatusBarIndicator(), fromParcel.getStatusBarIndicator());
- }
-
- private static final int EXPECTED_PROFILE_TRIGGER_TYPE = Profile.TriggerType.WIFI;
- private static final String EXPECTED_PROFILE_TRIGGER_ID = "1337";
- private static final int EXPECTED_PROFILE_TRIGGER_STATE = Profile.TriggerState.ON_CONNECT;
- private static final String EXPECTED_PROFILE_TRIGGER_NAME = "ON_CONNECT_WIFI_TRIGGER";
- private Profile.ProfileTrigger createSampleProfileTrigger() {
- return new Profile.ProfileTrigger(EXPECTED_PROFILE_TRIGGER_TYPE,
- EXPECTED_PROFILE_TRIGGER_ID, EXPECTED_PROFILE_TRIGGER_STATE,
- EXPECTED_PROFILE_TRIGGER_NAME);
- }
-
- @SmallTest
- public void testProfileTriggerId() {
- Profile.ProfileTrigger profileTrigger = createSampleProfileTrigger();
- assertEquals(EXPECTED_PROFILE_TRIGGER_ID, profileTrigger.getId());
- }
-
- @SmallTest
- public void testProfileTriggerName() {
- Profile.ProfileTrigger profileTrigger = createSampleProfileTrigger();
- assertEquals(EXPECTED_PROFILE_TRIGGER_NAME, profileTrigger.getName());
- }
-
- @SmallTest
- public void testProfileTriggerState() {
- Profile.ProfileTrigger profileTrigger = createSampleProfileTrigger();
- assertEquals(EXPECTED_PROFILE_TRIGGER_STATE, profileTrigger.getState());
- }
-
- @SmallTest
- public void testProfileTriggerType() {
- Profile.ProfileTrigger profileTrigger = createSampleProfileTrigger();
- assertEquals(EXPECTED_PROFILE_TRIGGER_STATE, profileTrigger.getType());
- }
-
- @SmallTest
- public void testProfileConstructor() {
- String expectedName = "PROFILE_NAME";
- Profile profile = new Profile(expectedName);
- assertEquals(expectedName, profile.getName());
- }
-
- @SmallTest
- public void testProfileAddSecondaryUuid() {
- UUID[] expectedUUIDs = new UUID[2];
- UUID expectedUUID1 = UUID.randomUUID();
- UUID expectedUUID2 = UUID.randomUUID();
- expectedUUIDs[0] = expectedUUID1;
- expectedUUIDs[1] = expectedUUID2;
-
- Profile profile = new Profile("Single Profile");
- profile.addSecondaryUuid(expectedUUID1);
- profile.addSecondaryUuid(expectedUUID2);
-
- UUID[] actualUUIDs = profile.getSecondaryUuids();
- for (int i = 0; i < actualUUIDs.length; i++) {
- assertEquals(actualUUIDs[i], expectedUUIDs[i]);
- }
-
- profile.setSecondaryUuids(Arrays.asList(expectedUUIDs));
- for (int i = 0; i < actualUUIDs.length; i++) {
- assertEquals(actualUUIDs[i], expectedUUIDs[i]);
- }
- }
-
- @SmallTest
- public void testProfileGetAirplaneMode() {
- Profile profile = new Profile("AirplaneMode Profile");
- AirplaneModeSettings expectedAirplaneModeSettings =
- new AirplaneModeSettings(AirplaneModeSettings.BooleanState.STATE_ENABLED, true);
- profile.setAirplaneMode(expectedAirplaneModeSettings);
-
- AirplaneModeSettings actualAirplaneModeSettings = profile.getAirplaneMode();
- assertEquals(expectedAirplaneModeSettings.getValue(),
- actualAirplaneModeSettings.getValue());
- assertEquals(expectedAirplaneModeSettings.isOverride(),
- actualAirplaneModeSettings.isOverride());
- }
-
- @SmallTest
- public void testProfileGetBrightness() {
- Profile profile = new Profile("Brightness Profile");
- BrightnessSettings expectedBrightnessSettings = new BrightnessSettings(0, true);
- profile.setBrightness(expectedBrightnessSettings);
-
- BrightnessSettings actualBrightnessSettings = profile.getBrightness();
- assertEquals(expectedBrightnessSettings.getValue(), actualBrightnessSettings.getValue());
- assertEquals(expectedBrightnessSettings.isOverride(), actualBrightnessSettings.isOverride());
- }
-
- @SmallTest
- public void testProfileGetConnectionSettingsWithSubId() {
- int targetSubId = 0;
- Profile profile = new Profile("Connection Sub Id Profile");
- ConnectionSettings expectedConnectionSettings = new ConnectionSettings(
- ConnectionSettings.PROFILE_CONNECTION_2G3G4G,
- ConnectionSettings.BooleanState.STATE_ENABLED, true);
- expectedConnectionSettings.setSubId(targetSubId);
- profile.setConnectionSettings(expectedConnectionSettings);
-
- ConnectionSettings actualConnectionSettings =
- profile.getConnectionSettingWithSubId(targetSubId);
- assertEquals(expectedConnectionSettings.getConnectionId(),
- actualConnectionSettings.getConnectionId());
- assertEquals(expectedConnectionSettings.getValue(), actualConnectionSettings.getValue());
- assertEquals(expectedConnectionSettings.isOverride(),
- actualConnectionSettings.isOverride());
- }
-
- @SmallTest
- public void testProfileGetConnectionSettings() {
- Profile profile = new Profile("Connection Profile");
-
- ConnectionSettings expectedConnectionSettings1 = new ConnectionSettings(
- ConnectionSettings.PROFILE_CONNECTION_2G3G4G,
- ConnectionSettings.BooleanState.STATE_ENABLED, true);
- profile.setConnectionSettings(expectedConnectionSettings1);
- ConnectionSettings expectedConnectionSettings2 = new ConnectionSettings(
- ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH,
- ConnectionSettings.BooleanState.STATE_DISABLED, false);
- profile.setConnectionSettings(expectedConnectionSettings2);
-
- List expectedConnectionSettings = new ArrayList<>();
- // inverted because the backing structure does it this way :/
- expectedConnectionSettings.add(expectedConnectionSettings2);
- expectedConnectionSettings.add(expectedConnectionSettings1);
-
- List actualConnectionSettings = new ArrayList<>(
- profile.getConnectionSettings());
- for (int i = 0; i < actualConnectionSettings.size(); i++) {
- ConnectionSettings expectedConnectionSetting = expectedConnectionSettings.get(i);
- ConnectionSettings actualConnectionSetting = actualConnectionSettings.get(i);
- assertEquals(expectedConnectionSetting.getConnectionId(),
- actualConnectionSetting.getConnectionId());
- assertEquals(expectedConnectionSetting.getValue(), actualConnectionSetting.getValue());
- assertEquals(expectedConnectionSetting.isOverride(),
- actualConnectionSetting.isOverride());
- }
- }
-
- @SmallTest
- public void testProfileGetDozeMode() {
- int expectedDozeMode = Profile.DozeMode.ENABLE;
- Profile profile = new Profile("Doze Mode Profile");
- profile.setDozeMode(expectedDozeMode);
- assertEquals(expectedDozeMode, profile.getDozeMode());
- }
-
- @SmallTest
- public void testProfileGetNotificationLightMode() {
- int expectedNotificationLightMode = Profile.NotificationLightMode.ENABLE;
- Profile profile = new Profile("Notification Light Mode Profile");
- profile.setNotificationLightMode(expectedNotificationLightMode);
- assertEquals(expectedNotificationLightMode, profile.getNotificationLightMode());
- }
-
- @SmallTest
- public void testProfileGetProfileType() {
- int expectedProfileType = Profile.Type.CONDITIONAL;
- Profile profile = new Profile("Profile Type Profile");
- profile.setProfileType(expectedProfileType);
- assertEquals(expectedProfileType, profile.getProfileType());
- }
-
- @SmallTest
- public void testProfileGetRingMode() {
- Profile profile = new Profile("Ringmode Profile");
- RingModeSettings expectedRingModeSettings =
- new RingModeSettings(RingModeSettings.RING_MODE_MUTE, true);
- profile.setRingMode(expectedRingModeSettings);
-
- RingModeSettings actualRingModeSettings = profile.getRingMode();
- assertEquals(expectedRingModeSettings.getValue(), actualRingModeSettings.getValue());
- assertEquals(expectedRingModeSettings.isDirty(), actualRingModeSettings.isDirty());
- assertEquals(expectedRingModeSettings.isOverride(), actualRingModeSettings.isOverride());
- }
-
- @SmallTest
- public void testProfileGetLockScreenMode() {
- Profile profile = new Profile("Lock Profile");
- LockSettings expectedLockSettings = new LockSettings(Profile.LockMode.INSECURE);
- profile.setScreenLockMode(expectedLockSettings);
-
- LockSettings actualLockSettings = profile.getScreenLockMode();
- assertEquals(expectedLockSettings.getValue(), actualLockSettings.getValue());
- assertEquals(expectedLockSettings.isDirty(), actualLockSettings.isDirty());
- }
-
- @SmallTest
- public void testProfileGetSettingForConnection() {
- Profile profile = new Profile("Connection Profile");
- ConnectionSettings expectedConnectionSettings = new ConnectionSettings(
- ConnectionSettings.PROFILE_CONNECTION_2G3G4G,
- ConnectionSettings.BooleanState.STATE_ENABLED, true);
- profile.setConnectionSettings(expectedConnectionSettings);
-
- ConnectionSettings actualConnectionSettings =
- profile.getSettingsForConnection(ConnectionSettings.PROFILE_CONNECTION_2G3G4G);
- assertEquals(expectedConnectionSettings.getConnectionId(),
- actualConnectionSettings.getConnectionId());
- assertEquals(expectedConnectionSettings.getValue(), actualConnectionSettings.getValue());
- assertEquals(expectedConnectionSettings.isOverride(),
- actualConnectionSettings.isOverride());
- }
-
- @SmallTest
- public void testProfileGetSettingForStream() {
- Profile profile = new Profile("Stream Profile");
- StreamSettings expectedStreamSettings =
- new StreamSettings(AudioManager.STREAM_RING, 0, true);
- profile.setStreamSettings(expectedStreamSettings);
-
- StreamSettings actualStreamSettings = profile.getSettingsForStream(
- expectedStreamSettings.getStreamId());
-
- assertEquals(expectedStreamSettings.getValue(), actualStreamSettings.getValue());
- assertEquals(expectedStreamSettings.isOverride(), actualStreamSettings.isOverride());
- assertEquals(expectedStreamSettings.isDirty(), actualStreamSettings.isDirty());
- }
-
- @SmallTest
- public void testProfileGetStreamSettings() {
- Profile profile = new Profile("Stream Profile");
- StreamSettings expectedStreamSettings1 =
- new StreamSettings(AudioManager.STREAM_RING, 0, true);
- profile.setStreamSettings(expectedStreamSettings1);
- StreamSettings expectedStreamSettings2 =
- new StreamSettings(AudioManager.STREAM_RING, 0, true);
- profile.setStreamSettings(expectedStreamSettings2);
-
- List expectedStreamSettings = new ArrayList<>();
- expectedStreamSettings.add(expectedStreamSettings1);
- expectedStreamSettings.add(expectedStreamSettings2);
-
- List actualStreamSettings = new ArrayList<>(
- profile.getStreamSettings());
-
- for (int i = 0; i < actualStreamSettings.size(); i++) {
- StreamSettings expectedStreamSetting = actualStreamSettings.get(i);
- StreamSettings actualStreamSetting = actualStreamSettings.get(i);
- assertEquals(expectedStreamSetting.getStreamId(),
- actualStreamSetting.getStreamId());
- assertEquals(expectedStreamSetting.getValue(), actualStreamSetting.getValue());
- assertEquals(expectedStreamSetting.isOverride(),
- actualStreamSetting.isOverride());
- }
- }
-
- @SmallTest
- public void testProfileGetTriggerState() {
- Profile profile = new Profile("ProfileTrigger Profile");
- Profile.ProfileTrigger profileTrigger = createSampleProfileTrigger();
- profile.setTrigger(profileTrigger);
- assertEquals(EXPECTED_PROFILE_TRIGGER_STATE,
- profile.getTriggerState(EXPECTED_PROFILE_TRIGGER_TYPE,
- EXPECTED_PROFILE_TRIGGER_ID));
- }
-
- @SmallTest
- public void testProfileGetTriggersFromType() {
- Profile profile = new Profile("ProfileTrigger Profile");
- Profile.ProfileTrigger profileTrigger1 = createSampleProfileTrigger();
- Profile.ProfileTrigger profileTrigger2 = createSampleProfileTrigger();
- profile.setTrigger(profileTrigger1);
- profile.setTrigger(profileTrigger2);
-
- List expectedProfileTriggers = new ArrayList<>();
- expectedProfileTriggers.add(profileTrigger1);
- expectedProfileTriggers.add(profileTrigger2);
-
- List actualProfileTriggers = new ArrayList<>(
- profile.getTriggersFromType(EXPECTED_PROFILE_TRIGGER_TYPE));
-
- for (int i = 0; i < actualProfileTriggers.size(); i++) {
- Profile.ProfileTrigger expectedProfileTrigger = expectedProfileTriggers.get(i);
- Profile.ProfileTrigger actualProfileTrigger = expectedProfileTriggers.get(i);
- assertEquals(expectedProfileTrigger.getId(), actualProfileTrigger.getId());
- assertEquals(expectedProfileTrigger.getName(), actualProfileTrigger.getName());
- assertEquals(expectedProfileTrigger.getState(), actualProfileTrigger.getState());
- assertEquals(expectedProfileTrigger.getType(), actualProfileTrigger.getType());
- }
- }
-
- @SmallTest
- public void testProfileIsConditionalType() {
- Profile profile = new Profile("Mutable Profile");
- profile.setProfileType(Profile.Type.TOGGLE);
- assertFalse(profile.isConditionalType());
- profile.setProfileType(Profile.Type.CONDITIONAL);
- assertTrue(profile.isConditionalType());
- }
-
- @SmallTest
- public void testProfileSetName() {
- String expectedProfileName = "MUTABLE Profile";
- Profile profile = new Profile("Mutable Profile");
- profile.setName(expectedProfileName);
- assertEquals(expectedProfileName, profile.getName());
- }
-}
diff --git a/tests/src/org/lineageos/tests/profiles/unit/RingModeSettingsTest.java b/tests/src/org/lineageos/tests/profiles/unit/RingModeSettingsTest.java
deleted file mode 100644
index 4c1bfd6e..00000000
--- a/tests/src/org/lineageos/tests/profiles/unit/RingModeSettingsTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * Copyright (c) 2016, 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.lineageos.tests.profiles.unit;
-
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import lineageos.profiles.RingModeSettings;
-
-public class RingModeSettingsTest extends AndroidTestCase {
-
- @SmallTest
- public void testConstructWholly() {
- RingModeSettings ringSettings = new RingModeSettings(
- RingModeSettings.RING_MODE_MUTE, true);
- assertEquals(RingModeSettings.RING_MODE_MUTE, ringSettings.getValue());
- assertEquals(true, ringSettings.isOverride());
- }
-
- @SmallTest
- public void testVerifyOverride() {
- RingModeSettings ringSettings = new RingModeSettings(
- RingModeSettings.RING_MODE_MUTE, true);
- ringSettings.setOverride(false);
- assertEquals(false, ringSettings.isOverride());
- }
-
- @SmallTest
- public void testVerifyValue() {
- String expectedValue = RingModeSettings.RING_MODE_NORMAL;
- RingModeSettings ringSettings = new RingModeSettings(
- RingModeSettings.RING_MODE_MUTE, true);
- ringSettings.setValue(expectedValue);
- assertEquals(expectedValue, ringSettings.getValue());
- }
-}
diff --git a/tests/src/org/lineageos/tests/profiles/unit/StreamSettingsTest.java b/tests/src/org/lineageos/tests/profiles/unit/StreamSettingsTest.java
deleted file mode 100644
index 783d293e..00000000
--- a/tests/src/org/lineageos/tests/profiles/unit/StreamSettingsTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright (c) 2016, 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.lineageos.tests.profiles.unit;
-
-import android.media.AudioManager;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import lineageos.profiles.StreamSettings;
-
-public class StreamSettingsTest extends AndroidTestCase {
-
- @SmallTest
- public void testConstructManually() {
- StreamSettings streamSettings =
- new StreamSettings(AudioManager.STREAM_RING);
- assertEquals(AudioManager.STREAM_RING, streamSettings.getStreamId());
- }
-
- @SmallTest
- public void testConstructWholly() {
- StreamSettings streamSettings =
- new StreamSettings(AudioManager.STREAM_RING, 0, true);
- assertEquals(AudioManager.STREAM_RING, streamSettings.getStreamId());
- assertEquals(0, streamSettings.getValue());
- assertEquals(true, streamSettings.isOverride());
- }
-
- @SmallTest
- public void testVerifyOverride() {
- StreamSettings streamSettings =
- new StreamSettings(AudioManager.STREAM_RING);
- streamSettings.setOverride(true);
- assertEquals(true, streamSettings.isOverride());
- }
-
- @SmallTest
- public void testVerifyValue() {
- int expectedValue = AudioManager.STREAM_ALARM;
- StreamSettings streamSettings =
- new StreamSettings(AudioManager.STREAM_RING);
- streamSettings.setValue(expectedValue);
- assertEquals(expectedValue, streamSettings.getValue());
- }
-}
diff --git a/tests/src/org/lineageos/tests/providers/LineageSettingsTest.java b/tests/src/org/lineageos/tests/providers/LineageSettingsTest.java
deleted file mode 100644
index d928a2df..00000000
--- a/tests/src/org/lineageos/tests/providers/LineageSettingsTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/**
- * 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.lineageos.tests.providers;
-
-import android.content.ContentResolver;
-import android.database.ContentObserver;
-import android.net.Uri;
-import android.os.Handler;
-import android.os.UserHandle;
-import android.provider.Settings;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import lineageos.providers.LineageSettings;
-
-public class LineageSettingsTest extends AndroidTestCase{
- private ContentResolver mContentResolver;
- private LineageSettingsTestObserver mTestObserver;
-
- private static boolean sIsOnChangedCalled = false;
- private static Uri sExpectedUriChange = null;
-
- @Override
- public void setUp() {
- mContentResolver = getContext().getContentResolver();
- mTestObserver = new LineageSettingsTestObserver(null);
- }
-
- @Override
- public void tearDown() {
- mContentResolver.unregisterContentObserver(mTestObserver);
- }
-
- @MediumTest
- public void testPutAndGetSystemString() {
- final String key = LineageSettings.System.__MAGICAL_TEST_PASSING_ENABLER;
-
- // put
- final String expectedValue = "1";
- boolean isPutSuccessful = LineageSettings.System.putString(mContentResolver, key, expectedValue);
- assertTrue(isPutSuccessful);
-
- // get
- String actualValue = LineageSettings.System.getString(mContentResolver, key);
- assertEquals(expectedValue, actualValue);
-
- // setup observer
- sIsOnChangedCalled = false;
- sExpectedUriChange = LineageSettings.System.getUriFor(key);
- mContentResolver.registerContentObserver(sExpectedUriChange, false, mTestObserver,
- UserHandle.USER_ALL);
-
- // replace
- final String expectedReplaceValue = "0";
- isPutSuccessful = LineageSettings.System.putString(mContentResolver, key, expectedReplaceValue);
- assertTrue(isPutSuccessful);
-
- // get
- actualValue = LineageSettings.System.getString(mContentResolver, key);
- assertEquals(expectedReplaceValue, actualValue);
-
- // delete to clean up
- int rowsAffected = mContentResolver.delete(LineageSettings.System.CONTENT_URI,
- Settings.NameValueTable.NAME + " = ?", new String[]{ key });
- assertEquals(1, rowsAffected);
-
- if (!sIsOnChangedCalled) {
- fail("On change was never called or was called with the wrong uri");
- }
- }
-
- @MediumTest
- public void testPutAndGetSecureString() {
- /* TODO: FIXME
- final String key = LineageSettings.Secure.__MAGICAL_TEST_PASSING_ENABLER;
-
- // put
- final String expectedValue = "0";
- boolean isPutSuccessful = LineageSettings.Secure.putString(mContentResolver, key, expectedValue);
- assertTrue(isPutSuccessful);
-
- // get
- String actualValue = LineageSettings.Secure.getString(mContentResolver, key);
- assertEquals(expectedValue, actualValue);
-
- // setup observer
- sIsOnChangedCalled = false;
- sExpectedUriChange = LineageSettings.Secure.getUriFor(key);
- mContentResolver.registerContentObserver(sExpectedUriChange, false, mTestObserver,
- UserHandle.USER_ALL);
-
- // replace
- final String expectedReplaceValue = "1";
- isPutSuccessful = LineageSettings.Secure.putString(mContentResolver, key, expectedReplaceValue);
- assertTrue(isPutSuccessful);
-
- // get
- actualValue = LineageSettings.Secure.getString(mContentResolver, key);
- assertEquals(expectedReplaceValue, actualValue);
-
- // delete to clean up
- int rowsAffected = mContentResolver.delete(LineageSettings.Secure.CONTENT_URI,
- Settings.NameValueTable.NAME + " = ?", new String[]{ key });
- assertEquals(1, rowsAffected);
-
- if (!sIsOnChangedCalled) {
- fail("On change was never called or was called with the wrong uri");
- } */
- }
-
- @MediumTest
- public void testPutAndGetGlobalString() {
- final String key = "key";
-
- // put
- final String expectedValue = "globalTestValue1";
- boolean isPutSuccessful = LineageSettings.Global.putString(mContentResolver, key, expectedValue);
- assertTrue(isPutSuccessful);
-
- // get
- String actualValue = LineageSettings.Global.getString(mContentResolver, key);
- assertEquals(expectedValue, actualValue);
-
- // setup observer
- sIsOnChangedCalled = false;
- sExpectedUriChange = LineageSettings.Global.getUriFor(key);
- mContentResolver.registerContentObserver(sExpectedUriChange, false, mTestObserver,
- UserHandle.USER_SYSTEM);
-
- // replace
- final String expectedReplaceValue = "globalTestValue2";
- isPutSuccessful = LineageSettings.Global.putString(mContentResolver, key, expectedReplaceValue);
- assertTrue(isPutSuccessful);
-
- // get
- actualValue = LineageSettings.Global.getString(mContentResolver, key);
- assertEquals(expectedReplaceValue, actualValue);
-
- // delete to clean up
- int rowsAffected = mContentResolver.delete(LineageSettings.Global.CONTENT_URI,
- Settings.NameValueTable.NAME + " = ?", new String[]{ key });
- assertEquals(1, rowsAffected);
-
- if (!sIsOnChangedCalled) {
- fail("On change was never called or was called with the wrong uri");
- }
- }
-
- private class LineageSettingsTestObserver extends ContentObserver {
-
- public LineageSettingsTestObserver(Handler handler) {
- super(handler);
- }
-
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- if (sExpectedUriChange.equals(uri)) {
- sIsOnChangedCalled = true;
- }
- }
- }
-
- // TODO Add tests for other users
-}
diff --git a/tests/src/org/lineageos/tests/util/ColorUtilTest.java b/tests/src/org/lineageos/tests/util/ColorUtilTest.java
deleted file mode 100644
index 9ce91f96..00000000
--- a/tests/src/org/lineageos/tests/util/ColorUtilTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * Copyright (c) 2016, 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.lineageos.tests.util;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.ColorDrawable;
-import android.test.AndroidTestCase;
-import lineageos.util.ColorUtils;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-public class ColorUtilTest extends AndroidTestCase {
- private ColorUtils mColorUtils;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mColorUtils = new ColorUtils();
- }
-
- public void testDropAlpha() {
- // With pre-existing alpha
- int color = 0xBBCCDD;
- int alpha = 0xAA000000;
- int result = mColorUtils.dropAlpha(color | alpha);
- // Assert alpha was removed
- assertEquals(Color.alpha(result), 0);
- // Ensure color is preserved
- assertEquals(result & color, color);
-
- // Without pre-existing alpha
- color = Color.argb(0, 100, 200 ,300);
- result = mColorUtils.dropAlpha(color);
- // Assert alpha was removed
- assertEquals(Color.alpha(result), 0);
- // Ensure color is preserved
- assertEquals(result, color);
- }
-
- public void testGenerateAlertColorFromDrawable() {
- // Test null drawable
- int color = mColorUtils.generateAlertColorFromDrawable(null);
- assertEquals(color, Color.BLACK);
-
- Bitmap bitmap = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
- BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);
- bitmapDrawable.setBounds(0, 0, 10, 10);
- Canvas canvas = new Canvas(bitmap);
- canvas.drawColor(Color.RED);
-
- // Test fully red bitmap
- color = mColorUtils.generateAlertColorFromDrawable(bitmapDrawable);
- assertEquals(color, Color.RED);
- color = mColorUtils.generateAlertColorFromDrawable(
- getColorDrawableFromBitmapDrawable(bitmapDrawable));
- assertEquals(color, Color.RED);
-
- // Test blue/red bitmap with blue dominating
- Paint p = new Paint();
- p.setColor(Color.BLUE);
- p.setStyle(Paint.Style.FILL_AND_STROKE);
- canvas.drawRect(0, 0, 8, 8, p);
- color = mColorUtils.generateAlertColorFromDrawable(bitmapDrawable);
- assertEquals(color, Color.BLUE);
- color = mColorUtils.generateAlertColorFromDrawable(
- getColorDrawableFromBitmapDrawable(bitmapDrawable));
- assertEquals(color, Color.BLUE);
-
- // Test large white + small blue scenario
- canvas.drawColor(Color.WHITE);
- canvas.drawRect(0, 0, 2, 2, p);
- color = mColorUtils.generateAlertColorFromDrawable(bitmapDrawable);
- assertEquals(color, Color.BLUE);
- color = mColorUtils.generateAlertColorFromDrawable(
- getColorDrawableFromBitmapDrawable(bitmapDrawable));
- assertEquals(color, Color.BLUE);
-
- // Test large white + small black scenario
- canvas.drawColor(Color.WHITE);
- p.setColor(Color.BLACK);
- canvas.drawRect(0, 0, 2, 2, p);
- color = mColorUtils.generateAlertColorFromDrawable(bitmapDrawable);
- assertEquals(color, Color.WHITE);
- color = mColorUtils.generateAlertColorFromDrawable(
- getColorDrawableFromBitmapDrawable(bitmapDrawable));
- assertEquals(color, Color.WHITE);
-
- assertEquals(bitmap.isRecycled(), false);
- bitmap.recycle();
- }
-
- private ColorDrawable getColorDrawableFromBitmapDrawable(final BitmapDrawable bitmapDrawable) {
- ColorDrawable colorDrawable = Mockito.mock(ColorDrawable.class);
- Mockito.doAnswer(new Answer() {
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- Canvas canvas = (Canvas) invocation.getArguments()[0];
- bitmapDrawable.draw(canvas);
- return null;
- }
- }).when(colorDrawable).draw(Mockito.any(Canvas.class));
- return colorDrawable;
- }
-}
diff --git a/tests/src/org/lineageos/tests/versioning/VersioningTest.java b/tests/src/org/lineageos/tests/versioning/VersioningTest.java
deleted file mode 100644
index 9cbf2752..00000000
--- a/tests/src/org/lineageos/tests/versioning/VersioningTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * 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.lineageos.tests.versioning;
-
-import android.widget.Toast;
-import lineageos.os.Build;
-
-import org.lineageos.tests.TestActivity;
-
-public class VersioningTest extends TestActivity {
- @Override
- protected String tag() {
- return null;
- }
-
- @Override
- protected Test[] tests() {
- return mTests;
- }
-
- private Test[] mTests = new Test[] {
- new Test("test retrieve version") {
- public void run() {
- Toast.makeText(VersioningTest.this,
- "Current API version is " + Build.LINEAGE_VERSION.SDK_INT + " which is "
- + Build.getNameForSDKInt(Build.LINEAGE_VERSION.SDK_INT),
- Toast.LENGTH_SHORT).show();
- }
- },
- new Test("test target version larger") {
- public void run() {
- int currentapiVersion = Build.LINEAGE_VERSION.SDK_INT;
- if (currentapiVersion >= Build.LINEAGE_VERSION_CODES.APRICOT){
- Toast.makeText(VersioningTest.this,
- "Current API version is greater or equal to "
- + Build.getNameForSDKInt(Build.LINEAGE_VERSION_CODES.APRICOT),
- Toast.LENGTH_LONG).show();
- } else{
- Toast.makeText(VersioningTest.this,
- "Current API version is below target SKD version "
- + Build.LINEAGE_VERSION_CODES.APRICOT,
- Toast.LENGTH_SHORT).show();
- }
- }
- }
- };
-}
diff --git a/tests/src/org/lineageos/tests/versioning/unit/BinderTransactionTest.java b/tests/src/org/lineageos/tests/versioning/unit/BinderTransactionTest.java
deleted file mode 100644
index bad4c4c5..00000000
--- a/tests/src/org/lineageos/tests/versioning/unit/BinderTransactionTest.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * Copyright (c) 2016, 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.lineageos.tests.versioning.unit;
-
-import android.content.Context;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-import android.util.Log;
-import android.util.Pair;
-
-import org.lineageos.tests.LineageOSTestApplication;
-import org.lineageos.tests.versioning.unit.apiv2.ApiV2PriorReleaseInterfaces;
-import org.lineageos.tests.versioning.unit.apiv4.ApiV4PriorReleaseInterfaces;
-import org.lineageos.tests.versioning.unit.apiv5.ApiV5PriorReleaseInterfaces;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * These tests validate the enumerated binder transaction call ids per each
- * release api level against the current framework.
- *
- * This is to validate that no interface contracts are broken in terms of binder
- * call method mapping between releases.
- *
- * After too much searching on the internet, I found that no one was bored enough to
- * spend time on this awesomely boring concept. But I am.
- *
- * Also this is a fun endeavour into parameterized unit testing, and by fun, I mean
- * horrible and full of drinking.
- *
- * If you need to blame anyone for this concept, look no further than danesh@cyngn.com
- */
-@RunWith(Parameterized.class)
-@LargeTest
-public class BinderTransactionTest extends AndroidTestCase {
- private static final String TAG = BinderTransactionTest.class.getSimpleName();
- private static final String STUB_SUFFIX = "$Stub";
- private static final String LINEAGEOS_NAMESPACE = "lineageos";
- private static final String TRANSACTION_PREFIX = "TRANSACTION_";
-
- private static final int NOT_FROM_PRIOR_RELEASE = -1;
-
- private String mField;
- private int mExpectedValue;
- private int mActualValue;
- private static Context sContext;
-
- private static ArrayList mKnownSdkClasses;
- private static Map> mApiMethodsAndValues =
- new HashMap>();
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- }
-
- @Test
- public void testClassLoaderGivesSDKClasses() {
- /**
- * Verify we can retrieve our sdk classes from this package
- */
- assertNotNull(mKnownSdkClasses);
- assertTrue(mKnownSdkClasses.size() > 0);
- }
-
- private static void doSetup() {
- mKnownSdkClasses = MagicalDexHelper.getLoadedClasses(
- LineageOSTestApplication.getStaticApplicationContext(), LINEAGEOS_NAMESPACE);
- sContext = LineageOSTestApplication.getStaticApplicationContext();
- addInterfaces(ApiV2PriorReleaseInterfaces.getInterfaces());
- addInterfaces(ApiV4PriorReleaseInterfaces.getInterfaces());
- addInterfaces(ApiV5PriorReleaseInterfaces.getInterfaces());
- }
-
- private static void addInterfaces(Map> mapToAdd) {
- for (String key : mapToAdd.keySet()) {
- if (mApiMethodsAndValues.get(key) != null) {
- Map internalMap = mApiMethodsAndValues.get(key);
- internalMap.putAll(mapToAdd.get(key));
- } else {
- Map internalMap = mapToAdd.get(key);
- mApiMethodsAndValues.put(key, internalMap);
- }
- }
- }
-
- @Parameterized.Parameters
- public static Collection