问题描述(Issue Description)
[CTS\GTS\VTS…Test Step] :
− cd Android-vts/tools
− vts-tradefed
− run cts-on-gsi -m CtsContactsProviderWipe -t
android.provider.cts.contactsproviderwipe.ContactsContract_Wipe#testDatabaseWipeNotification
− check the VTS test result
[CTS/GTS/VTS Version] : VTS 10_r3
[GMS/GSI Version]: GSI 10_202003
[Security Patch]: Update to 2020-04-05
[Testing Result]:
android.provider.cts.contactsproviderwipe.ContactsContract_Wipe#testDatabaseWipeNotification failed:
junit.Framework.AssertionFailedError: expected:<content://com.android.contacts/provider_status>
but was:<content://com.android.contacts>
问题分析(Analysis)
1. In testDatabaseWipeNotification function, Register an observer class to monitor ProviderStatus.CONTENT_URI.
The second parameter of registerContentObserver is set 'false'. So the observer will be notified whenever a change
occurs to the exact URI specified by <code>uri</code> or to one of the URI's ancestors in the path hierarchy.
2. In this test, ContactsContract.AUTHORITY_URI is changed in ContactsProvider2.notifyChange(). This observer is
notified and ContactsContract.AUTHORITY_URI is transmitted to callback function 'onChange'. And notifiedUri is set as
ContactsContract.AUTHORITY_URI . When execute assertEquals(ProviderStatus.CONTENT_URI, notifiedUri.get()),occur assert error.
3. The observer in this test case monitor ProviderStatus.CONTENT_URI and its ancestors in the path hierarchy. So it is
correct that the value of notifiedUri.get() is ContactsContract.AUTHORITY_URI. So this test case is unreasonable.
问题分析(Analysis)
4. Detailed code as following:
//test case
public void testDatabaseWipeNotification() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Uri> notifiedUri = new AtomicReference<>();
//register content observer for ProviderStatus.CONTENT_URI
使用来自 Partner Android Build (PAB) dashboard 的最新 CTS/GSI/VT S dev builds,来验证失败的测试,测试失败不再发生。
YES
Test Date:
2020 April 26
Test Case:
run cts-on-gsi -m CtsContactsProviderWipe -t
android.provider.cts.contactsproviderwipe.ContactsContract_
Wipe#testDatabaseWipeNotification
CTS/VTS/CTS-On-GSI dev Build Number:
build#6395341
Build Created date:
2020 April 15