summaryrefslogtreecommitdiff
path: root/adservices/tests/unittest/service-core/src/com/android/adservices/download/MobileDataDownloadTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'adservices/tests/unittest/service-core/src/com/android/adservices/download/MobileDataDownloadTest.java')
-rw-r--r--adservices/tests/unittest/service-core/src/com/android/adservices/download/MobileDataDownloadTest.java60
1 files changed, 57 insertions, 3 deletions
diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/download/MobileDataDownloadTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/download/MobileDataDownloadTest.java
index 084e873bd1..ed448a8970 100644
--- a/adservices/tests/unittest/service-core/src/com/android/adservices/download/MobileDataDownloadTest.java
+++ b/adservices/tests/unittest/service-core/src/com/android/adservices/download/MobileDataDownloadTest.java
@@ -34,6 +34,7 @@ import com.android.dx.mockito.inline.extended.StaticMockitoSession;
import com.google.android.libraries.mobiledatadownload.AddFileGroupRequest;
import com.google.android.libraries.mobiledatadownload.DownloadFileGroupRequest;
+import com.google.android.libraries.mobiledatadownload.GetFileGroupRequest;
import com.google.android.libraries.mobiledatadownload.Logger;
import com.google.android.libraries.mobiledatadownload.MobileDataDownload;
import com.google.android.libraries.mobiledatadownload.TaskScheduler;
@@ -46,7 +47,6 @@ import com.google.mobiledatadownload.DownloadConfigProto.DownloadConditions.Devi
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -73,6 +73,13 @@ public class MobileDataDownloadTest {
private static final String FILE_URL_2 = "https://www.gstatic.com/suggest-dev/odws1_empty.jar";
private static final int FILE_SIZE_2 = 554;
+ private static final String TEST_MDD_TOPICS_CLASSIFIER_MANIFEST_FILE_URL =
+ "https://www.gstatic.com/mdi-serving/rubidium-adservices-topics-classifier/922/217081737fd739c74dd3ca5c407813d818526577";
+ private static final String TEST_MDD_ENROLLMENT_MANIFEST_FILE_URL =
+ "https://dl.google.com/mdi-serving/adservices/adtech_enrollment/manifest_configs/1/manifest_config_1658790241927.binaryproto";
+ public static final String TEST_TOPIC_FILE_GROUP_NAME = "topics-classifier-model";
+ public static final String TEST_ENROLLMENT_FILE_GROUP_NAME = "adtech_enrollment_data";
+
private StaticMockitoSession mStaticMockSession = null;
@Mock Flags mMockFlags;
@@ -136,16 +143,63 @@ public class MobileDataDownloadTest {
assertThat(clientFileGroup.hasAccount()).isFalse();
}
- @Ignore
+ /**
+ * This method tests topics and measurement manifest files. It downloads test classifier model
+ * and adtech enrollment data and verifies files downloaded successfully.
+ */
@Test
- public void testTopicsManifestFileGroupPopulator()
+ public void testManifestFileGroupPopulator()
throws ExecutionException, InterruptedException, TimeoutException {
+ ExtendedMockito.doReturn(mMockFlags).when(FlagsFactory::getFlagsForTest);
+ // Return a manifest URL for test only. This will download smaller size files only for
+ // testing MDD download feature.
+ doReturn(TEST_MDD_TOPICS_CLASSIFIER_MANIFEST_FILE_URL)
+ .when(mMockFlags)
+ .getMddTopicsClassifierManifestFileUrl();
+ doReturn(/*Download max download threads */ 2)
+ .when(mMockFlags)
+ .getDownloaderMaxDownloadThreads();
+ // Return production enrollment manifest file. This is a small file that will not affect
+ // running this test.
+ doReturn(TEST_MDD_ENROLLMENT_MANIFEST_FILE_URL)
+ .when(mMockFlags)
+ .getMeasurementManifestFileUrl();
+
MobileDataDownload mdd =
MobileDataDownloadFactory.getMddForTesting(
mContext, FlagsFactory.getFlagsForTest());
mdd.handleTask(TaskScheduler.WIFI_CHARGING_PERIODIC_TASK)
.get(MAX_HANDLE_TASK_WAIT_TIME_SECS, SECONDS);
+
+ ClientFileGroup clientFileGroup =
+ mdd.getFileGroup(
+ GetFileGroupRequest.newBuilder()
+ .setGroupName(TEST_TOPIC_FILE_GROUP_NAME)
+ .build())
+ .get();
+
+ // Verify topics file group.
+ assertThat(clientFileGroup.getGroupName()).isEqualTo(TEST_TOPIC_FILE_GROUP_NAME);
+ assertThat(clientFileGroup.getOwnerPackage()).isEqualTo(mContext.getPackageName());
+ assertThat(clientFileGroup.getVersionNumber())
+ .isEqualTo(/* Test filegroup version number */ 0);
+ assertThat(clientFileGroup.getFileCount()).isEqualTo(6);
+ assertThat(clientFileGroup.getBuildId()).isEqualTo(/* BuildID generated by Ingress */ 922);
+
+ clientFileGroup =
+ mdd.getFileGroup(
+ GetFileGroupRequest.newBuilder()
+ .setGroupName(TEST_ENROLLMENT_FILE_GROUP_NAME)
+ .build())
+ .get();
+
+ // Verify measurement file group
+ assertThat(clientFileGroup.getGroupName()).isEqualTo(TEST_ENROLLMENT_FILE_GROUP_NAME);
+ assertThat(clientFileGroup.getOwnerPackage()).isEqualTo(mContext.getPackageName());
+ assertThat(clientFileGroup.getFileCount()).isEqualTo(1);
+ assertThat(clientFileGroup.getVersionNumber())
+ .isEqualTo(/* Measurement filegroup version number */ 1);
}
// A helper function to create a DataFilegroup.