1 package com.example.android.lnotifications; 2 3 import android.app.Notification; 4 import android.test.ActivityInstrumentationTestCase2; 5 6 /** 7 * Unit tests for {@link HeadsUpNotificationFragment}. 8 */ 9 public class HeadsUpNotificationFragmentTest extends 10 ActivityInstrumentationTestCase2<LNotificationActivity> { 11 12 private LNotificationActivity mActivity; 13 private HeadsUpNotificationFragment mFragment; 14 15 public HeadsUpNotificationFragmentTest() { 16 super(LNotificationActivity.class); 17 } 18 19 @Override 20 protected void setUp() throws Exception { 21 super.setUp(); 22 mActivity = getActivity(); 23 // The first tab should be {@link HeadsUpNotificationFragment}, that is tested in the 24 // {@link LNotificationActivityTest}. 25 mActivity.getActionBar().setSelectedNavigationItem(0); 26 getInstrumentation().waitForIdleSync(); 27 mFragment = (HeadsUpNotificationFragment) mActivity.getFragmentManager() 28 .findFragmentById(R.id.container); 29 } 30 31 public void testPreconditions() { 32 assertNotNull(mActivity); 33 assertNotNull(mFragment); 34 assertNotNull(mActivity.findViewById(R.id.heads_up_notification_description)); 35 assertNotNull(mActivity.findViewById(R.id.show_notification_button)); 36 assertNotNull(mActivity.findViewById(R.id.use_heads_up_checkbox)); 37 } 38 39 public void testCreateNotification_verifyFullScreenIntentIsNotNull() { 40 Notification notification = mFragment.createNotification(true); 41 assertNotNull(notification.fullScreenIntent); 42 } 43 44 public void testCreateNotification_verifyFullScreenIntentIsNull() { 45 Notification notification = mFragment.createNotification(false); 46 assertNull(notification.fullScreenIntent); 47 } 48 49 // If Mockito can be used, mock the NotificationManager and tests Notifications are actually 50 // created. 51 } 52