1 /* 2 * Copyright (C) 2017 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.systemui.statusbar.stack; 18 19 import android.support.test.filters.SmallTest; 20 import android.support.test.runner.AndroidJUnit4; 21 import android.testing.AndroidTestingRunner; 22 import android.testing.TestableLooper.RunWithLooper; 23 import android.view.NotificationHeaderView; 24 import android.view.View; 25 26 import com.android.systemui.SysuiTestCase; 27 import com.android.systemui.statusbar.ExpandableNotificationRow; 28 import com.android.systemui.statusbar.NotificationTestHelper; 29 30 import org.junit.Assert; 31 import org.junit.Before; 32 import org.junit.Test; 33 import org.junit.runner.RunWith; 34 35 @SmallTest 36 @RunWith(AndroidTestingRunner.class) 37 @RunWithLooper(setAsMainLooper = true) 38 public class NotificationChildrenContainerTest extends SysuiTestCase { 39 40 private ExpandableNotificationRow mGroup; 41 private int mId; 42 private NotificationTestHelper mNotificationTestHelper; 43 44 @Before 45 public void setUp() throws Exception { 46 mNotificationTestHelper = new NotificationTestHelper(mContext); 47 mGroup = mNotificationTestHelper.createGroup(); 48 } 49 50 @Test 51 public void testLowPriorityHeaderCleared() { 52 mGroup.setIsLowPriority(true); 53 NotificationChildrenContainer childrenContainer = mGroup.getChildrenContainer(); 54 NotificationHeaderView lowPriorityHeaderView = childrenContainer.getLowPriorityHeaderView(); 55 Assert.assertTrue(lowPriorityHeaderView.getVisibility() == View.VISIBLE); 56 Assert.assertTrue(lowPriorityHeaderView.getParent() == childrenContainer); 57 mGroup.setIsLowPriority(false); 58 Assert.assertTrue(lowPriorityHeaderView.getParent() == null); 59 Assert.assertTrue(childrenContainer.getLowPriorityHeaderView() == null); 60 } 61 62 @Test 63 public void testRecreateNotificationHeader_hasHeader() { 64 NotificationChildrenContainer childrenContainer = mGroup.getChildrenContainer(); 65 childrenContainer.recreateNotificationHeader(null); 66 Assert.assertNotNull("Children container must have a header after recreation", 67 childrenContainer.getCurrentHeaderView()); 68 } 69 } 70