Home | History | Annotate | Download | only in statusbar
      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;
     18 
     19 import static org.mockito.ArgumentMatchers.any;
     20 import static org.mockito.Mockito.mock;
     21 import static org.mockito.Mockito.spy;
     22 import static org.mockito.Mockito.verify;
     23 
     24 import android.content.Context;
     25 import android.support.test.InstrumentationRegistry;
     26 import android.support.test.annotation.UiThreadTest;
     27 import android.support.test.filters.FlakyTest;
     28 import android.support.test.filters.SmallTest;
     29 import android.support.test.runner.AndroidJUnit4;
     30 import android.view.View;
     31 
     32 import com.android.systemui.statusbar.stack.NotificationChildrenContainer;
     33 import com.android.systemui.SysuiTestCase;
     34 
     35 import org.junit.Assert;
     36 import org.junit.Before;
     37 import org.junit.Ignore;
     38 import org.junit.Test;
     39 import org.junit.runner.RunWith;
     40 
     41 @SmallTest
     42 @RunWith(AndroidJUnit4.class)
     43 public class ExpandableNotificationRowTest extends SysuiTestCase {
     44 
     45     private ExpandableNotificationRow mGroup;
     46     private NotificationTestHelper mNotificationTestHelper;
     47 
     48     @Before
     49     public void setUp() throws Exception {
     50         mNotificationTestHelper = new NotificationTestHelper(mContext);
     51         mGroup = mNotificationTestHelper.createGroup();
     52     }
     53 
     54     @Test
     55     public void testGroupSummaryNotShowingIconWhenPublic() {
     56         mGroup.setSensitive(true, true);
     57         mGroup.setHideSensitive(true, false, 0, 0);
     58         Assert.assertTrue(mGroup.isSummaryWithChildren());
     59         Assert.assertFalse(mGroup.isShowingIcon());
     60     }
     61 
     62     @Test
     63     public void testNotificationHeaderVisibleWhenAnimating() {
     64         mGroup.setSensitive(true, true);
     65         mGroup.setHideSensitive(true, false, 0, 0);
     66         mGroup.setHideSensitive(false, true, 0, 0);
     67         Assert.assertTrue(mGroup.getChildrenContainer().getVisibleHeader().getVisibility()
     68                 == View.VISIBLE);
     69     }
     70 
     71     @Test
     72     public void testUserLockedResetEvenWhenNoChildren() {
     73         mGroup.setUserLocked(true);
     74         mGroup.removeAllChildren();
     75         mGroup.setUserLocked(false);
     76         Assert.assertFalse("The childrencontainer should not be userlocked but is, the state "
     77                 + "seems out of sync.", mGroup.getChildrenContainer().isUserLocked());
     78     }
     79 
     80     @Test
     81     public void testReinflatedOnDensityChange() {
     82         mGroup.setUserLocked(true);
     83         mGroup.removeAllChildren();
     84         mGroup.setUserLocked(false);
     85         NotificationChildrenContainer mockContainer = mock(NotificationChildrenContainer.class);
     86         mGroup.setChildrenContainer(mockContainer);
     87         mGroup.onDensityOrFontScaleChanged();
     88         verify(mockContainer).reInflateViews(any(), any());
     89     }
     90 
     91     @Test
     92     public void testIconColorShouldBeUpdatedWhenSensitive() throws Exception {
     93         ExpandableNotificationRow row = spy(mNotificationTestHelper.createRow());
     94         row.setSensitive(true, true);
     95         row.setHideSensitive(true, false, 0, 0);
     96         verify(row).updateShelfIconColor();
     97     }
     98 
     99     @Test
    100     public void testIconColorShouldBeUpdatedWhenSettingDark() throws Exception {
    101         ExpandableNotificationRow row = spy(mNotificationTestHelper.createRow());
    102         row.setDark(true, false, 0);
    103         verify(row).updateShelfIconColor();
    104     }
    105 }
    106