• 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 android.content.Context;
21 import android.graphics.SurfaceTexture;
22 import android.net.Uri;
23 import android.view.TextureView.SurfaceTextureListener;
24 
25 import com.android.settings.SettingsRobolectricTestRunner;
26 import com.android.settings.TestConfig;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.mockito.Mock;
31 import org.mockito.MockitoAnnotations;
32 import org.robolectric.annotation.Config;
33 import org.robolectric.shadows.ShadowApplication;
34 
35 import static org.mockito.Matchers.any;
36 import static org.mockito.Mockito.mock;
37 import static org.mockito.Mockito.spy;
38 import static org.mockito.Mockito.when;
39 
40 @RunWith(SettingsRobolectricTestRunner.class)
41 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
42 public class FingerprintLocationAnimationVideoViewTest {
43 
44     private Context mContext;
45     private FingerprintLocationAnimationVideoView mView;
46 
47     @Before
setUp()48     public void setUp() {
49         MockitoAnnotations.initMocks(this);
50         mContext = ShadowApplication.getInstance().getApplicationContext();
51         mView = spy(new FingerprintLocationAnimationVideoView(mContext, null));
52     }
53 
54     @Test
onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash()55     public void onSurfaceTextureAvailable_nullMediaPlayer_shouldNotCrash() {
56         mView.onFinishInflate();
57         final SurfaceTextureListener listener = mView.getSurfaceTextureListener();
58         when(mView.createMediaPlayer(any(Context.class), any(Uri.class))).thenReturn(null);
59 
60         listener.onSurfaceTextureAvailable(mock(SurfaceTexture.class), 48, 48);
61         // should not crash
62     }
63 }