Files
app_Settings/tests/robotests/src/com/android/settings/gestures/ButtonNavigationSettingsFragmentTest.java
Jernej Virag 97ea279c45 Add setting to allow configuration of long press home gesture
This allows configuration of long press home gesture on 2-/3-button navigation configurations. It allows the user to enable and disable the invocation of assistant app using said gesture.

Bug: 191888710
Test: Unit tests and on a physical device.
Change-Id: I18cb290058ac5c2a748d40802b942404f548b868
2021-10-26 13:34:02 +00:00

69 lines
2.6 KiB
Java

/*
* Copyright (C) 2021 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 com.android.settings.gestures;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVERLAY;
import static com.google.common.truth.Truth.assertThat;
import static org.robolectric.Shadows.shadowOf;
import android.content.Context;
import android.content.pm.PackageInfo;
import androidx.test.core.app.ApplicationProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowPackageManager;
@RunWith(RobolectricTestRunner.class)
public class ButtonNavigationSettingsFragmentTest {
@Test
public void getNonIndexableKeys_twoAndThreeButtonNavigationNotAvailable_allKeysNonIndexable() {
assertThat(ButtonNavigationSettingsFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
ApplicationProvider.getApplicationContext())).isNotEmpty();
}
@Test
public void getNonIndexableKeys_twoButtonNavigationAvailable_allKeysIndexable() {
addPackageToPackageManager(ApplicationProvider.getApplicationContext(),
NAV_BAR_MODE_2BUTTON_OVERLAY);
assertThat(ButtonNavigationSettingsFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
ApplicationProvider.getApplicationContext())).isEmpty();
}
@Test
public void getNonIndexableKeys_threeButtonNavigationAvailable_allKeysIndexable() {
addPackageToPackageManager(ApplicationProvider.getApplicationContext(),
NAV_BAR_MODE_3BUTTON_OVERLAY);
assertThat(ButtonNavigationSettingsFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(
ApplicationProvider.getApplicationContext())).isEmpty();
}
private static void addPackageToPackageManager(Context context, String pkg) {
ShadowPackageManager shadowPm = shadowOf(context.getPackageManager());
PackageInfo pi = new PackageInfo();
pi.packageName = pkg;
shadowPm.installPackage(pi);
}
}