Improve notification slice string on home page

Add ContextualNotificationChannelSlice to show more clear sub title on
notification slice.

Fixes: 128641319
Test: visual, robotests
Change-Id: I650102f4cde7d8d397c7a501ba9ee76c401ba9db
This commit is contained in:
Yanting Yang
2019-03-19 18:17:50 +08:00
parent e4359a9eee
commit aed7ad5a43
6 changed files with 120 additions and 7 deletions

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2019 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.homepage.contextualcards.slices;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.net.Uri;
import com.android.settings.R;
import com.android.settings.slices.CustomSliceRegistry;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
public class ContextualNotificationChannelSliceTest {
private Context mContext;
private ContextualNotificationChannelSlice mNotificationChannelSlice;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mNotificationChannelSlice = new ContextualNotificationChannelSlice(mContext);
}
@Test
public void getUri_shouldBeContextualNotificationChannelSliceUri() {
final Uri uri = mNotificationChannelSlice.getUri();
assertThat(uri).isEqualTo(CustomSliceRegistry.CONTEXTUAL_NOTIFICATION_CHANNEL_SLICE_URI);
}
@Test
public void getSubTitle_shouldBeRecentlyInstalledApp() {
final CharSequence subTitle = mNotificationChannelSlice.getSubTitle("com.test.package", 0);
assertThat(subTitle).isEqualTo(mContext.getText(R.string.recently_installed_app));
}
}