blob: b56986eb80d06f295be60e5cce0c7561ce354e99 [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
Robert Snoeberger9ad03f42019-02-28 14:47:49 -050020import android.content.res.Resources;
Robert Snoebergerf2af1202019-06-05 14:38:01 -040021import android.graphics.Color;
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050022import android.test.suitebuilder.annotation.SmallTest;
23import android.testing.AndroidTestingRunner;
24import android.testing.TestableLooper.RunWithLooper;
25import android.view.LayoutInflater;
26import android.view.View;
27import android.view.ViewGroup;
28import android.widget.TextView;
29
30import com.android.systemui.SysuiTestCase;
Robert Snoeberger2ba20602019-03-29 14:25:39 -040031import com.android.systemui.colorextraction.SysuiColorExtractor;
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050032
33import org.junit.Before;
34import org.junit.Test;
35import org.junit.runner.RunWith;
Robert Snoeberger2ba20602019-03-29 14:25:39 -040036import org.mockito.Mock;
37import org.mockito.MockitoAnnotations;
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050038
39@SmallTest
40@RunWith(AndroidTestingRunner.class)
41@RunWithLooper
42public final class BubbleClockControllerTest extends SysuiTestCase {
43
44 private BubbleClockController mClockController;
Robert Snoeberger2ba20602019-03-29 14:25:39 -040045 @Mock SysuiColorExtractor mMockColorExtractor;
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050046
47 @Before
48 public void setUp() {
Robert Snoeberger2ba20602019-03-29 14:25:39 -040049 MockitoAnnotations.initMocks(this);
50
Robert Snoeberger9ad03f42019-02-28 14:47:49 -050051 Resources res = getContext().getResources();
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050052 LayoutInflater layoutInflater = LayoutInflater.from(getContext());
Robert Snoeberger2ba20602019-03-29 14:25:39 -040053 mClockController = new BubbleClockController(res, layoutInflater, mMockColorExtractor);
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050054 }
55
56 @Test
Robert Snoeberger69956802019-04-16 16:55:21 -040057 public void setDarkAmount_AOD() {
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050058 ViewGroup smallClockFrame = (ViewGroup) mClockController.getView();
59 View smallClock = smallClockFrame.getChildAt(0);
60 // WHEN dark amount is set to AOD
61 mClockController.setDarkAmount(1f);
62 // THEN small clock should not be shown.
Robert Snoeberger69956802019-04-16 16:55:21 -040063 assertThat(smallClock.getVisibility()).isEqualTo(View.VISIBLE);
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050064 }
65
66 @Test
Robert Snoeberger69956802019-04-16 16:55:21 -040067 public void setColorPalette_setDigitalClock() {
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050068 ViewGroup smallClock = (ViewGroup) mClockController.getView();
69 // WHEN text color is set
Robert Snoebergerf2af1202019-06-05 14:38:01 -040070 mClockController.setColorPalette(true, new int[]{Color.RED});
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050071 // THEN child of small clock should have text color set.
72 TextView digitalClock = (TextView) smallClock.getChildAt(0);
Robert Snoebergerf2af1202019-06-05 14:38:01 -040073 assertThat(digitalClock.getCurrentTextColor()).isEqualTo(Color.RED);
Robert Snoeberger046ee9c2019-01-10 18:29:38 -050074 }
75}