• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 
17 package com.android.adservices.tests.adid;
18 
19 import static com.android.adservices.shared.testing.AndroidSdk.RVC;
20 
21 import static com.google.common.truth.Truth.assertWithMessage;
22 
23 import android.adservices.adid.AdId;
24 import android.adservices.adid.AdIdManager;
25 import android.adservices.exceptions.AdServicesException;
26 
27 import com.android.adservices.common.AdServicesCtsTestCase;
28 import com.android.adservices.common.AdServicesOutcomeReceiverForTests;
29 import com.android.adservices.shared.testing.annotations.RequiresSdkRange;
30 import com.android.adservices.shared.testing.concurrency.DeviceSideConcurrencyHelper;
31 
32 import org.junit.Before;
33 import org.junit.Test;
34 
35 import java.util.concurrent.Executor;
36 import java.util.concurrent.Executors;
37 
38 @RequiresSdkRange(atMost = RVC)
39 public final class AdIdManagerRvcTest extends AdServicesCtsTestCase
40         implements CtsAdIdEndToEndTestFlags {
41 
42     private static final Executor sCallbackExecutor = Executors.newCachedThreadPool();
43 
44     private AdIdManager mAdIdManager;
45 
46     @Before
setup()47     public void setup() throws Exception {
48         DeviceSideConcurrencyHelper.sleep(1000, "setup():sleeping 1s");
49 
50         mAdIdManager = AdIdManager.get(sContext);
51         assertWithMessage("AdIdManager on context %s", sContext).that(mAdIdManager).isNotNull();
52     }
53 
54     @Test
testAdIdManager_getAdId_onR_invokesCallbackOnError()55     public void testAdIdManager_getAdId_onR_invokesCallbackOnError() throws Exception {
56         AdServicesOutcomeReceiverForTests<AdId> callback =
57                 new AdServicesOutcomeReceiverForTests<>();
58 
59         mAdIdManager.getAdId(sCallbackExecutor, callback);
60 
61         callback.assertFailure(AdServicesException.class);
62     }
63 }
64