blob: 0659b4fe71cd107f7ec8a389614618c131d9949a [file] [log] [blame]
Robert Snoeberger496916b2019-01-15 18:00:58 -05001/*
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 */
16package com.android.keyguard.clock;
17
18import static com.google.common.truth.Truth.assertThat;
19
Robert Snoeberger9ad03f42019-02-28 14:47:49 -050020import android.content.res.Resources;
Robert Snoeberger496916b2019-01-15 18:00:58 -050021import android.test.suitebuilder.annotation.SmallTest;
22import android.testing.AndroidTestingRunner;
23import android.testing.TestableLooper.RunWithLooper;
24import android.view.LayoutInflater;
25import android.view.View;
26import android.view.ViewGroup;
27import android.widget.TextView;
28
29import com.android.systemui.SysuiTestCase;
30
31import org.junit.Before;
32import org.junit.Test;
33import org.junit.runner.RunWith;
34
35@SmallTest
36@RunWith(AndroidTestingRunner.class)
37@RunWithLooper
38public final class StretchAnalogClockControllerTest extends SysuiTestCase {
39
40 private StretchAnalogClockController mClockController;
41
42 @Before
43 public void setUp() {
Robert Snoeberger9ad03f42019-02-28 14:47:49 -050044 Resources res = getContext().getResources();
Robert Snoeberger496916b2019-01-15 18:00:58 -050045 LayoutInflater layoutInflater = LayoutInflater.from(getContext());
Robert Snoeberger9ad03f42019-02-28 14:47:49 -050046 mClockController = new StretchAnalogClockController(res, layoutInflater);
Robert Snoeberger496916b2019-01-15 18:00:58 -050047 }
48
49 @Test
50 public void setDarkAmount_fadeIn() {
51 ViewGroup smallClockFrame = (ViewGroup) mClockController.getView();
52 View smallClock = smallClockFrame.getChildAt(0);
53 // WHEN dark amount is set to AOD
54 mClockController.setDarkAmount(1f);
55 // THEN small clock should not be shown.
56 assertThat(smallClock.getVisibility()).isEqualTo(View.GONE);
57 }
58
59 @Test
60 public void setTextColor_setDigitalClock() {
61 ViewGroup smallClock = (ViewGroup) mClockController.getView();
62 // WHEN text color is set
63 mClockController.setTextColor(42);
64 // THEN child of small clock should have text color set.
65 TextView digitalClock = (TextView) smallClock.getChildAt(0);
66 assertThat(digitalClock.getCurrentTextColor()).isEqualTo(42);
67 }
68}