Home | History | Annotate | Download | only in statusbar
      1 /*
      2  * Copyright (C) 2014 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.anyFloat;
     20 import static org.mockito.Mockito.doNothing;
     21 import static org.mockito.Mockito.doReturn;
     22 import static org.mockito.Mockito.spy;
     23 
     24 import android.support.test.annotation.UiThreadTest;
     25 import android.support.test.filters.SmallTest;
     26 import android.support.test.runner.AndroidJUnit4;
     27 import android.view.View;
     28 
     29 import com.android.systemui.SysuiTestCase;
     30 
     31 import org.junit.Assert;
     32 import org.junit.Before;
     33 import org.junit.Test;
     34 import org.junit.runner.RunWith;
     35 
     36 @SmallTest
     37 @RunWith(AndroidJUnit4.class)
     38 public class NotificationContentViewTest extends SysuiTestCase {
     39 
     40     NotificationContentView mView;
     41 
     42     @Before
     43     @UiThreadTest
     44     public void setup() {
     45         mView = new NotificationContentView(mContext, null);
     46         ExpandableNotificationRow row = new ExpandableNotificationRow(mContext, null);
     47         ExpandableNotificationRow mockRow = spy(row);
     48         doNothing().when(mockRow).updateBackgroundAlpha(anyFloat());
     49         doReturn(10).when(mockRow).getIntrinsicHeight();
     50 
     51         mView.setContainingNotification(mockRow);
     52         mView.setHeights(10, 20, 30, 40);
     53 
     54         mView.setContractedChild(createViewWithHeight(10));
     55         mView.setExpandedChild(createViewWithHeight(20));
     56         mView.setHeadsUpChild(createViewWithHeight(30));
     57         mView.setAmbientChild(createViewWithHeight(40));
     58 
     59         mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
     60         mView.layout(0, 0, mView.getMeasuredWidth(), mView.getMeasuredHeight());
     61     }
     62 
     63     private View createViewWithHeight(int height) {
     64         View view = new View(mContext, null);
     65         view.setMinimumHeight(height);
     66         return view;
     67     }
     68 
     69     @Test
     70     @UiThreadTest
     71     public void animationStartType_getsClearedAfterUpdatingVisibilitiesWithoutAnimation() {
     72         mView.setHeadsUp(true);
     73         mView.setDark(true, false, 0);
     74         mView.setDark(false, true, 0);
     75         mView.setHeadsUpAnimatingAway(true);
     76         Assert.assertFalse(mView.isAnimatingVisibleType());
     77     }
     78 }
     79