Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35b1c20c authored by Bill Lin's avatar Bill Lin
Browse files

Implement ImageRevealHelperTest to test reveal state

Test: atest ImageRevealHelperTest
Bug: 139487871
Change-Id: Ib2fe13905b1548961aa61182a0486064c119018f
parent 63a772c0
Loading
Loading
Loading
Loading
+73 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.systemui.glwallpaper;

import static com.google.common.truth.Truth.assertThat;

import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;

import androidx.test.filters.SmallTest;

import com.android.systemui.SysuiTestCase;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class ImageRevealHelperTest extends SysuiTestCase {

    static final int ANIMATION_DURATION = 500;
    ImageRevealHelper mImageRevealHelper;
    ImageRevealHelper.RevealStateListener mRevealStateListener;

    @Before
    public void setUp() throws Exception {
        mRevealStateListener = new ImageRevealHelper.RevealStateListener() {
            @Override
            public void onRevealStateChanged() {
                // no-op
            }

            @Override
            public void onRevealStart(boolean animate) {
                // no-op
            }

            @Override
            public void onRevealEnd() {
                // no-op
            }
        };
        mImageRevealHelper = new ImageRevealHelper(mRevealStateListener);
    }

    @Test
    public void testBiometricAuthUnlockAnimateImageRevealState_shouldNotBlackoutScreen() {
        assertThat(mImageRevealHelper.getReveal()).isEqualTo(0f);

        mImageRevealHelper.updateAwake(true /* awake */, ANIMATION_DURATION);
        assertThat(mImageRevealHelper.getReveal()).isEqualTo(0f);

        // When device unlock through Biometric, should not show reveal transition
        mImageRevealHelper.updateAwake(false /* awake */, 0);
        assertThat(mImageRevealHelper.getReveal()).isEqualTo(1f);
    }
}