Fixed crash when opening Camera Lift suggestion

Bug: 37742959
Test: manual + make RunSettingsRoboTests +
      adb shell am instrument -w com.android.settings.tests.unit
          /android.support.test.runner.AndroidJUnitRunner

Added missing SettingsGateway entry for Camera Lift Trigger settings
fragment.

Change-Id: Iddce7a672b0bb8430e3c7b3c346788fb23970636
This commit is contained in:
Daniel Sheng
2017-04-27 16:01:58 -07:00
parent 67589e7afa
commit b74914eff3
2 changed files with 68 additions and 0 deletions

View File

@@ -80,6 +80,7 @@ import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
import com.android.settings.fuelgauge.BatterySaverSettings;
import com.android.settings.fuelgauge.PowerUsageSummary;
import com.android.settings.gestures.AssistGestureSettings;
import com.android.settings.gestures.CameraLiftTriggerSettings;
import com.android.settings.gestures.DoubleTapPowerSettings;
import com.android.settings.gestures.DoubleTapScreenSettings;
import com.android.settings.gestures.DoubleTwistGestureSettings;
@@ -177,6 +178,7 @@ public class SettingsGateway {
AccountSyncSettings.class.getName(),
AssistGestureSettings.class.getName(),
SwipeToNotificationSettings.class.getName(),
CameraLiftTriggerSettings.class.getName(),
DoubleTapPowerSettings.class.getName(),
DoubleTapScreenSettings.class.getName(),
PickupGestureSettings.class.getName(),

View File

@@ -0,0 +1,66 @@
/*
* 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 com.android.settings;
import static android.support.test.espresso.Espresso.onView;
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.withText;
import static android.support.test.espresso.matcher.ViewMatchers.hasSibling;
import static org.hamcrest.Matchers.allOf;
import android.app.Instrumentation;
import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
@SmallTest
public class CameraLiftTriggerSuggestionActivityTest {
private Instrumentation mInstrumentation;
private Context mTargetContext;
@Before
public void setUp() throws Exception {
mInstrumentation = InstrumentationRegistry.getInstrumentation();
mTargetContext = mInstrumentation.getTargetContext();
}
@Test
public void launchCameraLiftTriggerSuggestion_shouldNotCrash() {
final Intent cameraTriggerSuggestionIntent = new Intent(mTargetContext,
Settings.CameraLiftTriggerSuggestionActivity.class);
final boolean cameraLiftTriggerEnabled = mTargetContext.getResources()
.getBoolean(R.bool.config_cameraLiftTriggerAvailable);
if (!cameraLiftTriggerEnabled) {
return;
}
mInstrumentation.startActivitySync(cameraTriggerSuggestionIntent);
onView(allOf(withText(R.string.camera_lift_trigger_title),
hasSibling(withText(R.string.camera_lift_trigger_summary))))
.check(matches(isDisplayed()));
}
}