summaryrefslogtreecommitdiff
path: root/tests/autofillservice/src/android/autofillservice/cts/commontests/AutoFillServiceTestCase.java
blob: 9716c001570429a19dcfd9b7235e5ca15b2bf684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.autofillservice.cts.commontests;

import static android.autofillservice.cts.testcore.Helper.DEVICE_CONFIG_AUTOFILL_DIALOG_HINTS;
import static android.autofillservice.cts.testcore.Helper.getContext;
import static android.autofillservice.cts.testcore.InstrumentedAutoFillService.SERVICE_NAME;
import static android.content.Context.CLIPBOARD_SERVICE;

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

import static com.android.compatibility.common.util.ShellUtils.runShellCommand;

import static org.junit.Assume.assumeFalse;

import android.app.PendingIntent;
import android.autofillservice.cts.R;
import android.autofillservice.cts.activities.AbstractAutoFillActivity;
import android.autofillservice.cts.activities.AugmentedAuthActivity;
import android.autofillservice.cts.activities.AuthenticationActivity;
import android.autofillservice.cts.activities.LoginActivity;
import android.autofillservice.cts.activities.LoginImportantForCredentialManagerActivity;
import android.autofillservice.cts.activities.LoginMixedImportantForCredentialManagerActivity;
import android.autofillservice.cts.activities.PreSimpleSaveActivity;
import android.autofillservice.cts.activities.SimpleSaveActivity;
import android.autofillservice.cts.testcore.AutofillActivityTestRule;
import android.autofillservice.cts.testcore.AutofillLoggingTestRule;
import android.autofillservice.cts.testcore.AutofillTestWatcher;
import android.autofillservice.cts.testcore.Helper;
import android.autofillservice.cts.testcore.InlineUiBot;
import android.autofillservice.cts.testcore.InstrumentedAutoFillService;
import android.autofillservice.cts.testcore.InstrumentedAutoFillService.Replier;
import android.autofillservice.cts.testcore.UiBot;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.service.autofill.InlinePresentation;
import android.util.Log;
import android.view.autofill.AutofillFeatureFlags;
import android.view.autofill.AutofillManager;
import android.widget.RemoteViews;

import androidx.annotation.NonNull;
import androidx.test.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.android.compatibility.common.util.DeviceConfigStateChangerRule;
import com.android.compatibility.common.util.DisableAnimationRule;
import com.android.compatibility.common.util.RequiredFeatureRule;
import com.android.compatibility.common.util.RetryRule;
import com.android.compatibility.common.util.SafeCleanerRule;
import com.android.compatibility.common.util.SettingsStateKeeperRule;
import com.android.compatibility.common.util.TestNameUtils;
import com.android.cts.mockime.ImeSettings;
import com.android.cts.mockime.MockImeSessionRule;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.junit.runners.model.Statement;

/**
 * Placeholder for the base class for all integration tests:
 *
 * <ul>
 *   <li>{@link AutoActivityLaunch}
 *   <li>{@link ManualActivityLaunch}
 * </ul>
 *
 * <p>These classes provide the common infrastructure such as:
 *
 * <ul>
 *   <li>Preserving the autofill service settings.
 *   <li>Cleaning up test state.
 *   <li>Wrapping the test under autofill-specific test rules.
 *   <li>Launching the activity used by the test.
 * </ul>
 */
public final class AutoFillServiceTestCase {

