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;
256dceace0eddd08156e6b71c17e3de4ed5f4f2f41Jason Monkimport android.testing.AndroidTestingRunner;
266dceace0eddd08156e6b71c17e3de4ed5f4f2f41Jason Monkimport android.testing.TestableLooper.RunWithLooper;
273acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek
283acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport com.android.systemui.statusbar.ExpandableNotificationRow;
293acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport com.android.systemui.statusbar.NotificationTestHelper;
303acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek
313acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport org.junit.Before;
323acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport org.junit.Test;
333acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport org.junit.runner.RunWith;
343acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek
353acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport static org.mockito.ArgumentMatchers.any;
363acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport static org.mockito.Mockito.mock;
373acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekimport static org.mockito.Mockito.when;
383acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek
393acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek@SmallTest
406dceace0eddd08156e6b71c17e3de4ed5f4f2f41Jason Monk@RunWith(AndroidTestingRunner.class)
416dceace0eddd08156e6b71c17e3de4ed5f4f2f41Jason Monk@RunWithLooper(setAsMainLooper = true)
423acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinekpublic class ExpandHelperTest extends SysuiTestCase {
433acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek
443acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek    private ExpandableNotificationRow mRow;
453acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek    private ExpandHelper mExpandHelper;
463acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek    private ExpandHelper.Callback mCallback;
473acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek
483acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek    @Before
495ba2254df1cb71355efb0a3831581e2f2babcdbeSelim Cinek    public void setUp() throws Exception {
503acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        Context context = getContext();
513acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        mRow = new NotificationTestHelper(context).createRow();
523acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        mCallback = mock(ExpandHelper.Callback.class);
536dceace0eddd08156e6b71c17e3de4ed5f4f2f41Jason Monk        mExpandHelper = new ExpandHelper(context, mCallback, 10, 100);
543acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek    }
553acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek
563acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek    @Test
573acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek    @UiThreadTest
583acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek    public void testAnimationDoesntClearViewIfNewExpansionStarted() {
593acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        when(mCallback.getMaxExpandHeight(any())).thenReturn(100);
603acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        mExpandHelper.startExpanding(mRow, 0);
613acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        mExpandHelper.finishExpanding(false, 0);
623acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        mExpandHelper.startExpanding(mRow, 0);
633acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        ObjectAnimator scaleAnimation = mExpandHelper.getScaleAnimation();
643acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        scaleAnimation.end();
653acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek        mExpandHelper.updateExpansion();
663acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek    }
673acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek
683acdc8e7fc7e4e21f2ffb13b55d258f4a9cc460eSelim Cinek}
69