13acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek/* 23acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * Copyright (C) 2017 The Android Open Source Project 33acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * 43acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * Licensed under the Apache License, Version 2.0 (the "License"); 53acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * you may not use this file except in compliance with the License. 63acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * You may obtain a copy of the License at 73acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * 83acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * http://www.apache.org/licenses/LICENSE-2.0 93acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * 103acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * Unless required by applicable law or agreed to in writing, software 113acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * distributed under the License is distributed on an "AS IS" BASIS, 123acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * See the License for the specific language governing permissions and 143acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek * limitations under the License 153acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek */ 163acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 173acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekpackage com.android.systemui; 183acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 193acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport android.animation.ObjectAnimator; 203acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport android.content.Context; 213acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport android.support.test.InstrumentationRegistry; 223acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport android.support.test.annotation.UiThreadTest; 233acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport android.support.test.filters.SmallTest; 243acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport android.support.test.runner.AndroidJUnit4; 253acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 263acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport com.android.systemui.statusbar.ExpandableNotificationRow; 273acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport com.android.systemui.statusbar.NotificationTestHelper; 283acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 293acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport org.junit.Before; 303acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport org.junit.Test; 313acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport org.junit.runner.RunWith; 323acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 333acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport static org.mockito.ArgumentMatchers.any; 343acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport static org.mockito.Mockito.mock; 353acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport static org.mockito.Mockito.when; 363acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 373acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek@SmallTest 383acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek@RunWith(AndroidJUnit4.class) 393acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekpublic class ExpandHelperTest extends SysuiTestCase { 403acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 413acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek private ExpandableNotificationRow mRow; 423acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek private ExpandHelper mExpandHelper; 433acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek private ExpandHelper.Callback mCallback; 443acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 453acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek @Before 462630dc7ecf16a965321cfc615104f372cd2b0e96Selim Cinek public void setUp() throws Exception { 473acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek Context context = getContext(); 483acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek mRow = new NotificationTestHelper(context).createRow(); 493acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek mCallback = mock(ExpandHelper.Callback.class); 502630dc7ecf16a965321cfc615104f372cd2b0e96Selim Cinek InstrumentationRegistry.getInstrumentation().runOnMainSync( 512630dc7ecf16a965321cfc615104f372cd2b0e96Selim Cinek () -> mExpandHelper = new ExpandHelper(context, mCallback, 10, 100)); 522630dc7ecf16a965321cfc615104f372cd2b0e96Selim Cinek 533acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek } 543acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 553acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek @Test 563acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek @UiThreadTest 573acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek public void testAnimationDoesntClearViewIfNewExpansionStarted() { 583acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek when(mCallback.getMaxExpandHeight(any())).thenReturn(100); 593acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek mExpandHelper.startExpanding(mRow, 0); 603acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek mExpandHelper.finishExpanding(false, 0); 613acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek mExpandHelper.startExpanding(mRow, 0); 623acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek ObjectAnimator scaleAnimation = mExpandHelper.getScaleAnimation(); 633acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek scaleAnimation.end(); 643acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek mExpandHelper.updateExpansion(); 653acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek } 663acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek 673acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek} 68