Merge "Disable settings nav drawer entirely."

This commit is contained in:
TreeHugger Robot
2017-02-22 20:08:34 +00:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 5 deletions

View File

@@ -465,8 +465,7 @@ public class SettingsDrawerActivity extends Activity {
}
boolean isNavDrawerEnabled() {
return !isDashboardFeatureEnabled()
|| getResources().getBoolean(R.bool.config_enable_nav_drawer);
return getResources().getBoolean(R.bool.config_enable_nav_drawer);
}
private class PackageReceiver extends BroadcastReceiver {

View File

@@ -16,6 +16,7 @@
package com.android.settingslib.drawer;
import android.app.Activity;
import android.app.Instrumentation;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
@@ -25,6 +26,8 @@ import android.support.test.runner.AndroidJUnit4;
import com.android.settingslib.R;
import com.google.common.truth.Truth;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -36,12 +39,12 @@ import static android.support.test.espresso.assertion.ViewAssertions.doesNotExis
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withContentDescription;
import static com.google.common.truth.Truth.assertThat;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class SettingsDrawerActivityTest {
@Rule
public ActivityTestRule<TestActivity> mActivityRule =
new ActivityTestRule<>(TestActivity.class, true, true);
@@ -83,6 +86,16 @@ public class SettingsDrawerActivityTest {
.check(matches(isDisplayed()));
}
@Test
public void startActivity_shouldNotHaveNavDrawer() {
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
Activity activity = instrumentation.startActivitySync(
new Intent(instrumentation.getTargetContext(), TestActivity.class));
assertThat(((SettingsDrawerActivity) activity).isNavDrawerEnabled())
.isFalse();
}
/**
* Test Activity in this test.
*

View File

@@ -21,12 +21,12 @@ import android.content.Context;
import android.content.Intent;
import android.util.Pair;
import com.android.settingslib.SettingLibRobolectricTestRunner;
import com.android.settingslib.TestConfig;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
@@ -35,7 +35,7 @@ import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
@RunWith(RobolectricTestRunner.class)
@RunWith(SettingLibRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class CategoryManagerTest {