sdk: Remove tests

They don't compile and they haven't been updated in years.
They barely cover any of the sdk code, so remove them instead of fixing
them.

Change-Id: I74b2811d0bcead9b590e6c58053bd4b9fd72fec6
This commit is contained in:
Michael Bestas
2024-11-02 13:31:19 +02:00
parent cd36464e00
commit 8c849ce234
44 changed files with 0 additions and 3580 deletions

View File

@@ -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)

View File

@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.lineageos.tests"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_HOTWORD" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="lineageos.permission.BIND_CUSTOM_TILE_LISTENER_SERVICE"/>
<uses-permission android:name="lineageos.permission.PUBLISH_CUSTOM_TILE"/>
<uses-permission android:name="lineageos.permission.WRITE_SETTINGS"/>
<uses-permission android:name="lineageos.permission.WRITE_SECURE_SETTINGS"/>
<uses-permission android:name="lineageos.permission.MODIFY_NETWORK_SETTINGS" />
<uses-permission android:name="lineageos.permission.MODIFY_SOUND_SETTINGS" />
<uses-permission android:name="lineageos.permission.MANAGE_ALARMS" />
<uses-permission android:name="lineageos.permission.READ_ALARMS" />
<uses-permission android:name="lineageos.permission.MODIFY_MSIM_PHONE_STATE" />
<uses-permission android:name="lineageos.permission.READ_MSIM_PHONE_STATE" />
<uses-permission android:name="lineageos.permission.HARDWARE_ABSTRACTION_ACCESS" />
<uses-permission android:name="lineageos.permission.MODIFY_PROFILES" />
<uses-permission android:name="lineageos.permission.MANAGE_PERSISTENT_STORAGE" />
<uses-permission android:name="lineageos.permission.MANAGE_LIVEDISPLAY" />
<uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />
<application android:name=".LineageOSTestApplication"
android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<uses-library android:name="android.test.runner" />
<activity android:name=".customtiles.LineageStatusBarTest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".alarmclock.LineageAlarmClockTest"
android:label="@string/alarm_tests_activity_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".telephony.LineageTelephonyTest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".profiles.ProfileTest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".versioning.VersioningTest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".hardware.LineageHardwareTest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".customtiles.DummySettings"
android:label="@string/app_name" />
</application>
<instrumentation
android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="org.lineageos.tests" />
</manifest>

View File

