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