| /* |
| * Copyright (C) 2022 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package com.android.wm.shell.activityembedding; |
| |
| import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; |
| |
| import static org.junit.Assert.assertNotNull; |
| import static org.junit.Assume.assumeTrue; |
| import static org.mockito.Mockito.mock; |
| |
| import android.animation.Animator; |
| import android.annotation.CallSuper; |
| import android.os.IBinder; |
| import android.view.SurfaceControl; |
| import android.window.TransitionInfo; |
| import android.window.WindowContainerToken; |
| |
| import com.android.wm.shell.ShellTestCase; |
| import com.android.wm.shell.sysui.ShellInit; |
| import com.android.wm.shell.transition.Transitions; |
| |
| import org.junit.Before; |
| import org.mockito.Mock; |
| import org.mockito.MockitoAnnotations; |
| |
| /** TestBase for ActivityEmbedding animation. */ |
| abstract class ActivityEmbeddingAnimationTestBase extends ShellTestCase { |
| |
| @Mock |
| ShellInit mShellInit; |
| @Mock |
| Transitions mTransitions; |
| @Mock |
| IBinder mTransition; |
| @Mock |
| SurfaceControl.Transaction mStartTransaction; |
| @Mock |
| SurfaceControl.Transaction mFinishTransaction; |
| @Mock |
| Transitions.TransitionFinishCallback mFinishCallback; |
| @Mock |
| Animator mAnimator; |
| |
| ActivityEmbeddingController mController; |
| ActivityEmbeddingAnimationRunner mAnimRunner; |
| ActivityEmbeddingAnimationSpec mAnimSpec; |
| |
| @CallSuper |
| @Before |
| public void setUp() { |
| assumeTrue(Transitions.ENABLE_SHELL_TRANSITIONS); |
| MockitoAnnotations.initMocks(this); |
| mController = ActivityEmbeddingController.create(mContext, mShellInit, mTransitions); |
| assertNotNull(mController); |
| mAnimRunner = mController.mAnimationRunner; |
| assertNotNull(mAnimRunner); |
| mAnimSpec = mAnimRunner.mAnimationSpec; |
| assertNotNull(mAnimSpec); |
| spyOn(mController); |
| spyOn(mAnimRunner); |
| spyOn(mAnimSpec); |
| } |
| |
| /** Creates a mock {@link TransitionInfo.Change}. */ |
| static TransitionInfo.Change createChange() { |
| return new TransitionInfo.Change(mock(WindowContainerToken.class), |
| mock(SurfaceControl.class)); |
| } |
| } |