@@ -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```

View File

@@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST PUBLISH TILE"
android:onClick="testPublishTile"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST PUBLISH SETTINGS TILE"
android:onClick="testPublishTileWithSettings"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST UPDATE TILE"
android:onClick="testUpdateTile"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST REMOVE TILE"
android:onClick="testRemoveTile"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST PUBLISH MULTIPLE"
android:onClick="testMultipleTilePublish"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEST REMOVE MULTIPLE"
android:onClick="testMultipleTileRemove"/>
</LinearLayout>

View File

@@ -1,45 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal">
<ImageView
android:src="@drawable/ic_whatshot_white_24dp"
android:layout_width="48dp"
android:layout_height="48dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="THIS IS A REMOTEVIEW"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/whats_hot_click"
android:text="CLICK ME"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Lineage Platform Tests</string>
<string name="settings_tests_activity_name">Lineage Platform Settings Tests</string>
<string name="alarm_tests_activity_name">Lineage Platform Alarm Clock Tests</string>
</resources>

View File

@@ -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;
}
}

View File

@@ -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<mTests.length; i++) {
labels[i] = mTests[i].name;
}
setListAdapter(new ArrayAdapter<String>(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();
}
}

View File

@@ -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 <T extends IBinder> String getStubDescriptor(Class<T> 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 extends IBinder> T getMockInterface(Class<T> 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;
}
}

View File

@@ -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.
*
*
* <p>
* 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 <em>main thread</em>
* won't work.
* </p>
*
* <p>
* 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 :
* </p>
*
* <ul>
* <li>The {@link #runOnServiceThread(Runnable)} methods allows to run code on
* the service pseudo-main thread.</li>
* <li>The {@link #startService(boolean, ServiceRunnable)} mehod allows starting
* the service in its own thread with some additional initialization code.</li>
* </ul>
*
*
* @author Antoine Martin
*
*/
public abstract class ThreadServiceTestCase<T extends Service> extends ServiceTestCase<T> {
/** 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> {
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<T> serviceClass;
public ThreadServiceTestCase(Class<T> 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<T> serviceHolder = new Holder<T>();
// 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<IBinder> serviceHolder = new Holder<IBinder>();
// 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();
}
}
}

View File

@@ -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<Integer> 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<String> 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<Integer> 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();
}
}
},
};
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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]);
}
}

View File

@@ -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<UUID> mProfileUuidList;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
mProfileManager = ProfileManager.getInstance(this);
mProfileUuidList = new ArrayList<UUID>();
}
@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();
}
}
};
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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();
}
}

View File

@@ -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<ConnectionSettings> expectedConnectionSettings = new ArrayList<>();
// inverted because the backing structure does it this way :/
expectedConnectionSettings.add(expectedConnectionSettings2);
expectedConnectionSettings.add(expectedConnectionSettings1);
List<ConnectionSettings> 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<StreamSettings> expectedStreamSettings = new ArrayList<>();
expectedStreamSettings.add(expectedStreamSettings1);
expectedStreamSettings.add(expectedStreamSettings2);
List<StreamSettings> 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<Profile.ProfileTrigger> expectedProfileTriggers = new ArrayList<>();
expectedProfileTriggers.add(profileTrigger1);
expectedProfileTriggers.add(profileTrigger2);
List<Profile.ProfileTrigger> 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());
}
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}

View File

@@ -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
}

View File

@@ -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;
}
}

View File

@@ -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();
}
}
}
};
}

View File

@@ -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<String> mKnownSdkClasses;
private static Map<String, Map<String, Integer>> mApiMethodsAndValues =
new HashMap<String, Map<String, Integer>>();
@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<String, Map<String, Integer>> mapToAdd) {
for (String key : mapToAdd.keySet()) {
if (mApiMethodsAndValues.get(key) != null) {
Map<String, Integer> internalMap = mApiMethodsAndValues.get(key);
internalMap.putAll(mapToAdd.get(key));
} else {
Map<String, Integer> internalMap = mapToAdd.get(key);
mApiMethodsAndValues.put(key, internalMap);
}
}
}
@Parameterized.Parameters
public static Collection<Object[]> data() {
doSetup();
//Ughhh, lets pretend this never happened
ArrayList<Pair<String, String>> targetClassAndFields =
new ArrayList<Pair<String, String>>();
ArrayList<Integer> actualValues = new ArrayList<Integer>();
for (String sClazz : mKnownSdkClasses) {
if (sClazz.endsWith(STUB_SUFFIX)) {
try {
Class clazz = MagicalDexHelper.loadClassForNameSpace(LineageOSTestApplication
.getStaticApplicationContext(), sClazz);
Field[] fields = clazz.getDeclaredFields();
Pattern pattern = Pattern.compile("\\.([\\w]+)\\$");
Matcher matcher = pattern.matcher(clazz.getName());
String className = null;
if (matcher.find()) {
className = matcher.group(1).substring(0, matcher.group(1).length());
}
for (Field field : fields) {
if (field.getName().startsWith(TRANSACTION_PREFIX)) {
field.setAccessible(true);
String fieldName = field.getName().substring(
TRANSACTION_PREFIX.length());
fieldName = fieldName.split("_")[0];
Pair<String, String> classAndField = new Pair<String, String>(
className, fieldName);
Log.d(TAG, "Adding: " + classAndField.first + " with field "
+ classAndField.second);
targetClassAndFields.add(classAndField);
try {
actualValues.add(field.getInt(clazz));
} catch (IllegalAccessException e) {
throw new AssertionError("Unable to access " + field.getName());
}
}
}
} catch (IOException e) {
throw new AssertionError("Unable to load class " + sClazz);
}
}
}
Object[][] values = new Object[targetClassAndFields.size()][3];
for (int i = 0; i < targetClassAndFields.size(); i++) {
Pair<String, String> targetClassAndField = targetClassAndFields.get(i);
values[i][0] = targetClassAndField.second;
values[i][1] = lookupValueForField(targetClassAndField.first,
targetClassAndField.second);
values[i][2] = actualValues.get(i);
}
return Arrays.asList(values);
}
//Look up the target fields value from a prior release
private static Object lookupValueForField(String clazz, String fieldName) {
Log.d(TAG, "Looking up: " + clazz + " with field "
+ fieldName);
Map<String, Integer> internalMap = mApiMethodsAndValues.get(clazz);
if (internalMap == null || !internalMap.containsKey(fieldName)) {
Log.d(TAG, "Internal map for " + clazz + " is null or doesn't contain entry");
return NOT_FROM_PRIOR_RELEASE;
}
return internalMap.get(fieldName);
}
public BinderTransactionTest(String targetField, Integer expectedValue, Integer actualValue) {
mField = targetField;
mExpectedValue = expectedValue;
mActualValue = actualValue;
}
@Test
public void testBinderTransactionValidation() {
Log.d(TAG, "Testing: " + mField + " with expected value of " + mExpectedValue
+ " and actual value of " + mActualValue);
if (mExpectedValue == NOT_FROM_PRIOR_RELEASE) {
//This is a new interface, no need to test against
return;
}
try {
assertEquals(mExpectedValue, mActualValue);
} catch (AssertionError e) {
throw new AssertionError("For the field " + mField + " expected value "
+ mExpectedValue + " but got " + mActualValue);
}
}
}

View File

@@ -1,67 +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.unit;
import android.test.suitebuilder.annotation.SmallTest;
import lineageos.os.Build;
import android.test.AndroidTestCase;
import lineageos.os.Concierge;
/**
* Created by adnan on 7/14/15.
*/
public class BuildTest extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
}
@SmallTest
public void testFetchSdkApiLevelExists() {
assertNotNull(Build.LINEAGE_VERSION.SDK_INT);
}
@SmallTest
public void testSdkApiLevelCurrent() {
assertEquals(Concierge.PARCELABLE_VERSION, Build.LINEAGE_VERSION.SDK_INT);
}
@SmallTest
public void testSdkApiLevelCanMatch() {
String apiName = Build.getNameForSDKInt(Build.LINEAGE_VERSION.SDK_INT);
assertNotNull(apiName);
assertEquals(Build.getNameForSDKInt(Concierge.PARCELABLE_VERSION), apiName);
}
@SmallTest
public void testSdkApiLevelSkippedIfGreaterThanAllowed() {
int i = 0;
if (Build.LINEAGE_VERSION.SDK_INT > Concierge.PARCELABLE_VERSION + 1) {
i++;
}
assertEquals(0, i);
}
@SmallTest
public void testSdkLevelRetrieveNameImpossible() {
String name = Build.getNameForSDKInt(Integer.MAX_VALUE);
assertNotNull(name);
assertEquals(Build.UNKNOWN, name);
}
}

View File

@@ -1,26 +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.unit;
/**
* Created by Adnan on 9/25/15.
*/
public class ClassPathException extends Exception {
public ClassPathException(String message) {
super("should not have " + message + " !");
}
}

View File

@@ -1,108 +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.unit;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.SmallTest;
import dalvik.system.DexFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
/**
* Created by adnan on 9/22/15.
*/
public class ClassPathTest extends AndroidTestCase {
private static final String LINEAGEOS_NAMESPACE = "lineageos";
private static final String PATH_TO_SYSTEM_FRAMEWORK = "/system/framework";
private ArrayList<String> mKnownSdkClasses;
@Override
protected void setUp() throws Exception {
super.setUp();
mKnownSdkClasses = MagicalDexHelper.getLoadedClasses(mContext, LINEAGEOS_NAMESPACE);
}
@SmallTest
public void testClassLoaderGivesSDKClasses() {
/**
* Verify we can retrieve our sdk classes from this package
*/
assertNotNull(mKnownSdkClasses);
assertTrue(mKnownSdkClasses.size() > 0);
}
@LargeTest
public void testBootClassPathIsClean() {
File path = new File(PATH_TO_SYSTEM_FRAMEWORK);
File[] files = path.listFiles();
assertNotNull(files);
/**
* Everything in the in the boot class path needs to not
* contain the sdk. Verify integrity of runtime below.
*/
final String bootClassPath = System.getenv("BOOTCLASSPATH");
ArrayList<String> classPathJars = new ArrayList<String>();
if (bootClassPath != null) {
String[] bootClassPathElements = bootClassPath.split(":");
for (String element : bootClassPathElements) {
classPathJars.add(element);
}
} else {
throw new AssertionError("No BOOTCLASSPATH defined! ");
}
for (String classPathJar : classPathJars) {
try {
File jar = new File(classPathJar);
DexFile dexFile = new DexFile(jar);
assertTrue(isJarClean(dexFile));
} catch (IOException e) {
throw new AssertionError("Unable to find jar! " + classPathJar +
"\nException " + e.toString());
}
}
}
private void processAndCompare(String name) throws ClassPathException {
if (mKnownSdkClasses.contains(name)) {
throw new ClassPathException(name);
}
}
private boolean isJarClean(DexFile dexFile) throws AssertionError {
Enumeration<String> enumeration = dexFile.entries();
while (enumeration.hasMoreElements()) {
try {
processAndCompare(enumeration.nextElement());
} catch (ClassPathException e) {
throw new AssertionError("Jar file "
+ dexFile.getName() + " " + e.getMessage());
}
}
return true;
}
}

View File

@@ -1,55 +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 dalvik.system.DexFile;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
/**
* Created by adnan on 2/3/16.
*/
public class MagicalDexHelper {
public static ArrayList<String> getLoadedClasses(Context context, String targetNameSpace) {
ArrayList<String> listOfClasses = new ArrayList<String>();
try {
DexFile dexFile = new DexFile(new File(context.getPackageCodePath()));
Enumeration<String> enumeration = dexFile.entries();
while (enumeration.hasMoreElements()){
String className = enumeration.nextElement();
if (className.startsWith(targetNameSpace)) {
listOfClasses.add(className);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return listOfClasses;
}
public static Class loadClassForNameSpace(Context context,
String classToLoad) throws IOException {
DexFile dexFile = new DexFile(new File(context.getPackageCodePath()));
return dexFile.loadClass(classToLoad, context.getClassLoader());
}
}

View File

@@ -1,131 +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.apiv2;
import java.util.HashMap;
import java.util.Map;
/**
* Created by adnan on 2/4/16.
*/
public class ApiV2PriorReleaseInterfaces {
private static Map<String, Map<String, Integer>> mApiMethodsAndValues =
new HashMap<String, Map<String, Integer>>();
//Profiles Aidl (IProfileManager)
static {
Map<String, Integer> profilesMap = getInternalInterfaceMap("IProfileManager");
// APRICOT + BOYSENBERRY + CANTALOUPE
profilesMap.put("setActiveProfile", 1);
profilesMap.put("etActiveProfileByName", 2);
profilesMap.put("getActiveProfile", 3);
profilesMap.put("addProfile", 4);
profilesMap.put("removeProfile", 5);
profilesMap.put("updateProfile", 6);
profilesMap.put("getProfile", 7);
profilesMap.put("getProfileByName", 8);
profilesMap.put("getProfiles", 9);
profilesMap.put("profileExists", 10);
profilesMap.put("profileExistsByName", 11);
profilesMap.put("notificationGroupExistsByName", 12);
profilesMap.put("getNotificationGroups", 13);
profilesMap.put("addNotificationGroup", 14);
profilesMap.put("removeNotificationGroup", 15);
profilesMap.put("updateNotificationGroup", 16);
profilesMap.put("getNotificationGroupForPackage", 17);
profilesMap.put("getNotificationGroup", 18);
profilesMap.put("resetAll", 19);
}
//LineageHardwareManager Aidl (ILineageHardwareService)
static {
Map<String, Integer> hardwareMap = getInternalInterfaceMap("ILineageHardwareService");
// APRICOT + BOYSENBERRY + CANTALOUPE
hardwareMap.put("getSupportedFeatures", 1);
hardwareMap.put("get", 2);
hardwareMap.put("set", 3);
hardwareMap.put("getDisplayColorCalibration", 4);
hardwareMap.put("setDisplayColorCalibration", 5);
hardwareMap.put("getNumGammaControls", 6);
hardwareMap.put("getDisplayGammaCalibration", 7);
hardwareMap.put("setDisplayGammaCalibration", 8);
hardwareMap.put("getVibratorIntensity", 9);
hardwareMap.put("setVibratorIntensity", 10);
hardwareMap.put("getLtoSource", 11);
hardwareMap.put("getLtoDestination", 12);
hardwareMap.put("getLtoDownloadInterval", 13);
hardwareMap.put("getSerialNumber", 14);
hardwareMap.put("requireAdaptiveBacklightForSunlightEnhancement", 15);
hardwareMap.put("getDisplayModes", 16);
hardwareMap.put("getCurrentDisplayMode", 17);
hardwareMap.put("getDefaultDisplayMode", 18);
hardwareMap.put("setDisplayMode", 19);
hardwareMap.put("writePersistentBytes", 20);
hardwareMap.put("readPersistentBytes", 21);
hardwareMap.put("getThermalState", 22);
hardwareMap.put("registerThermalListener", 23);
hardwareMap.put("unRegisterThermalListener", 24);
}
//LineageStatusBarManager Aidl (ILineageStatusBarManager)
static {
Map<String, Integer> statusBarMap = getInternalInterfaceMap("ILineageStatusBarManager");
// APRICOT + BOYSENBERRY + CANTALOUPE
statusBarMap.put("createCustomTileWithTag", 1);
statusBarMap.put("removeCustomTileWithTag", 2);
statusBarMap.put("registerListener", 3);
statusBarMap.put("unregisterListener", 4);
statusBarMap.put("removeCustomTileFromListener", 5);
}
//AppSuggestManager Aidl (IAppSuggestManager)
static {
Map<String, Integer> suggestMap = getInternalInterfaceMap("IAppSuggestManager");
// APRICOT + BOYSENBERRY + CANTALOUPE
suggestMap.put("handles", 1);
suggestMap.put("getSuggestions", 2);
}
//LineageTelephonyManager Aidl (ILineageTelephonyManager)
static {
Map<String, Integer> telephonyMap = getInternalInterfaceMap("ILineageTelephonyManager");
// APRICOT + BOYSENBERRY + CANTALOUPE
telephonyMap.put("getSubInformation", 1);
telephonyMap.put("isSubActive", 2);
telephonyMap.put("isDataConnectionSelectedOnSub", 3);
telephonyMap.put("isDataConnectionEnabled", 4);
telephonyMap.put("setSubState", 5);
telephonyMap.put("setDataConnectionSelectedOnSub", 6);
telephonyMap.put("setDataConnectionState", 7);
telephonyMap.put("setDefaultPhoneSub", 8);
telephonyMap.put("setDefaultSmsSub", 9);
}
protected static Map<String, Integer> getInternalInterfaceMap(String targetInterface) {
Map<String, Integer> internalMap = mApiMethodsAndValues.get(targetInterface);
if (internalMap == null) {
internalMap = new HashMap<String, Integer>();
mApiMethodsAndValues.put(targetInterface, internalMap);
return internalMap;
}
return internalMap;
}
public static Map<String, Map<String, Integer>> getInterfaces() {
return mApiMethodsAndValues;
}
}

View File

@@ -1,96 +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.apiv4;
import java.util.HashMap;
import java.util.Map;
public class ApiV4PriorReleaseInterfaces {
private static Map<String, Map<String, Integer>> mApiMethodsAndValues =
new HashMap<String, Map<String, Integer>>();
//Profiles Aidl (IProfileManager)
static {
Map<String, Integer> profilesMap = getInternalInterfaceMap("IProfileManager");
// APRICOT + BOYSENBERRY + CANTALOUPE to 19
// DRAGONFRUIT BEGIN
profilesMap.put("isEnabled", 20);
}
//LineageHardwareManager Aidl (ILineageHardwareService)
static {
Map<String, Integer> hardwareMap = getInternalInterfaceMap("ILineageHardwareService");
// APRICOT + BOYSENBERRY + CANTALOUPE to 24
// DRAGONFRUIT BEGIN
hardwareMap.put("isSunlightEnhancementSelfManaged", 25);
hardwareMap.put("getUniqueDeviceId", 26);
}
//LineageStatusBarManager Aidl (ILineageStatusBarManager)
static {
// APRICOT + BOYSENBERRY + CANTALOUPE to 5
// DRAGONFRUIT BEGIN
}
//AppSuggestManager Aidl (IAppSuggestManager)
static {
// APRICOT + BOYSENBERRY + CANTALOUPE to 2
// DRAGONFRUIT BEGIN
}
//LineageTelephonyManager Aidl (ILineageTelephonyManager)
static {
// APRICOT + BOYSENBERRY + CANTALOUPE to 9
// DRAGONFRUIT BEGIN
}
//ExternalViewProviderFactory Aidl (IExternalViewProviderFactory)
static {
Map<String, Integer> extProviderMap =
getInternalInterfaceMap("IExternalViewProviderFactory");
// DRAGONFRUIT BEGIN
extProviderMap.put("createExternalView", 1);
}
//ExternalViewProvider Aidl (IExternalViewProvider)
static {
Map<String, Integer> extViewProviderMap =
getInternalInterfaceMap("IExternalViewProvider");
// DRAGONFRUIT BEGIN
extViewProviderMap.put("onAttach", 1);
extViewProviderMap.put("onStart", 2);
extViewProviderMap.put("onResume", 3);
extViewProviderMap.put("onPause", 4);
extViewProviderMap.put("onStop", 5);
extViewProviderMap.put("onDetach", 6);
extViewProviderMap.put("alterWindow", 7);
}
protected static Map<String, Integer> getInternalInterfaceMap(String targetInterface) {
Map<String, Integer> internalMap = mApiMethodsAndValues.get(targetInterface);
if (internalMap == null) {
internalMap = new HashMap<String, Integer>();
mApiMethodsAndValues.put(targetInterface, internalMap);
return internalMap;
}
return internalMap;
}
public static Map<String, Map<String, Integer>> getInterfaces() {
return mApiMethodsAndValues;
}
}

View File

@@ -1,63 +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.apiv5;
import java.util.HashMap;
import java.util.Map;
public class ApiV5PriorReleaseInterfaces {
private static Map<String, Map<String, Integer>> mApiMethodsAndValues =
new HashMap<String, Map<String, Integer>>();
//ExternalViewProviderFactory Aidl (IExternalViewProviderFactory)
static {
Map<String, Integer> extProviderMap =
getInternalInterfaceMap("IExternalViewProviderFactory");
// DRAGONFRUIT TO 1
// ELDERBERRY BEGIN
}
//ExternalViewProvider Aidl (IExternalViewProvider)
static {
Map<String, Integer> extViewProviderMap =
getInternalInterfaceMap("IExternalViewProvider");
// DRAGONFRUIT TO 7
// ELDERBERRY BEGIN
}
//RequestInfoListener Aidl (IRequestInfoListener)
static {
Map<String, Integer> requestInfoListener =
getInternalInterfaceMap("IRequestInfoListener");
//ELDERBERRY BEGIN
requestInfoListener.put("onLookupCityRequestCompleted ", 1);
}
protected static Map<String, Integer> getInternalInterfaceMap(String targetInterface) {
Map<String, Integer> internalMap = mApiMethodsAndValues.get(targetInterface);
if (internalMap == null) {
internalMap = new HashMap<String, Integer>();
mApiMethodsAndValues.put(targetInterface, internalMap);
return internalMap;
}
return internalMap;
}
public static Map<String, Map<String, Integer>> getInterfaces() {
return mApiMethodsAndValues;
}
}