1 /*
2  * Copyright (C) 2022 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 android.system.helpers;
18 
19 import androidx.test.platform.app.InstrumentationRegistry;
20 import androidx.test.uiautomator.By;
21 import androidx.test.uiautomator.BySelector;
22 import androidx.test.uiautomator.UiDevice;
23 import androidx.test.uiautomator.Until;
24 
25 public class NavigationControlHelper {
26 
27     private static final BySelector NAVIGATION_BAR_VIEW =
28             By.res("com.android.systemui", "navigation_bar_view");
29 
30     private static final UiDevice sDevice =
31             UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
32 
assertNavigationBarNotVisible()33     public static void assertNavigationBarNotVisible() {
34         final boolean navBarInvisible = sDevice.wait(Until.gone(NAVIGATION_BAR_VIEW), 2_000);
35         if (!navBarInvisible) {
36             throw new AssertionError("Navigation bar is visible, expected: invisible");
37         }
38     }
39 }
40