blob: 9e946faf2a52ba445d0d89bc9d527abb5ee7bd34 [file] [log] [blame]
Robert Snoeberger046ee9c2019-01-10 18:29:38 -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
20import android.test.suitebuilder.annotation.SmallTest;
21import android.testing.AndroidTestingRunner;
22import android.testing.TestableLooper.RunWithLooper;
23import android.view.LayoutInflater;
24import android.view.View;
25import android.view.ViewGroup;
26import android.widget.TextView;
27
28import com.android.systemui.SysuiTestCase;
29
30import org.junit.Before;
31import org.junit.Test;
32import org.junit.runner.RunWith;
33
34@SmallTest
35@RunWith(AndroidTestingRunner.class)
36@RunWithLooper
37public 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}