1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.adservices.common; 17 18 import com.android.adservices.common.annotations.SetDefaultLogcatTags; 19 20 import org.junit.Rule; 21 22 /** 23 * Base class for all CTS tests. 24 * 25 * <p>Contains only the bare minimum functionality required by them, like custom JUnit rules. 26 * 27 * <p>In fact, this class "reserves" the first 10 rules (as defined by order), so subclasses should 28 * start defining rules with {@code order = 11} (although for now they can use {@code order = 0} for 29 * {@code SdkLevelSupportRule}, as that rule cannot be defined here yet. 30 */ 31 @SetDefaultLogcatTags 32 public abstract class AdServicesCtsTestCase extends AdServicesTestCase { 33 34 // TODO(b/295321663): move these constants (and those from LogFactory 35 protected static final String LOGCAT_TAG_ADSERVICES = "adservices"; 36 protected static final String LOGCAT_TAG_ADSERVICES_SERVICE = LOGCAT_TAG_ADSERVICES + "-system"; 37 public static final String LOGCAT_TAG_TOPICS = LOGCAT_TAG_ADSERVICES + ".topics"; 38 public static final String LOGCAT_TAG_FLEDGE = LOGCAT_TAG_ADSERVICES + ".fledge"; 39 public static final String LOGCAT_TAG_MEASUREMENT = LOGCAT_TAG_ADSERVICES + ".measurement"; 40 protected static final String LOGCAT_TAG_UI = LOGCAT_TAG_ADSERVICES + ".ui"; 41 protected static final String LOGCAT_TAG_ADID = LOGCAT_TAG_ADSERVICES + ".adid"; 42 protected static final String LOGCAT_TAG_APPSETID = LOGCAT_TAG_ADSERVICES + ".appsetid"; 43 44 @Rule(order = 5) 45 public final AdServicesFlagsSetterRule flags = getAdServicesFlagsSetterRule(); 46 47 /** 48 * Gets the {@link AdServicesFlagsSetterRule} for this test. 49 * 50 * <p>By default returns a rule with just the bare minimum set (like {@code logcat} tags) and 51 * subclasses can customize it using class annotations (such as {@link 52 * com.android.adservices.shared.testing.annotations.SetFlagEnabled}), but subclasses could 53 * extend it to support more complex scenarios. 54 */ getAdServicesFlagsSetterRule()55 protected AdServicesFlagsSetterRule getAdServicesFlagsSetterRule() { 56 return AdServicesFlagsSetterRule.newInstance(); 57 } 58 } 59