Robert Snoeberger | 046ee9c | 2019-01-10 18:29:38 -0500 | [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 | package com.android.keyguard.clock; |
| 17 | |
| 18 | import static com.google.common.truth.Truth.assertThat; |
| 19 | |
| 20 | import android.test.suitebuilder.annotation.SmallTest; |
| 21 | import android.testing.AndroidTestingRunner; |
| 22 | import android.testing.TestableLooper.RunWithLooper; |
| 23 | import android.view.LayoutInflater; |
| 24 | import android.view.View; |
| 25 | import android.view.ViewGroup; |
| 26 | import android.widget.TextView; |
| 27 | |
| 28 | import com.android.systemui.SysuiTestCase; |
| 29 | |
| 30 | import org.junit.Before; |
| 31 | import org.junit.Test; |
| 32 | import org.junit.runner.RunWith; |
| 33 | |
| 34 | @SmallTest |
| 35 | @RunWith(AndroidTestingRunner.class) |
| 36 | @RunWithLooper |
| 37 | public final class BubbleClockControllerTest extends SysuiTestCase { |
| 38 | |
| 39 | private BubbleClockController mClockController; |
| 40 | |
| 41 | @Before |
| 42 | public void setUp() { |
| 43 | LayoutInflater layoutInflater = LayoutInflater.from(getContext()); |
| 44 | mClockController = BubbleClockController.build(layoutInflater); |
| 45 | } |
| 46 | |
| 47 | @Test |
| 48 | public void setDarkAmount_fadeIn() { |
| 49 | ViewGroup smallClockFrame = (ViewGroup) mClockController.getView(); |
| 50 | View smallClock = smallClockFrame.getChildAt(0); |
| 51 | // WHEN dark amount is set to AOD |
| 52 | mClockController.setDarkAmount(1f); |
| 53 | // THEN small clock should not be shown. |
| 54 | assertThat(smallClock.getVisibility()).isEqualTo(View.GONE); |
| 55 | } |
| 56 | |
| 57 | @Test |
| 58 | public void setTextColor_setDigitalClock() { |
| 59 | ViewGroup smallClock = (ViewGroup) mClockController.getView(); |
| 60 | // WHEN text color is set |
| 61 | mClockController.setTextColor(42); |
| 62 | // THEN child of small clock should have text color set. |
| 63 | TextView digitalClock = (TextView) smallClock.getChildAt(0); |
| 64 | assertThat(digitalClock.getCurrentTextColor()).isEqualTo(42); |
| 65 | } |
| 66 | } |