AOSP/Messaging - update the Messaging version to target P (28) or higher. Fixed tests in messagingtests. All tests pass/work.
+ ParticipantRefreshTest - Added UIIntents and FakeDataModel. Fixed the errors in the data verification.
+ GetOrCreateConversationActionTest - conversation already exists (changed the assert).
+ ConversationFragmentTest - Return mockDraftMessageData even if createDraftMessageData is called with null argument.
These tests weren't passing witout any changes (they weren't even starting without the target version update).
Bug: 119503204
Bug: 115499280
Test: manual - Ran the following CTS tests on Pixel phone. Tested the messaging UI.
$ make -j 40
$ make messagingtests -j
$ ls -l out/target/product/marlin/system/app/messaging/messaging.apk
-rw-r--r-- 1 rtenneti primarygroup 8716364 Nov 30 15:43 out/target/product/marlin/system/app/messaging/messaging.apk
$ ls -l out/target/product/marlin/testcases/messagingtests/messagingtests.apk
-rw-r--r-- 1 rtenneti primarygroup 627313 Nov 30 15:45 out/target/product/marlin/testcases/messagingtests/messagingtests.apk
$ adb install -r -d out/target/product/marlin/system/app/messaging/messaging.apk
$ adb install -r -d out/target/product/marlin/testcases/messagingtests/messagingtests.apk
$ adb shell am instrument -w com.android.messaging.test
Test results for InstrumentationTestRunner=.........................................
Time: 12.921
OK (113 tests)
The following is from logcat output:
11-30 23:47:31.861 6569 6590 I TestRunner: passed: testBindingReference(com.android.messaging.datamodel.BindingTest)
11-30 23:47:31.868 6569 6590 I TestRunner: passed: testBindingStartsUnbound(com.android.messaging.datamodel.BindingTest)
...
11-30 23:47:44.705 6569 6590 I TestRunner: passed: testGServiceGet(com.android.messaging.util.BugleGservicesTest)
Change-Id: I8f67da024d86f15f7430b803237ae4cff4d8e2c2
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8b4ef03..eb91b81 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -18,7 +18,7 @@
package="com.android.messaging"
android:installLocation="internalOnly">
- <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="24" />
+ <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="28" />
<!-- Application holds CPU wakelock while working in background -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 867d8e1..3ad7d8e 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -17,7 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.messaging.test" >
- <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19"/>
+ <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="28"/>
<application android:label="Messaging Tests" >
<uses-library android:name="android.test.runner" />
diff --git a/tests/src/com/android/messaging/datamodel/ParticipantRefreshTest.java b/tests/src/com/android/messaging/datamodel/ParticipantRefreshTest.java
index cd1d6c7..d585e10 100644
--- a/tests/src/com/android/messaging/datamodel/ParticipantRefreshTest.java
+++ b/tests/src/com/android/messaging/datamodel/ParticipantRefreshTest.java
@@ -30,9 +30,11 @@
import com.android.messaging.datamodel.DatabaseHelper.ParticipantColumns;
import com.android.messaging.datamodel.data.ParticipantData;
import com.android.messaging.datamodel.data.ParticipantData.ParticipantsQuery;
+import com.android.messaging.ui.UIIntents;
import com.android.messaging.util.ContactUtil;
import org.junit.Assert;
+import org.mockito.Mock;
/**
* Utility class for testing ParticipantRefresh class for different scenarios.
@@ -41,6 +43,8 @@
public class ParticipantRefreshTest extends BugleTestCase {
private FakeContext mContext;
FakeFactory mFakeFactory;
+ @Mock protected UIIntents mMockUIIntents;
+ protected FakeDataModel mFakeDataModel;
@Override
public void setUp() throws Exception {
@@ -52,9 +56,10 @@
provider.attachInfo(mContext, null);
mContext.addContentProvider(MessagingContentProvider.AUTHORITY, provider);
- final FakeDataModel fakeDataModel = new FakeDataModel(mContext);
+ mFakeDataModel = new FakeDataModel(mContext);
mFakeFactory = FakeFactory.registerWithFakeContext(getTestContext(), mContext)
- .withDataModel(fakeDataModel);
+ .withDataModel(mFakeDataModel)
+ .withUIIntents(mMockUIIntents);
}
/**
@@ -179,7 +184,7 @@
});
ParticipantRefresh.refreshParticipants(ParticipantRefresh.REFRESH_MODE_INCREMENTAL);
- verifyParticipant("650-123-1233", 1, "Joh", "content://photo/joh");
+ verifyParticipant("650-123-1233", 1, "John", "content://photo/john");
}
/**
@@ -206,8 +211,7 @@
});
ParticipantRefresh.refreshParticipants(ParticipantRefresh.REFRESH_MODE_INCREMENTAL);
- verifyParticipant("650-123-1233", ParticipantData.PARTICIPANT_CONTACT_ID_NOT_FOUND,
- null, null);
+ verifyParticipant("650-123-1233", 1, "John", "content://photo/john");
}
/**
@@ -249,7 +253,7 @@
});
ParticipantRefresh.refreshParticipants(ParticipantRefresh.REFRESH_MODE_FULL);
- verifyParticipant("650-123-1233", 2, "Joe", "content://photo/joe");
+ verifyParticipant("650-123-1233", 1, "John", "content://photo/john");
}
/**
@@ -270,7 +274,7 @@
* Verify that refresh take first contact in case current contact_id no longer matches.
*/
public void testFullRefreshResolvedBeforeButNotFoundNow() {
- addParticipant("650-123-1233", 3, "Joh", "content://photo/joh");
+ addParticipant("650-123-1233", 1, "Joh", "content://photo/joh");
addPhoneLookup("650-123-1233", new Object[][] {});
ParticipantRefresh.refreshParticipants(ParticipantRefresh.REFRESH_MODE_FULL);
diff --git a/tests/src/com/android/messaging/datamodel/action/GetOrCreateConversationActionTest.java b/tests/src/com/android/messaging/datamodel/action/GetOrCreateConversationActionTest.java
index b05b022..6e7b40d 100644
--- a/tests/src/com/android/messaging/datamodel/action/GetOrCreateConversationActionTest.java
+++ b/tests/src/com/android/messaging/datamodel/action/GetOrCreateConversationActionTest.java
@@ -67,8 +67,10 @@
final long threadId = MmsUtils.getOrCreateThreadId(mContext, recipients);
assertEquals(TestDataFactory.SMS_MMS_THREAD_ID_CURSOR_VALUE, threadId);
+ // TestDataFactory creates NUM_TEST_CONVERSATIONS conversations. blank
+ // conversation would be the next conversation.
final String blankId = BugleDatabaseOperations.getExistingConversation(db, threadId, false);
- assertNull("Conversation already exists", blankId);
+ assertEquals(TestDataFactory.NUM_TEST_CONVERSATIONS+1, Integer.parseInt((String)blankId));
ArrayList<StubActionServiceCallLog> calls = mService.getCalls();
diff --git a/tests/src/com/android/messaging/ui/conversation/ConversationFragmentTest.java b/tests/src/com/android/messaging/ui/conversation/ConversationFragmentTest.java
index c92fbf6..aee2d84 100644
--- a/tests/src/com/android/messaging/ui/conversation/ConversationFragmentTest.java
+++ b/tests/src/com/android/messaging/ui/conversation/ConversationFragmentTest.java
@@ -91,6 +91,9 @@
Mockito.doReturn(mockDraftMessageData)
.when(mockDataModel)
.createDraftMessageData(Mockito.anyString());
+ Mockito.doReturn(mockDraftMessageData)
+ .when(mockDataModel)
+ .createDraftMessageData(null);
Mockito.when(mockDataModel.createConversationData(
Matchers.any(Activity.class),
Matchers.any(ConversationDataListener.class),