aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2016-06-14 13:40:23 -0700
committerAdnan Begovic <adnan@cyngn.com>2016-06-16 11:08:28 -0700
commit9b50627030c59e1f0df8a3eeac89e8bdeb80ae2d (patch)
tree465b1671a5ca7e59abbf3b74243e38d83ee70b2d /tests
parent522b0c3db16b061716078b202d3be5ae87ce06f0 (diff)
downloadvendor_cmsdk-9b50627030c59e1f0df8a3eeac89e8bdeb80ae2d.zip
vendor_cmsdk-9b50627030c59e1f0df8a3eeac89e8bdeb80ae2d.tar.gz
vendor_cmsdk-9b50627030c59e1f0df8a3eeac89e8bdeb80ae2d.tar.bz2
cmsdk: Provide remaining Profile test coverage.
Change-Id: Ief60939e92c1e8efe700410e3e23a0eeff744364 TICKET: CYNGNOS-3046
Diffstat (limited to 'tests')
-rw-r--r--tests/src/org/cyanogenmod/tests/profiles/unit/ProfileTest.java279
1 files changed, 276 insertions, 3 deletions
diff --git a/tests/src/org/cyanogenmod/tests/profiles/unit/ProfileTest.java b/tests/src/org/cyanogenmod/tests/profiles/unit/ProfileTest.java
index 364d36f..32c5b1a 100644
--- a/tests/src/org/cyanogenmod/tests/profiles/unit/ProfileTest.java
+++ b/tests/src/org/cyanogenmod/tests/profiles/unit/ProfileTest.java
@@ -32,11 +32,11 @@ import cyanogenmod.profiles.LockSettings;
import cyanogenmod.profiles.RingModeSettings;
import cyanogenmod.profiles.StreamSettings;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.UUID;
-/**
- * Created by adnan on 7/14/15.
- */
public class ProfileTest extends AndroidTestCase {
@Override
@@ -263,4 +263,277 @@ public class ProfileTest extends AndroidTestCase {
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_DISALED, 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 testProfileGetExpandedDesktopMode() {
+ int expectedExpandedDesktopMode = Profile.ExpandedDesktopMode.ENABLE;
+ Profile profile = new Profile("Desktop Mode Profile");
+ profile.setExpandedDesktopMode(expectedExpandedDesktopMode);
+ assertEquals(expectedExpandedDesktopMode, profile.getExpandedDesktopMode());
+ }
+
+ @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());
+ }
}