Loading core/tests/systemproperties/Android.mk 0 → 100644 +18 −0 Original line number Diff line number Diff line LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) # We only want this apk build for tests. LOCAL_MODULE_TAGS := tests # Include all test java files. LOCAL_SRC_FILES := \ $(call all-java-files-under, src) LOCAL_DX_FLAGS := --core-library LOCAL_STATIC_JAVA_LIBRARIES := core-tests-supportlib android-common frameworks-core-util-lib LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_PACKAGE_NAME := FrameworksCoreSystemPropertiesTests LOCAL_CERTIFICATE := platform include $(BUILD_PACKAGE) core/tests/systemproperties/AndroidManifest.xml 0 → 100644 +30 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2011 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. --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.android.frameworks.coretests.systemproperties" android:sharedUserId="android.uid.system"> <application> <uses-library android:name="android.test.runner" /> </application> <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.android.frameworks.coretests" android:label="Frameworks Core Tests" /> </manifest> core/tests/systemproperties/run_core_systemproperties_test.sh 0 → 100755 +21 −0 Original line number Diff line number Diff line #!/bin/bash while [[ $# -gt 0 ]]; do case "$1" in --rebuild ) echo Rebuild && rebuild=true;; * ) com_opts+=($1);; esac shift done if [[ -z $ANDROID_PRODUCT_OUT && $rebuilld == true ]]; then echo You must lunch before running this test. exit 0 fi if [[ $rebuild == true ]]; then make -j4 FrameworksCoreSystemPropertiesTests TESTAPP=${ANDROID_PRODUCT_OUT}/data/app/FrameworksCoreSystemPropertiesTests.apk fi adb shell am instrument -w -e class android.os.SystemPropertiesTest com.android.frameworks.coretests.systemproperties/android.test.InstrumentationTestRunner core/tests/systemproperties/src/android/os/SystemPropertiesTest.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 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 android.os; import junit.framework.TestCase; import android.os.SystemProperties; import android.test.suitebuilder.annotation.SmallTest; public class SystemPropertiesTest extends TestCase { private static final String KEY = "sys.testkey"; @SmallTest public void testLongSequencialProperties() throws Exception { for (int i = 0; i < 100; ++i) { SystemProperties.set(KEY, Long.toString(i)); long ret = SystemProperties.getLong(KEY, -1); assertEquals(i, ret); } } @SmallTest public void testProperties() throws Exception { String value; SystemProperties.set(KEY, ""); value = SystemProperties.get(KEY, "default"); assertEquals("default", value); SystemProperties.set(KEY, "SA"); value = SystemProperties.get(KEY, "default"); assertEquals("SA", value); value = SystemProperties.get(KEY); assertEquals("SA", value); SystemProperties.set(KEY, ""); value = SystemProperties.get(KEY, "default"); assertEquals("default", value); value = SystemProperties.get(KEY); assertEquals("", value); } } Loading
core/tests/systemproperties/Android.mk 0 → 100644 +18 −0 Original line number Diff line number Diff line LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) # We only want this apk build for tests. LOCAL_MODULE_TAGS := tests # Include all test java files. LOCAL_SRC_FILES := \ $(call all-java-files-under, src) LOCAL_DX_FLAGS := --core-library LOCAL_STATIC_JAVA_LIBRARIES := core-tests-supportlib android-common frameworks-core-util-lib LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_PACKAGE_NAME := FrameworksCoreSystemPropertiesTests LOCAL_CERTIFICATE := platform include $(BUILD_PACKAGE)
core/tests/systemproperties/AndroidManifest.xml 0 → 100644 +30 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2011 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. --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="com.android.frameworks.coretests.systemproperties" android:sharedUserId="android.uid.system"> <application> <uses-library android:name="android.test.runner" /> </application> <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.android.frameworks.coretests" android:label="Frameworks Core Tests" /> </manifest>
core/tests/systemproperties/run_core_systemproperties_test.sh 0 → 100755 +21 −0 Original line number Diff line number Diff line #!/bin/bash while [[ $# -gt 0 ]]; do case "$1" in --rebuild ) echo Rebuild && rebuild=true;; * ) com_opts+=($1);; esac shift done if [[ -z $ANDROID_PRODUCT_OUT && $rebuilld == true ]]; then echo You must lunch before running this test. exit 0 fi if [[ $rebuild == true ]]; then make -j4 FrameworksCoreSystemPropertiesTests TESTAPP=${ANDROID_PRODUCT_OUT}/data/app/FrameworksCoreSystemPropertiesTests.apk fi adb shell am instrument -w -e class android.os.SystemPropertiesTest com.android.frameworks.coretests.systemproperties/android.test.InstrumentationTestRunner
core/tests/systemproperties/src/android/os/SystemPropertiesTest.java 0 → 100644 +57 −0 Original line number Diff line number Diff line /* * Copyright (C) 2011 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 android.os; import junit.framework.TestCase; import android.os.SystemProperties; import android.test.suitebuilder.annotation.SmallTest; public class SystemPropertiesTest extends TestCase { private static final String KEY = "sys.testkey"; @SmallTest public void testLongSequencialProperties() throws Exception { for (int i = 0; i < 100; ++i) { SystemProperties.set(KEY, Long.toString(i)); long ret = SystemProperties.getLong(KEY, -1); assertEquals(i, ret); } } @SmallTest public void testProperties() throws Exception { String value; SystemProperties.set(KEY, ""); value = SystemProperties.get(KEY, "default"); assertEquals("default", value); SystemProperties.set(KEY, "SA"); value = SystemProperties.get(KEY, "default"); assertEquals("SA", value); value = SystemProperties.get(KEY); assertEquals("SA", value); SystemProperties.set(KEY, ""); value = SystemProperties.get(KEY, "default"); assertEquals("default", value); value = SystemProperties.get(KEY); assertEquals("", value); } }