    /**
     * Base class for all test cases that use an {@link AutofillActivityTestRule} to
     * launch the activity.
     */
    // Must be public because of @ClassRule
    public abstract static class AutoActivityLaunch<A extends AbstractAutoFillActivity>
            extends BaseTestCase {

        /**
         * Returns if inline suggestion is enabled.
         */
        protected boolean isInlineMode() {
            return false;
        }

        protected static InlineUiBot getInlineUiBot() {
            return new InlineUiBot(getContext());
        }

        protected static UiBot getDropdownUiBot() {
            return sDefaultUiBot;
        }

        @ClassRule
        public static final SettingsStateKeeperRule sPublicServiceSettingsKeeper =
                sTheRealServiceSettingsKeeper;

        protected AutoActivityLaunch() {
            super(sDefaultUiBot);
        }
        protected AutoActivityLaunch(UiBot uiBot) {
            super(uiBot);
        }

        @Override
        protected TestRule getMainTestRule() {
            // Don't try to set orientation when device is in half-opened state
            // The assumeFalse line in @Before would skip the half-opened tests.
            if(!Helper.isDeviceInState(sContext, Helper.DeviceStateEnum.HALF_FOLDED)) {
                try {
                    // Set orientation as portrait before auto-launch an activity,
                    // otherwise some tests might fail due to elements not fitting
                    // in, IME orientation, etc...
                    // Many tests will hold Activity in afterActivityLaunched() by
                    // overriding ActivityRule. If rotating after the activity has
                    // started, these tests will keep the old activity. All actions
                    // on the wrong activity did not happen as expected.
                    getDropdownUiBot().setScreenOrientation(UiBot.PORTRAIT);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            return getActivityRule();
        }

        /**
         * Gets the rule to launch the main activity for this test.
         *
         * <p><b>Note: </b>the rule must be either lazily generated or a static singleton, otherwise
         * this method could return {@code null} when the rule chain that uses it is constructed.
         *
         */
        protected abstract @NonNull AutofillActivityTestRule<A> getActivityRule();

        protected @NonNull A launchActivity(@NonNull Intent intent) {
            return getActivityRule().launchActivity(intent);
        }

        protected @NonNull A getActivity() {
            return getActivityRule().getActivity();
        }
    }

    /**
     * Base class for all test cases that don't require an {@link AutofillActivityTestRule}.
     */
    // Must be public because of @ClassRule
    public abstract static class ManualActivityLaunch extends BaseTestCase {

        @ClassRule
        public static final SettingsStateKeeperRule sPublicServiceSettingsKeeper =
                sTheRealServiceSettingsKeeper;

        protected ManualActivityLaunch() {
            this(sDefaultUiBot);
        }

        protected ManualActivityLaunch(@NonNull UiBot uiBot) {
            super(uiBot);
        }

        @Override
        protected TestRule getMainTestRule() {
            // TODO: create a NoOpTestRule on common code
            return new TestRule() {

                @Override
                public Statement apply(Statement base, Description description) {
                    // Returns a no-op statements
                    return new Statement() {
                        @Override
                        public void evaluate() throws Throwable {
                            base.evaluate();
                        }
                    };
                }
            };
        }

        protected SimpleSaveActivity startSimpleSaveActivity() throws Exception {
            final Intent intent = new Intent(mContext, SimpleSaveActivity.class)
                    .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
            mUiBot.assertShownByRelativeId(SimpleSaveActivity.ID_LABEL);
            return SimpleSaveActivity.getInstance();
        }

        protected PreSimpleSaveActivity startPreSimpleSaveActivity() throws Exception {
            final Intent intent = new Intent(mContext, PreSimpleSaveActivity.class)
                    .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
            mUiBot.assertShownByRelativeId(PreSimpleSaveActivity.ID_PRE_LABEL);
            return PreSimpleSaveActivity.getInstance();
        }

        protected LoginActivity startLoginActivity() throws Exception {
            final Intent intent = new Intent(mContext, LoginActivity.class)
                    .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
            mUiBot.assertShownByRelativeId(Helper.ID_USERNAME_LABEL);
            return LoginActivity.getCurrentActivity();
        }

        protected LoginImportantForCredentialManagerActivity
                    startLoginImportantForCredentialManagerActivity() throws Exception {
            final Intent intent =
                    new Intent(mContext, LoginImportantForCredentialManagerActivity.class)
                        .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
            mUiBot.assertShownByRelativeId(Helper.ID_USERNAME_LABEL);
            return LoginImportantForCredentialManagerActivity.getCurrentActivity();
        }

        protected LoginMixedImportantForCredentialManagerActivity
                startLoginMixedImportantForCredentialManagerActivity() throws Exception {
            final Intent intent =
                    new Intent(mContext, LoginMixedImportantForCredentialManagerActivity.class)
                        .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
            mUiBot.assertShownByRelativeId(Helper.ID_USERNAME_LABEL);
            return LoginMixedImportantForCredentialManagerActivity.getCurrentActivity();
        }
    }

    @RunWith(AndroidJUnit4.class)
    // Must be public because of @ClassRule
    public abstract static class BaseTestCase {

        private static final String TAG = "AutoFillServiceTestCase";

        protected static final Replier sReplier = InstrumentedAutoFillService.getReplier();

        protected static final Context sContext = getInstrumentation().getTargetContext();

        // Hack because JUnit requires that @ClassRule instance belong to a public class.
        protected static final SettingsStateKeeperRule sTheRealServiceSettingsKeeper =
                new SettingsStateKeeperRule(sContext, Settings.Secure.AUTOFILL_SERVICE) {
            @Override
            protected void preEvaluate(Description description) {
                TestNameUtils.setCurrentTestClass(description.getClassName());
            }

            @Override
            protected void postEvaluate(Description description) {
                TestNameUtils.setCurrentTestClass(null);
            }
        };

        public static final MockImeSessionRule sMockImeSessionRule = new MockImeSessionRule(
                InstrumentationRegistry.getTargetContext(),
                InstrumentationRegistry.getInstrumentation().getUiAutomation(),
                new ImeSettings.Builder().setInlineSuggestionsEnabled(true)
                        .setInlineSuggestionViewContentDesc(InlineUiBot.SUGGESTION_STRIP_DESC));

        private final AutofillTestWatcher mTestWatcher = new AutofillTestWatcher();

        private final RetryRule mRetryRule =
                new RetryRule(getNumberRetries(), () -> {
                    // Between testing and retries, clean all launched activities to avoid
                    // exception:
                    //     Could not launch intent Intent { ... } within 45 seconds.
                    mTestWatcher.cleanAllActivities();
                    cleanAllActivities();
                });

        private final AutofillLoggingTestRule mLoggingRule = new AutofillLoggingTestRule(TAG);

        protected final SafeCleanerRule mSafeCleanerRule = new SafeCleanerRule()
                .setDumper(mLoggingRule)
                .run(() -> sReplier.assertNoUnhandledFillRequests())
                .run(() -> sReplier.assertNoUnhandledSaveRequests())
                .add(() -> {
                    return sReplier.getExceptions();
                });

        /**
         * Disable animation for UiAutomator because animation will cause the UiAutomator
         * got a wrong position and then tests failed due to click on the wrong position.
         *
         * This is annotated as @ClassRule instead of @Rule, to save time of disabling and
         * re-enabling animation for each test method.
         */
        @ClassRule
        public static DisableAnimationRule sDisableAnimationRule = new DisableAnimationRule();

        @Rule
        public final RuleChain mLookAllTheseRules = RuleChain
                //
                // requiredFeatureRule should be first so the test can be skipped right away
                .outerRule(getRequiredFeaturesRule())
                //
                // mTestWatcher should always be one the first rules, as it defines the name of the
                // test being ran and finishes dangling activities at the end
                .around(mTestWatcher)
                //
                // sMockImeSessionRule make sure MockImeSession.create() is used to launch mock IME
                .around(sMockImeSessionRule)
                //
                // mLoggingRule wraps the test but doesn't interfere with it
                .around(mLoggingRule)
                //
                // mSafeCleanerRule will catch errors
                .around(mSafeCleanerRule)
                //
                // mRetryRule should be closest to the main test as possible
                .around(mRetryRule)
                //
                // Augmented Autofill should be disabled by default
                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                        AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_SMART_SUGGESTION_SUPPORTED_MODES,
                        Integer.toString(getSmartSuggestionMode())))
                //
                // Fill Dialog should be disabled by default
                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                        AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_DIALOG_ENABLED,
                        Boolean.toString(false)))
                //
                // Hints list of Fill Dialog should be empty by default
                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                        DEVICE_CONFIG_AUTOFILL_DIALOG_HINTS,
                        ""))

                //
                // CredentialManager-Autofill integration enabled by default
                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                        AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED,
                        Boolean.toString(true)))
                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                        AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_IGNORE_VIEWS,
                        Boolean.toString(true)))

                //
                // PCC Detection should be off by default
                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                        AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_PCC_CLASSIFICATION_ENABLED,
                        Boolean.toString(false)))

                //
                // PCC Detection Hints should be empty by default
                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                        AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_PCC_FEATURE_PROVIDER_HINTS,
                        ""))


                //
                // AFAA should be off by default
                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                            AutofillFeatureFlags.
                                DEVICE_CONFIG_TRIGGER_FILL_REQUEST_ON_UNIMPORTANT_VIEW,
                            Boolean.toString(false)))

                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                            "trigger_fill_request_on_filtered_important_views",
                            Boolean.toString(false)))

                .around(new DeviceConfigStateChangerRule(sContext, DeviceConfig.NAMESPACE_AUTOFILL,
                            "include_all_autofill_type_not_none_views_in_assist_structure",
                            Boolean.toString(false)))

                //
                // Finally, let subclasses add their own rules (like ActivityTestRule)
                .around(getMainTestRule());


        protected final Context mContext = sContext;
        protected final String mPackageName;
        protected final UiBot mUiBot;

        protected static final RuleChain sRequiredFeaturesRule = RuleChain
                .outerRule(new RequiredFeatureRule(PackageManager.FEATURE_AUTOFILL))
                .around(new RequiredFeatureRule(PackageManager.FEATURE_INPUT_METHODS));

        public BaseTestCase() {
            mPackageName = mContext.getPackageName();
            mUiBot = sDefaultUiBot;
        }

        private BaseTestCase(@NonNull UiBot uiBot) {
            mPackageName = mContext.getPackageName();
            mUiBot = uiBot;
            mUiBot.reset();
        }

        protected int getSmartSuggestionMode() {
            return AutofillManager.FLAG_SMART_SUGGESTION_OFF;
        }

        /**
         * Gets how many times a test should be retried.
         *
         * @return {@code 1} by default, unless overridden by subclasses or by a global settings
         * named {@code CLASS_NAME + #getNumberRetries} or
         * {@code CtsAutoFillServiceTestCases#getNumberRetries} (the former having a higher
         * priority).
         */
        protected int getNumberRetries() {
            final String localProp = getClass().getName() + "#getNumberRetries";
            final Integer localValue = getNumberRetries(localProp);
            if (localValue != null) return localValue.intValue();

            final String globalProp = "CtsAutoFillServiceTestCases#getNumberRetries";
            final Integer globalValue = getNumberRetries(globalProp);
            if (globalValue != null) return globalValue.intValue();

            return 1;
        }

        private Integer getNumberRetries(String prop) {
            final String value = Settings.Global.getString(sContext.getContentResolver(), prop);
            if (value != null) {
                Log.i(TAG, "getNumberRetries(): overriding to " + value + " because of '" + prop
                        + "' global setting");
                try {
                    return Integer.parseInt(value);
                } catch (Exception e) {
                    Log.w(TAG, "error parsing property '" + prop + "'='" + value + "'", e);
                }
            }
            return null;
        }

        /**
         * Gets a rule that defines which features must be present for this test to run.
         *
         * <p>By default it returns a rule that requires {@link PackageManager#FEATURE_AUTOFILL},
         * but subclass can override to be more specific.
         */
        @NonNull
        protected TestRule getRequiredFeaturesRule() {
            return sRequiredFeaturesRule;
        }

        /**
         * Gets the test-specific {@link Rule @Rule}.
         *
         * <p>Sub-class <b>MUST</b> override this method instead of annotation their own rules,
         * so the order is preserved.
         *
         */
        @NonNull
        protected abstract TestRule getMainTestRule();

        @BeforeClass
        public static void disableDefaultAugmentedService() {
            Log.v(TAG, "@BeforeClass: disableDefaultAugmentedService()");
            Helper.setDefaultAugmentedAutofillServiceEnabled(false);
        }

        @AfterClass
        public static void enableDefaultAugmentedService() {
            Log.v(TAG, "@AfterClass: enableDefaultAugmentedService()");
            Helper.setDefaultAugmentedAutofillServiceEnabled(true);
        }

        @Before
        public void prepareDevice() throws Exception {
            Log.v(TAG, "@Before: prepareDevice()");

            // Unlock screen.
            runShellCommand("input keyevent KEYCODE_WAKEUP");

            // Dismiss keyguard, in case it's set as "Swipe to unlock".
            runShellCommand("wm dismiss-keyguard");

            // Collapse notifications.
            runShellCommand("cmd statusbar collapse");

            assumeFalse("Device is half-folded",
                    Helper.isDeviceInState(mContext, Helper.DeviceStateEnum.HALF_FOLDED));

            // Set orientation as portrait, otherwise some tests might fail due to elements not
            // fitting in, IME orientation, etc...
            mUiBot.setScreenOrientation(UiBot.PORTRAIT);

            // Clear Clipboard
            // TODO(b/117768051): remove try/catch once fixed
            try {
                ((ClipboardManager) mContext.getSystemService(CLIPBOARD_SERVICE))
                    .clearPrimaryClip();
            } catch (Exception e) {
                Log.e(TAG, "Ignoring exception clearing clipboard", e);
            }
        }

        @Before
        public void preTestCleanup() {
            Log.v(TAG, "@Before: preTestCleanup()");

            prepareServicePreTest();

            InstrumentedAutoFillService.resetStaticState();
            AuthenticationActivity.resetStaticState();
            AugmentedAuthActivity.resetStaticState();
            sReplier.reset();
        }

        /**
         * Prepares the service before each test - by default, disables it
         */
        protected void prepareServicePreTest() {
            Log.v(TAG, "prepareServicePreTest(): calling disableService()");
            disableService();
        }

        /**
         * Enables the {@link InstrumentedAutoFillService} for autofill for the current user.
         */
        protected void enableService() {
            Helper.enableAutofillService(SERVICE_NAME);
        }

        /**
         * Disables the {@link InstrumentedAutoFillService} for autofill for the current user.
         */
        protected void disableService() {
            Helper.disableAutofillService();
        }

        /**
         * Asserts that the {@link InstrumentedAutoFillService} is enabled for the default user.
         */
        protected void assertServiceEnabled() {
            Helper.assertAutofillServiceStatus(SERVICE_NAME, true);
        }

        /**
         * Asserts that the {@link InstrumentedAutoFillService} is disabled for the default user.
         */
        protected void assertServiceDisabled() {
            Helper.assertAutofillServiceStatus(SERVICE_NAME, false);
        }

        protected RemoteViews createPresentation(String message) {
            return Helper.createPresentation(message);
        }

        protected RemoteViews createPresentationWithCancel(String message) {
            final RemoteViews presentation = new RemoteViews(getContext()
                    .getPackageName(), R.layout.list_item_cancel);
            presentation.setTextViewText(R.id.text1, message);
            return presentation;
        }

        protected InlinePresentation createInlinePresentation(String message) {
            return Helper.createInlinePresentation(message);
        }

        protected InlinePresentation createInlinePresentation(String message,
                                                              PendingIntent attribution) {
            return Helper.createInlinePresentation(message, attribution);
        }

        @NonNull
        protected AutofillManager getAutofillManager() {
            return mContext.getSystemService(AutofillManager.class);
        }

        /**
         * Used to clean all activities that started by test case and does not control by the
         * AutofillTestWatcher.
         */
        protected void cleanAllActivities() {}
    }

    protected static final UiBot sDefaultUiBot = new UiBot();

    private AutoFillServiceTestCase() {
        throw new UnsupportedOperationException("Contain static stuff only");
    }
}