Fix "Send feedback about this device" option is missing issue.

When device restart & launching "Feedback" from lock screen,
the "send feedback" option will be missing. It's because
the report package cannot be found by calling from lock screen.
Update the option visibility after updatestate and add test case.

Bug: 74076963
Test: Manual test and RunSettingsRoboTests:FeedbackPreferenceControllerTest
Change-Id: I105d6f90da499423b6881f2ba808e69bd2e8595d
This commit is contained in:
wayneyang
2018-03-21 20:05:09 +08:00
parent cbf9300cd2
commit 77f5ad5c4a
2 changed files with 25 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ import static org.mockito.Mockito.when;
import android.app.Fragment;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -38,12 +40,19 @@ public class FeedbackPreferenceControllerTest {
private Fragment mFragment;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext;
@Mock
private Preference mPreference;
@Mock
private PreferenceScreen mScreen;
private FeedbackPreferenceController mController;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mController = new FeedbackPreferenceController(mFragment, mContext);
final String prefKey = mController.getPreferenceKey();
when(mScreen.findPreference(prefKey)).thenReturn(mPreference);
}
@Test
@@ -51,4 +60,10 @@ public class FeedbackPreferenceControllerTest {
when(mContext.getResources().getString(anyInt())).thenReturn("");
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isVisible_afterUpdateState_shouldBeSameAsIsAvailable() {
mController.updateState(mPreference);
assertThat(mPreference.isVisible()).isEqualTo(mController.isAvailable());
}
}