• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.car.notification.template;
18 
19 import static android.app.PendingIntent.FLAG_IMMUTABLE;
20 
21 import static com.google.common.truth.Truth.assertThat;
22 
23 import static org.mockito.ArgumentMatchers.any;
24 import static org.mockito.ArgumentMatchers.anyInt;
25 import static org.mockito.ArgumentMatchers.eq;
26 import static org.mockito.ArgumentMatchers.nullable;
27 import static org.mockito.Mockito.doNothing;
28 import static org.mockito.Mockito.spy;
29 import static org.mockito.Mockito.verify;
30 import static org.mockito.Mockito.when;
31 
32 import android.app.Notification;
33 import android.app.PendingIntent;
34 import android.content.Context;
35 import android.content.Intent;
36 import android.graphics.drawable.Icon;
37 import android.os.Handler;
38 import android.os.UserHandle;
39 import android.service.notification.StatusBarNotification;
40 import android.view.View;
41 
42 import androidx.test.core.app.ApplicationProvider;
43 import androidx.test.ext.junit.runners.AndroidJUnit4;
44 
45 import com.android.car.assist.client.CarAssistUtils;
46 import com.android.car.notification.AlertEntry;
47 import com.android.car.notification.NotificationClickHandlerFactory;
48 import com.android.car.notification.NotificationDataManager;
49 import com.android.car.notification.R;
50 import com.android.car.notification.utils.MockMessageNotificationBuilder;
51 
52 import org.junit.Before;
53 import org.junit.Test;
54 import org.junit.runner.RunWith;
55 import org.mockito.Mock;
56 import org.mockito.MockitoAnnotations;
57 
58 @RunWith(AndroidJUnit4.class)
59 public class CarNotificationActionsViewTest {
60     private static final String PKG = "package";
61     private static final String OP_PKG = "OpPackage";
62     private static final int ID = 1;
63     private static final String TAG = "Tag";
64     private static final int UID = 2;
65     private static final int INITIAL_PID = 3;
66     private static final String CHANNEL_ID = "CHANNEL_ID";
67     private static final String CONTENT_TITLE = "CONTENT_TITLE";
68     private static final String OVERRIDE_GROUP_KEY = "OVERRIDE_GROUP_KEY";
69     private static final long POST_TIME = 12345L;
70     private static final UserHandle USER_HANDLE = new UserHandle(/* userId= */ 12);
71     private static final String TEST_KEY = "TEST_KEY";
72     private static final String ACTION_TITLE = "ACTION_TITLE";
73     private static final View.OnClickListener CLICK_LISTENER = (v) -> {
74     };
75 
76     private CarNotificationActionsView mCarNotificationActionsView;
77     private Notification.Action mAction;
78     private Context mContext;
79     private AlertEntry mMessageCategoryAlertEntry;
80     private Icon mIcon;
81     @Mock
82     private StatusBarNotification mStatusBarNotification;
83     @Mock
84     private NotificationClickHandlerFactory mNotificationClickHandlerFactory;
85     @Mock
86     private NotificationDataManager mNotificationDataManager;
87     @Mock
88     private CarAssistUtils mCarAssistUtils;
89     @Mock
90     private Context mMockContext;
91     @Mock
92     private Handler mHandler;
93 
94     @Before
setup()95     public void setup() {
96         MockitoAnnotations.initMocks(this);
97 
98         mContext = ApplicationProvider.getApplicationContext();
99         mIcon = spy(Icon.createWithResource(mContext, R.drawable.icon));
100         doNothing().when(mIcon).loadDrawableAsync(any(Context.class),
101                 nullable(Icon.OnDrawableLoadedListener.class), nullable(Handler.class));
102         initAction(/* icon= */ null);
103 
104         MockMessageNotificationBuilder messageNotificationBuilder =
105                 new MockMessageNotificationBuilder(mContext,
106                         CHANNEL_ID, android.R.drawable.sym_def_app_icon)
107                         .setContentTitle(CONTENT_TITLE)
108                         .setCategory(Notification.CATEGORY_MESSAGE)
109                         .setHasMessagingStyle(true)
110                         .setHasReplyAction(true)
111                         .setHasMuteAction(true)
112                         .setHasMarkAsRead(true);
113         mMessageCategoryAlertEntry = new AlertEntry(
114                 new StatusBarNotification(PKG, OP_PKG, ID, TAG, UID, INITIAL_PID,
115                         messageNotificationBuilder.build(), USER_HANDLE, OVERRIDE_GROUP_KEY,
116                         POST_TIME));
117         when(mStatusBarNotification.getKey()).thenReturn(TEST_KEY);
118 
119         when(mNotificationClickHandlerFactory
120                 .getPlayClickHandler(any(AlertEntry.class)))
121                 .thenReturn(CLICK_LISTENER);
122         when(mNotificationClickHandlerFactory
123                 .getReplyClickHandler(any(AlertEntry.class)))
124                 .thenReturn(CLICK_LISTENER);
125         when(mNotificationClickHandlerFactory
126                 .getMuteClickHandler(any(CarNotificationActionButton.class), any(AlertEntry.class),
127                         any(NotificationClickHandlerFactory.MuteStatusSetter.class)))
128                 .thenReturn(CLICK_LISTENER);
129         when(mNotificationClickHandlerFactory
130                 .getActionClickHandler(any(AlertEntry.class), anyInt()))
131                 .thenReturn(CLICK_LISTENER);
132         when(mNotificationClickHandlerFactory.getReplyAction(any(Notification.class)))
133                 .thenReturn(messageNotificationBuilder.getReplyAction());
134 
135         when(mCarAssistUtils.hasActiveAssistant()).thenReturn(true);
136         when(mCarAssistUtils.isFallbackAssistantEnabled()).thenReturn(false);
137     }
138 
139     @Test
onFinishInflate_addsMaxNumberOfActionButtons()140     public void onFinishInflate_addsMaxNumberOfActionButtons() {
141         finishInflateWithIsCall(/* isCall= */ false);
142 
143         assertThat(mCarNotificationActionsView.getActionButtons().size())
144                 .isEqualTo(CarNotificationActionsView.MAX_NUM_ACTIONS);
145     }
146 
147     @Test
onBind_noAction_doesNotCreateButtons()148     public void onBind_noAction_doesNotCreateButtons() {
149         finishInflateWithIsCall(/* isCall= */ false);
150         statusBarNotificationHasActions(/* hasActions= */ false);
151 
152         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
153                 new AlertEntry(mStatusBarNotification));
154 
155         for (int i = 0; i < mCarNotificationActionsView.getActionButtons().size(); i++) {
156             CarNotificationActionButton button =
157                     mCarNotificationActionsView.getActionButtons().get(i);
158             assertThat(button.getVisibility()).isNotEqualTo(View.VISIBLE);
159             assertThat(button.hasOnClickListeners()).isFalse();
160         }
161     }
162 
163     @Test
onBind_actionExists_isCarCompatibleMessage_playButtonIsVisible()164     public void onBind_actionExists_isCarCompatibleMessage_playButtonIsVisible() {
165         finishInflateWithIsCall(/* isCall= */ false);
166 
167         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
168                 mMessageCategoryAlertEntry);
169         CarNotificationActionButton playButton = mCarNotificationActionsView.getActionButtons().get(
170                 CarNotificationActionsView.FIRST_MESSAGE_ACTION_BUTTON_INDEX);
171 
172         assertThat(playButton.getVisibility()).isEqualTo(View.VISIBLE);
173     }
174 
175     @Test
onBind_actionExists_isCarCompatibleMessage_playButtonHasClickListener()176     public void onBind_actionExists_isCarCompatibleMessage_playButtonHasClickListener() {
177         finishInflateWithIsCall(/* isCall= */ false);
178 
179         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
180                 mMessageCategoryAlertEntry);
181         CarNotificationActionButton playButton = mCarNotificationActionsView.getActionButtons().get(
182                 CarNotificationActionsView.FIRST_MESSAGE_ACTION_BUTTON_INDEX);
183 
184         assertThat(playButton.hasOnClickListeners()).isTrue();
185     }
186 
187     @Test
onBind_actionExists_isCarCompatibleMessage_playButtonShowsPlayLabel()188     public void onBind_actionExists_isCarCompatibleMessage_playButtonShowsPlayLabel() {
189         finishInflateWithIsCall(/* isCall= */ false);
190 
191         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
192                 mMessageCategoryAlertEntry);
193         CarNotificationActionButton playButton = mCarNotificationActionsView.getActionButtons().get(
194                 CarNotificationActionsView.FIRST_MESSAGE_ACTION_BUTTON_INDEX);
195 
196         assertThat(playButton.getText())
197                 .isEqualTo(mContext.getString(R.string.assist_action_play_label));
198     }
199 
200     @Test
onBind_actionExists_isCarCompatibleMessage_playButtonShowsPlayDrawable()201     public void onBind_actionExists_isCarCompatibleMessage_playButtonShowsPlayDrawable() {
202         finishInflateWithIsCall(/* isCall= */ false);
203 
204         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
205                 mMessageCategoryAlertEntry);
206         CarNotificationActionButton playButton = mCarNotificationActionsView.getActionButtons().get(
207                 CarNotificationActionsView.FIRST_MESSAGE_ACTION_BUTTON_INDEX);
208 
209         assertThat(playButton.getDrawable())
210                 .isEqualTo(mCarNotificationActionsView.mPlayButtonDrawable);
211     }
212 
213     @Test
onBind_carCompatibleMessage_noAssistantNoFallback_playButtonIsHidden()214     public void onBind_carCompatibleMessage_noAssistantNoFallback_playButtonIsHidden() {
215         when(mCarAssistUtils.hasActiveAssistant()).thenReturn(false);
216         when(mCarAssistUtils.isFallbackAssistantEnabled()).thenReturn(false);
217 
218         finishInflateWithIsCall(/* isCall= */ false);
219 
220         mCarNotificationActionsView.bind(
221                 mNotificationClickHandlerFactory, mMessageCategoryAlertEntry);
222         CarNotificationActionButton playButton = mCarNotificationActionsView.getActionButtons().get(
223                 CarNotificationActionsView.FIRST_MESSAGE_ACTION_BUTTON_INDEX);
224 
225         assertThat(playButton.getVisibility()).isNotEqualTo(View.VISIBLE);
226     }
227 
228     @Test
onBind_carCompatibleMessage_noAssistantWithFallback_playButtonIsVisible()229     public void onBind_carCompatibleMessage_noAssistantWithFallback_playButtonIsVisible() {
230         when(mCarAssistUtils.hasActiveAssistant()).thenReturn(false);
231         when(mCarAssistUtils.isFallbackAssistantEnabled()).thenReturn(true);
232 
233         finishInflateWithIsCall(/* isCall= */ false);
234 
235         mCarNotificationActionsView.bind(
236                 mNotificationClickHandlerFactory, mMessageCategoryAlertEntry);
237         CarNotificationActionButton playButton = mCarNotificationActionsView.getActionButtons().get(
238                 CarNotificationActionsView.FIRST_MESSAGE_ACTION_BUTTON_INDEX);
239 
240         assertThat(playButton.getVisibility()).isEqualTo(View.VISIBLE);
241         assertThat(playButton.getText())
242                 .isEqualTo(mContext.getString(R.string.assist_action_play_label));
243         assertThat(playButton.hasOnClickListeners()).isTrue();
244     }
245 
246     @Test
onBind_actionExists_isCarCompatibleMessage_replyButtonIsVisible()247     public void onBind_actionExists_isCarCompatibleMessage_replyButtonIsVisible() {
248         finishInflateWithIsCall(/* isCall= */ false);
249 
250         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
251                 mMessageCategoryAlertEntry);
252         CarNotificationActionButton replyButton = mCarNotificationActionsView.getActionButtons()
253                 .get(CarNotificationActionsView.SECOND_MESSAGE_ACTION_BUTTON_INDEX);
254 
255         assertThat(replyButton.getVisibility()).isEqualTo(View.VISIBLE);
256     }
257 
258     @Test
onBind_actionExists_isCarCompatibleMessage_replyButtonHasClickListener()259     public void onBind_actionExists_isCarCompatibleMessage_replyButtonHasClickListener() {
260         finishInflateWithIsCall(/* isCall= */ false);
261 
262         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
263                 mMessageCategoryAlertEntry);
264         CarNotificationActionButton replyButton = mCarNotificationActionsView.getActionButtons()
265                 .get(CarNotificationActionsView.SECOND_MESSAGE_ACTION_BUTTON_INDEX);
266 
267         assertThat(replyButton.hasOnClickListeners()).isTrue();
268     }
269 
270     @Test
onBind_actionExists_isCarCompatibleMessage_replyButtonShowsReplyLabel()271     public void onBind_actionExists_isCarCompatibleMessage_replyButtonShowsReplyLabel() {
272         finishInflateWithIsCall(/* isCall= */ false);
273 
274         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
275                 mMessageCategoryAlertEntry);
276         CarNotificationActionButton replyButton = mCarNotificationActionsView.getActionButtons()
277                 .get(CarNotificationActionsView.SECOND_MESSAGE_ACTION_BUTTON_INDEX);
278 
279         assertThat(replyButton.getText())
280                 .isEqualTo(mContext.getString(R.string.assist_action_reply_label));
281     }
282 
283     @Test
onBind_actionExists_isCarCompatibleMessage_replyButtonShowsReplyDrawable()284     public void onBind_actionExists_isCarCompatibleMessage_replyButtonShowsReplyDrawable() {
285         finishInflateWithIsCall(/* isCall= */ false);
286 
287         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
288                 mMessageCategoryAlertEntry);
289         CarNotificationActionButton replyButton = mCarNotificationActionsView.getActionButtons()
290                 .get(CarNotificationActionsView.SECOND_MESSAGE_ACTION_BUTTON_INDEX);
291 
292         assertThat(replyButton.getDrawable())
293                 .isEqualTo(mCarNotificationActionsView.mReplyButtonDrawable);
294     }
295 
296     @Test
onBind_actionExists_isCarCompatibleMessage_muteButtonIsVisible()297     public void onBind_actionExists_isCarCompatibleMessage_muteButtonIsVisible() {
298         finishInflateWithIsCall(/* isCall= */ false);
299 
300         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
301                 mMessageCategoryAlertEntry);
302         CarNotificationActionButton muteButton = mCarNotificationActionsView.getActionButtons().get(
303                 CarNotificationActionsView.THIRD_MESSAGE_ACTION_BUTTON_INDEX);
304 
305         assertThat(muteButton.getVisibility()).isEqualTo(View.VISIBLE);
306     }
307 
308     @Test
onBind_actionExists_isCarCompatibleMessage_muteButtonHasClickListener()309     public void onBind_actionExists_isCarCompatibleMessage_muteButtonHasClickListener() {
310         finishInflateWithIsCall(/* isCall= */ false);
311 
312         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
313                 mMessageCategoryAlertEntry);
314         CarNotificationActionButton muteButton = mCarNotificationActionsView.getActionButtons().get(
315                 CarNotificationActionsView.THIRD_MESSAGE_ACTION_BUTTON_INDEX);
316 
317         assertThat(muteButton.hasOnClickListeners()).isTrue();
318     }
319 
320     @Test
onBind_actionExists_isCarCompatibleMessage_muted_muteButtonShowsUnmuteLabel()321     public void onBind_actionExists_isCarCompatibleMessage_muted_muteButtonShowsUnmuteLabel() {
322         finishInflateWithIsCall(/* isCall= */ false);
323         messageIsMuted(true);
324 
325         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
326                 mMessageCategoryAlertEntry);
327         CarNotificationActionButton muteButton = mCarNotificationActionsView.getActionButtons().get(
328                 CarNotificationActionsView.THIRD_MESSAGE_ACTION_BUTTON_INDEX);
329 
330         assertThat(muteButton.getText())
331                 .isEqualTo(mContext.getString(R.string.action_unmute_short));
332     }
333 
334     @Test
onBind_actionExists_isCarCompatibleMessage_unmuted_muteButtonShowsMuteLabel()335     public void onBind_actionExists_isCarCompatibleMessage_unmuted_muteButtonShowsMuteLabel() {
336         finishInflateWithIsCall(/* isCall= */ false);
337         messageIsMuted(false);
338 
339         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
340                 mMessageCategoryAlertEntry);
341         CarNotificationActionButton muteButton = mCarNotificationActionsView.getActionButtons().get(
342                 CarNotificationActionsView.THIRD_MESSAGE_ACTION_BUTTON_INDEX);
343 
344         assertThat(muteButton.getText())
345                 .isEqualTo(mContext.getString(R.string.action_mute_short));
346     }
347 
348     @Test
onBind_actionExists_notCarCompatibleMessage_buttonIsVisible()349     public void onBind_actionExists_notCarCompatibleMessage_buttonIsVisible() {
350         finishInflateWithIsCall(/* isCall= */ false);
351         statusBarNotificationHasActions(/* hasActions= */ true);
352 
353         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
354                 new AlertEntry(mStatusBarNotification));
355         CarNotificationActionButton button = mCarNotificationActionsView.getActionButtons().get(0);
356 
357         assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);
358     }
359 
360     @Test
onBind_actionExists_notCarCompatibleMessage_buttonShowsActionTitle()361     public void onBind_actionExists_notCarCompatibleMessage_buttonShowsActionTitle() {
362         finishInflateWithIsCall(/* isCall= */ false);
363         statusBarNotificationHasActions(/* hasActions= */ true);
364 
365         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
366                 new AlertEntry(mStatusBarNotification));
367         CarNotificationActionButton button = mCarNotificationActionsView.getActionButtons().get(0);
368 
369         assertThat(button.getText()).isEqualTo(ACTION_TITLE);
370     }
371 
372     @Test
onBind_actionExists_notCarCompatibleMessage_hasIntent_buttonHasClickListener()373     public void onBind_actionExists_notCarCompatibleMessage_hasIntent_buttonHasClickListener() {
374         finishInflateWithIsCall(/* isCall= */ false);
375         statusBarNotificationHasActions(/* hasActions= */ true);
376 
377         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
378                 new AlertEntry(mStatusBarNotification));
379         CarNotificationActionButton button = mCarNotificationActionsView.getActionButtons().get(0);
380 
381         assertThat(button.hasOnClickListeners()).isTrue();
382     }
383 
384     @Test
onBind_actionExists_notCarCompatibleMessage_hasNoIntent_buttonHasNoClickListener()385     public void onBind_actionExists_notCarCompatibleMessage_hasNoIntent_buttonHasNoClickListener() {
386         // Override mAction with an Action without a pending intent.
387         mAction = new Notification.Action
388                 .Builder(/* icon= */ null, ACTION_TITLE, /* pendingIntent= */ null)
389                 .build();
390 
391         finishInflateWithIsCall(/* isCall= */ false);
392         statusBarNotificationHasActions(/* hasActions= */ true);
393 
394         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
395                 new AlertEntry(mStatusBarNotification));
396         CarNotificationActionButton button = mCarNotificationActionsView.getActionButtons().get(0);
397 
398         assertThat(button.hasOnClickListeners()).isFalse();
399     }
400 
401     @Test
onBind_actionCountExceedsMaximum_notCarCompatibleMessage_doesNotThrowError()402     public void onBind_actionCountExceedsMaximum_notCarCompatibleMessage_doesNotThrowError() {
403         finishInflateWithIsCall(/* isCall= */ false);
404 
405         int numberOverMaximum = CarNotificationActionsView.MAX_NUM_ACTIONS + 10;
406         Notification.Action[] actions = new Notification.Action[numberOverMaximum];
407         for (int i = 0; i < actions.length; i++) {
408             actions[i] = mAction;
409         }
410         Notification notification = new Notification();
411         notification.actions = actions;
412         when(mStatusBarNotification.getNotification()).thenReturn(notification);
413 
414         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
415                 new AlertEntry(mStatusBarNotification));
416     }
417 
418     @Test
onBind_actionExists_notCarCompatibleMessage_isCall_firstButtonHasBackground()419     public void onBind_actionExists_notCarCompatibleMessage_isCall_firstButtonHasBackground() {
420         finishInflateWithIsCall(/* isCall= */ true);
421         statusBarNotificationHasActions(/* hasActions= */ true);
422 
423         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
424                 new AlertEntry(mStatusBarNotification));
425         CarNotificationActionButton firstButton =
426                 mCarNotificationActionsView.getActionButtons().get(0);
427 
428         assertThat(firstButton.getBackground()).isNotNull();
429     }
430 
431     @Test
onBind_actionExists_notCarCompatibleMessage_isCall_secondButtonHasBackground()432     public void onBind_actionExists_notCarCompatibleMessage_isCall_secondButtonHasBackground() {
433         finishInflateWithIsCall(/* isCall= */ true);
434         statusBarNotificationHasActions(/* hasActions= */ true);
435 
436         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
437                 new AlertEntry(mStatusBarNotification));
438         CarNotificationActionButton secondButton =
439                 mCarNotificationActionsView.getActionButtons().get(1);
440 
441         assertThat(secondButton.getBackground()).isNotNull();
442     }
443 
444     @Test
onBind_actionWithCustomIconExists_iconLoadedUsingSenderPackage()445     public void onBind_actionWithCustomIconExists_iconLoadedUsingSenderPackage() {
446         initAction(mIcon);
447         finishInflateWithIsCall(/* isCall= */ false);
448         statusBarNotificationHasActions(/* hasActions= */ true);
449         when(mStatusBarNotification.getPackageContext(nullable(Context.class))).thenReturn(
450                 mMockContext);
451 
452         mCarNotificationActionsView.bind(mNotificationClickHandlerFactory,
453                 new AlertEntry(mStatusBarNotification));
454 
455         verify(mIcon).loadDrawableAsync(eq(mMockContext),
456                 nullable(Icon.OnDrawableLoadedListener.class), nullable(Handler.class));
457     }
458 
finishInflateWithIsCall(boolean isCall)459     private void finishInflateWithIsCall(boolean isCall) {
460         mCarNotificationActionsView = new CarNotificationActionsView(
461                 mContext,
462                 /* attributeSet= */ null,
463                 /* defStyleAttr= */ 0,
464                 /* defStyleRes= */ 0,
465                 mCarAssistUtils) {
466             @Override
467             Handler getAsyncHandler() {
468                 return mHandler;
469             }
470         };
471         mCarNotificationActionsView.setCategoryIsCall(isCall);
472         mCarNotificationActionsView.onFinishInflate();
473         mCarNotificationActionsView.setNotificationDataManager(mNotificationDataManager);
474     }
475 
initAction(Icon icon)476     private void initAction(Icon icon) {
477         PendingIntent pendingIntent = PendingIntent.getForegroundService(
478                 mContext, /* requestCode= */ 0, new Intent(), FLAG_IMMUTABLE);
479         mAction = new Notification.Action
480                 .Builder(icon, ACTION_TITLE, pendingIntent).build();
481     }
482 
statusBarNotificationHasActions(boolean hasActions)483     private void statusBarNotificationHasActions(boolean hasActions) {
484         Notification notification = new Notification();
485         Notification.Action[] actions = {mAction};
486         notification.actions = hasActions ? actions : null;
487         when(mStatusBarNotification.getNotification()).thenReturn(notification);
488     }
489 
messageIsMuted(boolean isMuted)490     private void messageIsMuted(boolean isMuted) {
491         when(mNotificationDataManager.isMessageNotificationMuted(any(AlertEntry.class)))
492                 .thenReturn(isMuted);
493     }
494 }
495