From 0e0cb73c61508cf61f59da90b63baf45b6309202 Mon Sep 17 00:00:00 2001 From: Adnan Begovic Date: Wed, 8 Jun 2016 14:18:37 -0700 Subject: [PATCH] cmsdk: Provide test coverage to Profile's *Settings classes. Change-Id: I775cdd00e7e5cfbead681d548075f44d5799bccf TICKET: CYNGNOS-3027 --- .../unit/AirplaneModeSettingsTest.java | 52 ++++++++++++++ .../profiles/unit/BrightnessSettingsTest.java | 49 +++++++++++++ .../profiles/unit/ConnectionSettingsTest.java | 71 +++++++++++++++++++ .../tests/profiles/unit/LockSettingsTest.java | 39 ++++++++++ .../profiles/unit/RingModeSettingsTest.java | 49 +++++++++++++ .../profiles/unit/StreamSettingsTest.java | 58 +++++++++++++++ 6 files changed, 318 insertions(+) create mode 100644 tests/src/org/cyanogenmod/tests/profiles/unit/AirplaneModeSettingsTest.java create mode 100644 tests/src/org/cyanogenmod/tests/profiles/unit/BrightnessSettingsTest.java create mode 100644 tests/src/org/cyanogenmod/tests/profiles/unit/ConnectionSettingsTest.java create mode 100644 tests/src/org/cyanogenmod/tests/profiles/unit/LockSettingsTest.java create mode 100644 tests/src/org/cyanogenmod/tests/profiles/unit/RingModeSettingsTest.java create mode 100644 tests/src/org/cyanogenmod/tests/profiles/unit/StreamSettingsTest.java diff --git a/tests/src/org/cyanogenmod/tests/profiles/unit/AirplaneModeSettingsTest.java b/tests/src/org/cyanogenmod/tests/profiles/unit/AirplaneModeSettingsTest.java new file mode 100644 index 0000000..d77639b --- /dev/null +++ b/tests/src/org/cyanogenmod/tests/profiles/unit/AirplaneModeSettingsTest.java @@ -0,0 +1,52 @@ +/** + * 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.cyanogenmod.tests.profiles.unit; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; +import cyanogenmod.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_DISALED; + AirplaneModeSettings airplaneModeSettings = + new AirplaneModeSettings( + AirplaneModeSettings.BooleanState.STATE_ENABLED, true); + airplaneModeSettings.setValue(expectedValue); + assertEquals(expectedValue, airplaneModeSettings.getValue()); + } +} diff --git a/tests/src/org/cyanogenmod/tests/profiles/unit/BrightnessSettingsTest.java b/tests/src/org/cyanogenmod/tests/profiles/unit/BrightnessSettingsTest.java new file mode 100644 index 0000000..bb725e8 --- /dev/null +++ b/tests/src/org/cyanogenmod/tests/profiles/unit/BrightnessSettingsTest.java @@ -0,0 +1,49 @@ +/** + * 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.cyanogenmod.tests.profiles.unit; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; +import cyanogenmod.profiles.BrightnessSettings; + +public class BrightnessSettingsTest extends AndroidTestCase { + + @SmallTest + public void testConstructWholly() { + BrightnessSettings brightnessSettings = + new BrightnessSettings(0, true); + assertEquals(0, brightnessSettings.getValue()); + assertEquals(true, brightnessSettings.isOverride()); + } + + @SmallTest + public void testVerifyOverride() { + BrightnessSettings brightnessSettings = + new BrightnessSettings(0, true); + brightnessSettings.setOverride(false); + assertEquals(false, brightnessSettings.isOverride()); + } + + @SmallTest + public void testVerifyValue() { + int expectedValue = 30; + BrightnessSettings brightnessSettings = + new BrightnessSettings(0, true); + brightnessSettings.setValue(expectedValue); + assertEquals(expectedValue, brightnessSettings.getValue()); + } +} diff --git a/tests/src/org/cyanogenmod/tests/profiles/unit/ConnectionSettingsTest.java b/tests/src/org/cyanogenmod/tests/profiles/unit/ConnectionSettingsTest.java new file mode 100644 index 0000000..780c0df --- /dev/null +++ b/tests/src/org/cyanogenmod/tests/profiles/unit/ConnectionSettingsTest.java @@ -0,0 +1,71 @@ +/** + * 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.cyanogenmod.tests.profiles.unit; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; +import cyanogenmod.profiles.ConnectionSettings; + +public class ConnectionSettingsTest extends AndroidTestCase { + + @SmallTest + public void testConstructManually() { + ConnectionSettings connectionSettings = new ConnectionSettings( + ConnectionSettings.PROFILE_CONNECTION_GPS); + assertEquals(ConnectionSettings.PROFILE_CONNECTION_GPS, + connectionSettings.getConnectionId()); + assertNotNull(connectionSettings); + } + + @SmallTest + public void testConstructWholly() { + ConnectionSettings connectionSettings = + new ConnectionSettings(ConnectionSettings.PROFILE_CONNECTION_GPS, + ConnectionSettings.BooleanState.STATE_DISALED, true); + assertEquals(true, connectionSettings.isOverride()); + assertEquals(ConnectionSettings.BooleanState.STATE_DISALED, + connectionSettings.getValue()); + assertEquals(ConnectionSettings.PROFILE_CONNECTION_GPS, + connectionSettings.getConnectionId()); + assertNotNull(connectionSettings); + } + + @SmallTest + public void testVerifyOverride() { + ConnectionSettings connectionSettings = new ConnectionSettings( + ConnectionSettings.PROFILE_CONNECTION_GPS); + 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_DISALED; + ConnectionSettings connectionSettings = new ConnectionSettings( + ConnectionSettings.PROFILE_CONNECTION_2G3G4G); + connectionSettings.setValue(expectedValue); + assertEquals(expectedValue, connectionSettings.getValue()); + } +} diff --git a/tests/src/org/cyanogenmod/tests/profiles/unit/LockSettingsTest.java b/tests/src/org/cyanogenmod/tests/profiles/unit/LockSettingsTest.java new file mode 100644 index 0000000..9da3c0f --- /dev/null +++ b/tests/src/org/cyanogenmod/tests/profiles/unit/LockSettingsTest.java @@ -0,0 +1,39 @@ +/** + * 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.cyanogenmod.tests.profiles.unit; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; +import cyanogenmod.app.Profile; +import cyanogenmod.profiles.LockSettings; + +public class LockSettingsTest extends AndroidTestCase { + + @SmallTest + public void testConstructWholly() { + LockSettings lockSettings = new LockSettings(Profile.LockMode.INSECURE); + assertEquals(Profile.LockMode.INSECURE, lockSettings.getValue()); + } + + @SmallTest + public void testVerifyValue() { + int expectedValue = Profile.LockMode.DEFAULT; + LockSettings lockSettings = new LockSettings(Profile.LockMode.INSECURE); + lockSettings.setValue(expectedValue); + assertEquals(expectedValue, lockSettings.getValue()); + } +} diff --git a/tests/src/org/cyanogenmod/tests/profiles/unit/RingModeSettingsTest.java b/tests/src/org/cyanogenmod/tests/profiles/unit/RingModeSettingsTest.java new file mode 100644 index 0000000..de2ae93 --- /dev/null +++ b/tests/src/org/cyanogenmod/tests/profiles/unit/RingModeSettingsTest.java @@ -0,0 +1,49 @@ +/** + * 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.cyanogenmod.tests.profiles.unit; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; +import cyanogenmod.profiles.RingModeSettings; + +public class RingModeSettingsTest extends AndroidTestCase { + + @SmallTest + public void testConstructWholly() { + RingModeSettings ringSettings = new RingModeSettings( + RingModeSettings.RING_MODE_MUTE, true); + assertEquals(RingModeSettings.RING_MODE_MUTE, ringSettings.getValue()); + assertEquals(true, ringSettings.isOverride()); + } + + @SmallTest + public void testVerifyOverride() { + RingModeSettings ringSettings = new RingModeSettings( + RingModeSettings.RING_MODE_MUTE, true); + ringSettings.setOverride(false); + assertEquals(false, ringSettings.isOverride()); + } + + @SmallTest + public void testVerifyValue() { + String expectedValue = RingModeSettings.RING_MODE_NORMAL; + RingModeSettings ringSettings = new RingModeSettings( + RingModeSettings.RING_MODE_MUTE, true); + ringSettings.setValue(expectedValue); + assertEquals(expectedValue, ringSettings.getValue()); + } +} diff --git a/tests/src/org/cyanogenmod/tests/profiles/unit/StreamSettingsTest.java b/tests/src/org/cyanogenmod/tests/profiles/unit/StreamSettingsTest.java new file mode 100644 index 0000000..8bf806b --- /dev/null +++ b/tests/src/org/cyanogenmod/tests/profiles/unit/StreamSettingsTest.java @@ -0,0 +1,58 @@ +/** + * 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.cyanogenmod.tests.profiles.unit; + +import android.media.AudioManager; +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; +import cyanogenmod.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()); + } +}