Robert Snoeberger | 4cbd159 | 2019-04-24 14:20:38 -0400 | [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.keyguard.clock |
| 18 | |
| 19 | import android.testing.AndroidTestingRunner |
| 20 | import androidx.test.filters.SmallTest |
| 21 | import com.android.systemui.SysuiTestCase |
| 22 | import com.google.common.truth.Truth.assertThat |
| 23 | import org.junit.Before |
| 24 | import org.junit.Test |
| 25 | import org.junit.runner.RunWith |
| 26 | |
| 27 | @RunWith(AndroidTestingRunner::class) |
| 28 | @SmallTest |
| 29 | class SmallClockPositionTest : SysuiTestCase() { |
| 30 | |
| 31 | private val statusBarHeight = 100 |
| 32 | private val lockPadding = 15 |
| 33 | private val lockHeight = 35 |
| 34 | private val burnInY = 20 |
| 35 | |
| 36 | private lateinit var position: SmallClockPosition |
| 37 | |
| 38 | @Before |
| 39 | fun setUp() { |
| 40 | position = SmallClockPosition(statusBarHeight, lockPadding, lockHeight, burnInY) |
| 41 | } |
| 42 | |
| 43 | @Test |
| 44 | fun loadResources() { |
| 45 | // Cover constructor taking Resources object. |
| 46 | position = SmallClockPosition(context.resources) |
| 47 | position.setDarkAmount(1f) |
| 48 | assertThat(position.preferredY).isGreaterThan(0) |
| 49 | } |
| 50 | |
| 51 | @Test |
| 52 | fun darkPosition() { |
| 53 | // GIVEN on AOD |
| 54 | position.setDarkAmount(1f) |
| 55 | // THEN Y position is statusBarHeight + lockPadding + burnInY (100 + 15 + 20 = 135) |
| 56 | assertThat(position.preferredY).isEqualTo(135) |
| 57 | } |
| 58 | |
| 59 | @Test |
| 60 | fun lockPosition() { |
| 61 | // GIVEN on lock screen |
| 62 | position.setDarkAmount(0f) |
| 63 | // THEN Y position is statusBarHeight + lockPadding + lockHeight + lockPadding |
| 64 | // (100 + 15 + 35 + 15 = 165) |
| 65 | assertThat(position.preferredY).isEqualTo(165) |
| 66 | } |
| 67 | } |