Bill Lin | 35b1c20 | 2019-12-06 13:25:25 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | package com.android.systemui.glwallpaper; |
| 18 | |
| 19 | import static com.google.common.truth.Truth.assertThat; |
| 20 | |
| 21 | import android.testing.AndroidTestingRunner; |
| 22 | import android.testing.TestableLooper; |
| 23 | |
| 24 | import androidx.test.filters.SmallTest; |
| 25 | |
| 26 | import com.android.systemui.SysuiTestCase; |
| 27 | |
| 28 | import org.junit.Before; |
| 29 | import org.junit.Test; |
| 30 | import org.junit.runner.RunWith; |
| 31 | |
| 32 | @SmallTest |
| 33 | @RunWith(AndroidTestingRunner.class) |
| 34 | @TestableLooper.RunWithLooper |
| 35 | public class ImageRevealHelperTest extends SysuiTestCase { |
| 36 | |
| 37 | static final int ANIMATION_DURATION = 500; |
| 38 | ImageRevealHelper mImageRevealHelper; |
| 39 | ImageRevealHelper.RevealStateListener mRevealStateListener; |
| 40 | |
| 41 | @Before |
| 42 | public void setUp() throws Exception { |
| 43 | mRevealStateListener = new ImageRevealHelper.RevealStateListener() { |
| 44 | @Override |
| 45 | public void onRevealStateChanged() { |
| 46 | // no-op |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public void onRevealStart(boolean animate) { |
| 51 | // no-op |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public void onRevealEnd() { |
| 56 | // no-op |
| 57 | } |
| 58 | }; |
| 59 | mImageRevealHelper = new ImageRevealHelper(mRevealStateListener); |
| 60 | } |
| 61 | |
| 62 | @Test |
| 63 | public void testBiometricAuthUnlockAnimateImageRevealState_shouldNotBlackoutScreen() { |
| 64 | assertThat(mImageRevealHelper.getReveal()).isEqualTo(0f); |
| 65 | |
| 66 | mImageRevealHelper.updateAwake(true /* awake */, ANIMATION_DURATION); |
| 67 | assertThat(mImageRevealHelper.getReveal()).isEqualTo(0f); |
| 68 | |
| 69 | // When device unlock through Biometric, should not show reveal transition |
| 70 | mImageRevealHelper.updateAwake(false /* awake */, 0); |
| 71 | assertThat(mImageRevealHelper.getReveal()).isEqualTo(1f); |
| 72 | } |
| 73 | } |