Search in sources :

Example 1 with ImportancePreference

use of com.android.settings.notification.app.ImportancePreference in project android_packages_apps_Settings by omnirom.

the class ImportancePreferenceTest method onBindViewHolder_nonConfigurable.

@Test
public void onBindViewHolder_nonConfigurable() {
    final ImportancePreference preference = new ImportancePreference(mContext);
    final LayoutInflater inflater = LayoutInflater.from(mContext);
    PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.notif_importance_preference, null));
    Drawable unselected = mock(Drawable.class);
    Drawable selected = mock(Drawable.class);
    preference.selectedBackground = selected;
    preference.unselectedBackground = unselected;
    preference.setConfigurable(false);
    preference.setImportance(IMPORTANCE_DEFAULT);
    preference.onBindViewHolder(holder);
    assertThat(holder.itemView.findViewById(R.id.silence).isEnabled()).isFalse();
    assertThat(holder.itemView.findViewById(R.id.alert).isEnabled()).isFalse();
    assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected);
    assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(unselected);
    // other button
    preference.setImportance(IMPORTANCE_LOW);
    holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.notif_importance_preference, null));
    preference.onBindViewHolder(holder);
    assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
    assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected);
}
Also used : ImportancePreference(com.android.settings.notification.app.ImportancePreference) LayoutInflater(android.view.LayoutInflater) Drawable(android.graphics.drawable.Drawable) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 2 with ImportancePreference

use of com.android.settings.notification.app.ImportancePreference in project android_packages_apps_Settings by omnirom.

the class ImportancePreferenceTest method setImportanceSummary.

@Test
public void setImportanceSummary() {
    final ImportancePreference preference = spy(new ImportancePreference(mContext));
    final LayoutInflater inflater = LayoutInflater.from(mContext);
    final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.notif_importance_preference, null));
    preference.setConfigurable(true);
    preference.setImportance(IMPORTANCE_DEFAULT);
    preference.onBindViewHolder(holder);
    TextView tv = holder.itemView.findViewById(R.id.silence_summary);
    preference.setDisplayInStatusBar(true);
    preference.setDisplayOnLockscreen(true);
    preference.setImportanceSummary((ViewGroup) holder.itemView, IMPORTANCE_LOW, true);
    assertThat(tv.getText()).isEqualTo(mContext.getString(R.string.notification_channel_summary_low));
}
Also used : ImportancePreference(com.android.settings.notification.app.ImportancePreference) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 3 with ImportancePreference

use of com.android.settings.notification.app.ImportancePreference in project android_packages_apps_Settings by omnirom.

the class ImportancePreferenceTest method createNewPreference_shouldSetLayout.

@Test
public void createNewPreference_shouldSetLayout() {
    final ImportancePreference preference = new ImportancePreference(mContext);
    assertThat(preference.getLayoutResource()).isEqualTo(R.layout.notif_importance_preference);
}
Also used : ImportancePreference(com.android.settings.notification.app.ImportancePreference) Test(org.junit.Test)

Example 4 with ImportancePreference

use of com.android.settings.notification.app.ImportancePreference in project android_packages_apps_Settings by omnirom.

the class ImportancePreferenceTest method onBindViewHolder_selectButtonAndText.

@Test
public void onBindViewHolder_selectButtonAndText() {
    final ImportancePreference preference = new ImportancePreference(mContext);
    final LayoutInflater inflater = LayoutInflater.from(mContext);
    final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.notif_importance_preference, null));
    Drawable unselected = mock(Drawable.class);
    Drawable selected = mock(Drawable.class);
    preference.selectedBackground = selected;
    preference.unselectedBackground = unselected;
    preference.setConfigurable(true);
    preference.setImportance(IMPORTANCE_DEFAULT);
    preference.onBindViewHolder(holder);
    assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(selected);
    assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(unselected);
    assertThat(((TextView) holder.itemView.findViewById(R.id.alert_summary)).getText()).isEqualTo(mContext.getString(R.string.notification_channel_summary_default));
}
Also used : ImportancePreference(com.android.settings.notification.app.ImportancePreference) LayoutInflater(android.view.LayoutInflater) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) Test(org.junit.Test)

Example 5 with ImportancePreference

use of com.android.settings.notification.app.ImportancePreference in project android_packages_apps_Settings by omnirom.

the class ImportancePreferenceTest method onClick_changesUICallsListener.

@Test
public void onClick_changesUICallsListener() {
    final ImportancePreference preference = spy(new ImportancePreference(mContext));
    final LayoutInflater inflater = LayoutInflater.from(mContext);
    final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests(inflater.inflate(R.layout.notif_importance_preference, null));
    Drawable unselected = mock(Drawable.class);
    Drawable selected = mock(Drawable.class);
    preference.selectedBackground = selected;
    preference.unselectedBackground = unselected;
    preference.setConfigurable(true);
    preference.setImportance(IMPORTANCE_DEFAULT);
    preference.onBindViewHolder(holder);
    View silenceButton = holder.itemView.findViewById(R.id.silence);
    silenceButton.callOnClick();
    assertThat(holder.itemView.findViewById(R.id.alert).getBackground()).isEqualTo(unselected);
    assertThat(holder.itemView.findViewById(R.id.silence).getBackground()).isEqualTo(selected);
    verify(preference, times(1)).callChangeListener(IMPORTANCE_LOW);
}
Also used : ImportancePreference(com.android.settings.notification.app.ImportancePreference) LayoutInflater(android.view.LayoutInflater) Drawable(android.graphics.drawable.Drawable) PreferenceViewHolder(androidx.preference.PreferenceViewHolder) TextView(android.widget.TextView) View(android.view.View) Test(org.junit.Test)

Aggregations

ImportancePreference (com.android.settings.notification.app.ImportancePreference)6 Test (org.junit.Test)6 LayoutInflater (android.view.LayoutInflater)5 PreferenceViewHolder (androidx.preference.PreferenceViewHolder)5 TextView (android.widget.TextView)4 Drawable (android.graphics.drawable.Drawable)3 View (android.view.View)1