• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 package com.android.settings.fingerprint;
19 
20 import static org.mockito.Matchers.any;
21 import static org.mockito.Mockito.mock;
22 import static org.mockito.Mockito.spy;
23 import static org.mockito.Mockito.when;
24 
25 import android.content.Context;
26 import android.graphics.SurfaceTexture;
27 import android.net.Uri;
28 import android.view.TextureView.SurfaceTextureListener;
29 
30 import com.android.settings.testutils.SettingsRobolectricTestRunner;
31 
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
35 import org.mockito.MockitoAnnotations;
36 import org.robolectric.RuntimeEnvironment;
37 
38 @RunWith(SettingsRobolectricTestRunner.class)
39 public class FingerprintLocationAnimationVideoViewTest {
40 
41     private FingerprintLocationAnimationVideoView mView;
42 
43     @Before
setUp()44     public void setUp() {
45         MockitoAnnotations.initMocks(this);
46         final Context context = RuntimeEnvironment.application;
47         mView = spy(new FingerprintLocationAnimationVideoView(context, null));
48     }
49 
50     @Test
onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash()51     public void onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash() {
52         mView.onFinishInflate();
53         final SurfaceTextureListener listener = mView.getSurfaceTextureListener();
54         when(mView.createMediaPlayer(any(Context.class), any(Uri.class))).thenReturn(null);
55 
56         listener.onSurfaceTextureAvailable(mock(SurfaceTexture.class), 48, 48);
57         // should not crash
58     }
59 }