From 22cf344ba4f01ce2a4c75c4bfc5ee73b91f28640 Mon Sep 17 00:00:00 2001 From: William Escande Date: Mon, 22 Aug 2022 11:27:57 -0700 Subject: [Bluetooth apex] Use new apex name The Bluetooth apex name is now called com.android.btservices Bug: 243054261 Test: Build Change-Id: I77716d6c807560a26088b2eeb36bcfc134b4ed3d --- Android.bp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Android.bp b/Android.bp index ac8ca69..1732969 100644 --- a/Android.bp +++ b/Android.bp @@ -25,6 +25,6 @@ java_library { srcs: ["java/**/*.java"], apex_available: [ "//apex_available:platform", - "com.android.bluetooth", + "com.android.btservices", ], } -- cgit v1.2.3 From 94550f87512eb5ee09893a48727d592021ffc0b0 Mon Sep 17 00:00:00 2001 From: Kihong Seong Date: Fri, 2 Sep 2022 03:23:16 +0000 Subject: Add VCardExceptionTest Bug: 244261444 Test: atest VCardExceptionTest Change-Id: I08c105d4b47a46f8d167b789e32d7372d1385c0d --- tests/Android.bp | 4 +++ .../android/vcard/tests/VCardExceptionTest.java | 35 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/src/com/android/vcard/tests/VCardExceptionTest.java diff --git a/tests/Android.bp b/tests/Android.bp index 5c49410..ec1d932 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -31,6 +31,10 @@ android_test { static_libs: [ "com.android.vcard", "junit", + "androidx.test.ext.truth", + "androidx.test.rules", + "mockito-target", + "truth-prebuilt", ], jacoco: { diff --git a/tests/src/com/android/vcard/tests/VCardExceptionTest.java b/tests/src/com/android/vcard/tests/VCardExceptionTest.java new file mode 100644 index 0000000..6f09fad --- /dev/null +++ b/tests/src/com/android/vcard/tests/VCardExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardException; + +import junit.framework.TestCase; + +public class VCardExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardException exception = new VCardException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardException exception = new VCardException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} -- cgit v1.2.3 From 07668b6429abce0699b729e8878e0b0b420fdab7 Mon Sep 17 00:00:00 2001 From: Kihong Seong Date: Tue, 13 Sep 2022 05:55:36 +0000 Subject: Add JapaneseUtilsTest Bug: 237467631 Test: atest JapaneseUtilsTest Change-Id: I7b69f1301da585a52bd7c4b528dc7b032c7a4f5e --- Android.bp | 4 +++ java/com/android/vcard/JapaneseUtils.java | 5 +++- .../com/android/vcard/tests/JapaneseUtilsTest.java | 31 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/src/com/android/vcard/tests/JapaneseUtilsTest.java diff --git a/Android.bp b/Android.bp index 1732969..ac85d76 100644 --- a/Android.bp +++ b/Android.bp @@ -27,4 +27,8 @@ java_library { "//apex_available:platform", "com.android.btservices", ], + + libs: [ + "framework-annotations-lib", + ] } diff --git a/java/com/android/vcard/JapaneseUtils.java b/java/com/android/vcard/JapaneseUtils.java index 5b44944..7079648 100644 --- a/java/com/android/vcard/JapaneseUtils.java +++ b/java/com/android/vcard/JapaneseUtils.java @@ -16,6 +16,8 @@ package com.android.vcard; +import com.android.internal.annotations.VisibleForTesting; + import java.util.HashMap; import java.util.Map; @@ -23,7 +25,8 @@ import java.util.Map; * TextUtils especially for Japanese. */ /* package */ class JapaneseUtils { - static private final Map sHalfWidthMap = + @VisibleForTesting + static final Map sHalfWidthMap = new HashMap(); static { diff --git a/tests/src/com/android/vcard/tests/JapaneseUtilsTest.java b/tests/src/com/android/vcard/tests/JapaneseUtilsTest.java new file mode 100644 index 0000000..452944e --- /dev/null +++ b/tests/src/com/android/vcard/tests/JapaneseUtilsTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2022 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 com.android.vcard; + +import com.android.vcard.JapaneseUtils; + +import junit.framework.TestCase; + +public class JapaneseUtilsTest extends TestCase { + static final char TEST_CONTAINED_CHAR = '\uFFE5'; + static final char TEST_UNCONTAINED_CHAR = '\uFFF5'; + + public void testTryGetHalfWidthText() { + assertNull(JapaneseUtils.tryGetHalfWidthText(TEST_UNCONTAINED_CHAR)); + assertEquals(JapaneseUtils.tryGetHalfWidthText(TEST_CONTAINED_CHAR), "\u005C\u005C"); + } +} -- cgit v1.2.3 From 9cb240cfc3dfa5c616233421ae6290e1479db82c Mon Sep 17 00:00:00 2001 From: Kihong Seong Date: Wed, 7 Sep 2022 06:59:31 +0000 Subject: Add tests for classes in package vcard.exception This CL adds tests for: - VCardAgentNotSupportedException - VCardInvalidCommentLineException - VCardInvalidLineException - VCardNestedException - VCardNotSupportedException - VCardVersionException Bug: 237467631 Test: Ran each test with atest Change-Id: I6420bdae32c88bdc860ea4343ebd9411efc1dfc2 --- .../android/vcard/tests/VCardExceptionTest.java | 35 --------------------- .../VCardAgentNotSupportedExceptionTest.java | 36 ++++++++++++++++++++++ .../vcard/tests/exception/VCardExceptionTest.java | 35 +++++++++++++++++++++ .../VCardInvalidCommentLineExceptionTest.java | 36 ++++++++++++++++++++++ .../exception/VCardInvalidLineExceptionTest.java | 35 +++++++++++++++++++++ .../tests/exception/VCardNestedExceptionTest.java | 35 +++++++++++++++++++++ .../exception/VCardNotSupportedExceptionTest.java | 35 +++++++++++++++++++++ .../tests/exception/VCardVersionExceptionTest.java | 35 +++++++++++++++++++++ 8 files changed, 247 insertions(+), 35 deletions(-) delete mode 100644 tests/src/com/android/vcard/tests/VCardExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardAgentNotSupportedExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardInvalidCommentLineExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardInvalidLineExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardNestedExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardNotSupportedExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardVersionExceptionTest.java diff --git a/tests/src/com/android/vcard/tests/VCardExceptionTest.java b/tests/src/com/android/vcard/tests/VCardExceptionTest.java deleted file mode 100644 index 6f09fad..0000000 --- a/tests/src/com/android/vcard/tests/VCardExceptionTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2022 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 com.android.vcard.tests; - -import com.android.vcard.exception.VCardException; - -import junit.framework.TestCase; - -public class VCardExceptionTest extends TestCase { - static final String TEST_MESSAGE = "message"; - - public void testExceptionWithoutMessage() { - VCardException exception = new VCardException(); - assertNull(exception.getMessage()); - } - - public void testExceptionWithMessage() { - VCardException exception = new VCardException(TEST_MESSAGE); - assertEquals(exception.getMessage(), TEST_MESSAGE); - } -} diff --git a/tests/src/com/android/vcard/tests/exception/VCardAgentNotSupportedExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardAgentNotSupportedExceptionTest.java new file mode 100644 index 0000000..c370ec0 --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardAgentNotSupportedExceptionTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardAgentNotSupportedException; + +import junit.framework.TestCase; + +public class VCardAgentNotSupportedExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardAgentNotSupportedException exception = new VCardAgentNotSupportedException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardAgentNotSupportedException exception = new VCardAgentNotSupportedException( + TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardExceptionTest.java new file mode 100644 index 0000000..6f09fad --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardException; + +import junit.framework.TestCase; + +public class VCardExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardException exception = new VCardException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardException exception = new VCardException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardInvalidCommentLineExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardInvalidCommentLineExceptionTest.java new file mode 100644 index 0000000..5a1429f --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardInvalidCommentLineExceptionTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardInvalidCommentLineException; + +import junit.framework.TestCase; + +public class VCardInvalidCommentLineExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardInvalidCommentLineException exception = new VCardInvalidCommentLineException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardInvalidCommentLineException exception = new VCardInvalidCommentLineException( + TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardInvalidLineExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardInvalidLineExceptionTest.java new file mode 100644 index 0000000..6568de8 --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardInvalidLineExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardInvalidLineException; + +import junit.framework.TestCase; + +public class VCardInvalidLineExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardInvalidLineException exception = new VCardInvalidLineException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardInvalidLineException exception = new VCardInvalidLineException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardNestedExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardNestedExceptionTest.java new file mode 100644 index 0000000..ee87dc2 --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardNestedExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardNestedException; + +import junit.framework.TestCase; + +public class VCardNestedExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardNestedException exception = new VCardNestedException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardNestedException exception = new VCardNestedException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardNotSupportedExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardNotSupportedExceptionTest.java new file mode 100644 index 0000000..0d393be --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardNotSupportedExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardNotSupportedException; + +import junit.framework.TestCase; + +public class VCardNotSupportedExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardNotSupportedException exception = new VCardNotSupportedException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardNotSupportedException exception = new VCardNotSupportedException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardVersionExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardVersionExceptionTest.java new file mode 100644 index 0000000..1e9ed67 --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardVersionExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardVersionException; + +import junit.framework.TestCase; + +public class VCardVersionExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardVersionException exception = new VCardVersionException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardVersionException exception = new VCardVersionException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} -- cgit v1.2.3 From 06ed1dcec3671440f888f4a6f7354de1b176e473 Mon Sep 17 00:00:00 2001 From: Kihong Seong Date: Fri, 2 Sep 2022 03:23:16 +0000 Subject: Add VCardExceptionTest Bug: 237467631 Test: atest VCardExceptionTest Change-Id: I08c105d4b47a46f8d167b789e32d7372d1385c0d (cherry picked from commit 94550f87512eb5ee09893a48727d592021ffc0b0) --- tests/Android.bp | 4 +++ .../android/vcard/tests/VCardExceptionTest.java | 35 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/src/com/android/vcard/tests/VCardExceptionTest.java diff --git a/tests/Android.bp b/tests/Android.bp index 5c49410..ec1d932 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -31,6 +31,10 @@ android_test { static_libs: [ "com.android.vcard", "junit", + "androidx.test.ext.truth", + "androidx.test.rules", + "mockito-target", + "truth-prebuilt", ], jacoco: { diff --git a/tests/src/com/android/vcard/tests/VCardExceptionTest.java b/tests/src/com/android/vcard/tests/VCardExceptionTest.java new file mode 100644 index 0000000..6f09fad --- /dev/null +++ b/tests/src/com/android/vcard/tests/VCardExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardException; + +import junit.framework.TestCase; + +public class VCardExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardException exception = new VCardException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardException exception = new VCardException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} -- cgit v1.2.3 From 81a931a71f2da95a91b8ebbede3eb831edd5b04a Mon Sep 17 00:00:00 2001 From: Ahmed Elmaghraby Date: Wed, 5 Oct 2022 17:32:22 +0000 Subject: Update vcard/OWNERS file remove maghraby@ and add johnshao@ Change-Id: Ifa71a0ac3329e8998c18639285c0753ad33101fc --- OWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OWNERS b/OWNERS index 22dad71..0b3cfb7 100644 --- a/OWNERS +++ b/OWNERS @@ -1,4 +1,4 @@ # Default code reviewers picked from top 3 or more developers. # Please update this list if you find better candidates. pirozzoj@google.com -maghraby@google.com +johnshao@google.com -- cgit v1.2.3 From 57064bfc0df9009a71681dbb1ce0cbc014c9278a Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Sat, 15 Oct 2022 21:33:32 -0700 Subject: Fix errorprone warnings that should be errors This commit is part of a large scale change to fix errorprone errors that have been downgraded to warnings in the android source tree, so that they can be promoted to errors again. The full list of changes include the following, but not all will be present in any one individual commit: BadAnnotationImplementation BadShiftAmount BanJNDI BoxedPrimitiveEquality ComparableType ComplexBooleanConstant CollectionToArraySafeParameter ConditionalExpressionNumericPromotion DangerousLiteralNull DoubleBraceInitialization DurationFrom DurationTemporalUnit EmptyTopLevelDeclaration EqualsNull EqualsReference FormatString FromTemporalAccessor GetClassOnAnnotation GetClassOnClass HashtableContains IdentityBinaryExpression IdentityHashMapBoxing InstantTemporalUnit InvalidTimeZoneID InvalidZoneId IsInstanceIncompatibleType JUnitParameterMethodNotFound LockOnBoxedPrimitive MathRoundIntLong MislabeledAndroidString MisusedDayOfYear MissingSuperCall MisusedWeekYear ModifyingCollectionWithItself NoCanIgnoreReturnValueOnClasses NonRuntimeAnnotation NullableOnContainingClass NullTernary OverridesJavaxInjectableMethod ParcelableCreator PeriodFrom PreconditionsInvalidPlaceholder ProtoBuilderReturnValueIgnored ProtoFieldNullComparison RandomModInteger RectIntersectReturnValueIgnored ReturnValueIgnored SelfAssignment SelfComparison SelfEquals SizeGreaterThanOrEqualsZero StringBuilderInitWithChar TreeToString TryFailThrowable UnnecessaryCheckNotNull UnusedCollectionModifiedInPlace XorPower See https://errorprone.info/bugpatterns for more information on the checks. Bug: 253827323 Test: m RUN_ERROR_PRONE=true javac-check Change-Id: Ie5d49b6c2010cacdb47816f30cc6dca668ae8a3e --- java/com/android/vcard/VCardParserImpl_V21.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/com/android/vcard/VCardParserImpl_V21.java b/java/com/android/vcard/VCardParserImpl_V21.java index 2fa52df..07695a5 100644 --- a/java/com/android/vcard/VCardParserImpl_V21.java +++ b/java/com/android/vcard/VCardParserImpl_V21.java @@ -481,7 +481,7 @@ import java.util.Set; || ptypeval.startsWith("X-")) && !mUnknownTypeSet.contains(ptypeval)) { mUnknownTypeSet.add(ptypeval); - Log.w(LOG_TAG, String.format("TYPE unsupported by %s: ", getVersion(), ptypeval)); + Log.w(LOG_TAG, String.format("TYPE unsupported by %s: %s", getVersion(), ptypeval)); } propertyData.addParameter(VCardConstants.PARAM_TYPE, ptypeval); } @@ -495,7 +495,7 @@ import java.util.Set; || mUnknownValueSet.contains(pvalueval))) { mUnknownValueSet.add(pvalueval); Log.w(LOG_TAG, String.format( - "The value unsupported by TYPE of %s: ", getVersion(), pvalueval)); + "The value unsupported by TYPE of %s: %s", getVersion(), pvalueval)); } propertyData.addParameter(VCardConstants.PARAM_VALUE, pvalueval); } -- cgit v1.2.3 From eea3a011e7a6f6e9a9fbe4632ae761145e9cdcd9 Mon Sep 17 00:00:00 2001 From: Kihong Seong Date: Tue, 13 Sep 2022 05:55:36 +0000 Subject: Add JapaneseUtilsTest Bug: 237467631 Test: atest JapaneseUtilsTest Change-Id: I7b69f1301da585a52bd7c4b528dc7b032c7a4f5e (cherry picked from commit 07668b6429abce0699b729e8878e0b0b420fdab7) --- Android.bp | 4 +++ java/com/android/vcard/JapaneseUtils.java | 5 +++- .../com/android/vcard/tests/JapaneseUtilsTest.java | 31 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/src/com/android/vcard/tests/JapaneseUtilsTest.java diff --git a/Android.bp b/Android.bp index ac8ca69..95756f5 100644 --- a/Android.bp +++ b/Android.bp @@ -27,4 +27,8 @@ java_library { "//apex_available:platform", "com.android.bluetooth", ], + + libs: [ + "framework-annotations-lib", + ] } diff --git a/java/com/android/vcard/JapaneseUtils.java b/java/com/android/vcard/JapaneseUtils.java index 5b44944..7079648 100644 --- a/java/com/android/vcard/JapaneseUtils.java +++ b/java/com/android/vcard/JapaneseUtils.java @@ -16,6 +16,8 @@ package com.android.vcard; +import com.android.internal.annotations.VisibleForTesting; + import java.util.HashMap; import java.util.Map; @@ -23,7 +25,8 @@ import java.util.Map; * TextUtils especially for Japanese. */ /* package */ class JapaneseUtils { - static private final Map sHalfWidthMap = + @VisibleForTesting + static final Map sHalfWidthMap = new HashMap(); static { diff --git a/tests/src/com/android/vcard/tests/JapaneseUtilsTest.java b/tests/src/com/android/vcard/tests/JapaneseUtilsTest.java new file mode 100644 index 0000000..452944e --- /dev/null +++ b/tests/src/com/android/vcard/tests/JapaneseUtilsTest.java @@ -0,0 +1,31 @@ +/* + * Copyright 2022 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 com.android.vcard; + +import com.android.vcard.JapaneseUtils; + +import junit.framework.TestCase; + +public class JapaneseUtilsTest extends TestCase { + static final char TEST_CONTAINED_CHAR = '\uFFE5'; + static final char TEST_UNCONTAINED_CHAR = '\uFFF5'; + + public void testTryGetHalfWidthText() { + assertNull(JapaneseUtils.tryGetHalfWidthText(TEST_UNCONTAINED_CHAR)); + assertEquals(JapaneseUtils.tryGetHalfWidthText(TEST_CONTAINED_CHAR), "\u005C\u005C"); + } +} -- cgit v1.2.3 From 238e7083993cdb67bb3c1d103db0f802fac636f6 Mon Sep 17 00:00:00 2001 From: Kihong Seong Date: Wed, 7 Sep 2022 06:59:31 +0000 Subject: Add tests for classes in package vcard.exception This CL adds tests for: - VCardAgentNotSupportedException - VCardInvalidCommentLineException - VCardInvalidLineException - VCardNestedException - VCardNotSupportedException - VCardVersionException Bug: 237467631 Test: Ran each test with atest Change-Id: I6420bdae32c88bdc860ea4343ebd9411efc1dfc2 (cherry picked from commit 9cb240cfc3dfa5c616233421ae6290e1479db82c) --- .../android/vcard/tests/VCardExceptionTest.java | 35 --------------------- .../VCardAgentNotSupportedExceptionTest.java | 36 ++++++++++++++++++++++ .../vcard/tests/exception/VCardExceptionTest.java | 35 +++++++++++++++++++++ .../VCardInvalidCommentLineExceptionTest.java | 36 ++++++++++++++++++++++ .../exception/VCardInvalidLineExceptionTest.java | 35 +++++++++++++++++++++ .../tests/exception/VCardNestedExceptionTest.java | 35 +++++++++++++++++++++ .../exception/VCardNotSupportedExceptionTest.java | 35 +++++++++++++++++++++ .../tests/exception/VCardVersionExceptionTest.java | 35 +++++++++++++++++++++ 8 files changed, 247 insertions(+), 35 deletions(-) delete mode 100644 tests/src/com/android/vcard/tests/VCardExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardAgentNotSupportedExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardInvalidCommentLineExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardInvalidLineExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardNestedExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardNotSupportedExceptionTest.java create mode 100644 tests/src/com/android/vcard/tests/exception/VCardVersionExceptionTest.java diff --git a/tests/src/com/android/vcard/tests/VCardExceptionTest.java b/tests/src/com/android/vcard/tests/VCardExceptionTest.java deleted file mode 100644 index 6f09fad..0000000 --- a/tests/src/com/android/vcard/tests/VCardExceptionTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2022 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 com.android.vcard.tests; - -import com.android.vcard.exception.VCardException; - -import junit.framework.TestCase; - -public class VCardExceptionTest extends TestCase { - static final String TEST_MESSAGE = "message"; - - public void testExceptionWithoutMessage() { - VCardException exception = new VCardException(); - assertNull(exception.getMessage()); - } - - public void testExceptionWithMessage() { - VCardException exception = new VCardException(TEST_MESSAGE); - assertEquals(exception.getMessage(), TEST_MESSAGE); - } -} diff --git a/tests/src/com/android/vcard/tests/exception/VCardAgentNotSupportedExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardAgentNotSupportedExceptionTest.java new file mode 100644 index 0000000..c370ec0 --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardAgentNotSupportedExceptionTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardAgentNotSupportedException; + +import junit.framework.TestCase; + +public class VCardAgentNotSupportedExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardAgentNotSupportedException exception = new VCardAgentNotSupportedException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardAgentNotSupportedException exception = new VCardAgentNotSupportedException( + TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardExceptionTest.java new file mode 100644 index 0000000..6f09fad --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardException; + +import junit.framework.TestCase; + +public class VCardExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardException exception = new VCardException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardException exception = new VCardException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardInvalidCommentLineExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardInvalidCommentLineExceptionTest.java new file mode 100644 index 0000000..5a1429f --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardInvalidCommentLineExceptionTest.java @@ -0,0 +1,36 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardInvalidCommentLineException; + +import junit.framework.TestCase; + +public class VCardInvalidCommentLineExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardInvalidCommentLineException exception = new VCardInvalidCommentLineException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardInvalidCommentLineException exception = new VCardInvalidCommentLineException( + TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardInvalidLineExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardInvalidLineExceptionTest.java new file mode 100644 index 0000000..6568de8 --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardInvalidLineExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardInvalidLineException; + +import junit.framework.TestCase; + +public class VCardInvalidLineExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardInvalidLineException exception = new VCardInvalidLineException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardInvalidLineException exception = new VCardInvalidLineException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardNestedExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardNestedExceptionTest.java new file mode 100644 index 0000000..ee87dc2 --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardNestedExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardNestedException; + +import junit.framework.TestCase; + +public class VCardNestedExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardNestedException exception = new VCardNestedException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardNestedException exception = new VCardNestedException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardNotSupportedExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardNotSupportedExceptionTest.java new file mode 100644 index 0000000..0d393be --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardNotSupportedExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardNotSupportedException; + +import junit.framework.TestCase; + +public class VCardNotSupportedExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardNotSupportedException exception = new VCardNotSupportedException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardNotSupportedException exception = new VCardNotSupportedException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} diff --git a/tests/src/com/android/vcard/tests/exception/VCardVersionExceptionTest.java b/tests/src/com/android/vcard/tests/exception/VCardVersionExceptionTest.java new file mode 100644 index 0000000..1e9ed67 --- /dev/null +++ b/tests/src/com/android/vcard/tests/exception/VCardVersionExceptionTest.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022 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 com.android.vcard.tests; + +import com.android.vcard.exception.VCardVersionException; + +import junit.framework.TestCase; + +public class VCardVersionExceptionTest extends TestCase { + static final String TEST_MESSAGE = "message"; + + public void testExceptionWithoutMessage() { + VCardVersionException exception = new VCardVersionException(); + assertNull(exception.getMessage()); + } + + public void testExceptionWithMessage() { + VCardVersionException exception = new VCardVersionException(TEST_MESSAGE); + assertEquals(exception.getMessage(), TEST_MESSAGE); + } +} -- cgit v1.2.3