blob: 63e18ce722c35376ca456d2e6ef7fe98a27d23fe [file] [log] [blame]
Selim Cinek245090f2017-02-02 10:36:02 -08001/*
2 * Copyright (C) 2017 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
Rohan Shah20790b82018-07-02 17:21:04 -070017package com.android.systemui.statusbar.notification.row.wrapper;
Selim Cinek245090f2017-02-02 10:36:02 -080018
Jason Monk6dceace2018-05-15 20:24:07 -040019import android.testing.AndroidTestingRunner;
Jason Monka716bac2018-12-05 15:48:21 -050020import android.testing.TestableLooper;
Jason Monk6dceace2018-05-15 20:24:07 -040021import android.testing.TestableLooper.RunWithLooper;
Selim Cinek245090f2017-02-02 10:36:02 -080022import android.view.View;
23import android.widget.RemoteViews;
24
Brett Chabot84151d92019-02-27 15:37:59 -080025import androidx.test.filters.SmallTest;
26
Selim Cinek245090f2017-02-02 10:36:02 -080027import com.android.systemui.R;
Jason Monkfba8faf2017-05-23 10:42:59 -040028import com.android.systemui.SysuiTestCase;
Rohan Shah20790b82018-07-02 17:21:04 -070029import com.android.systemui.statusbar.NotificationTestHelper;
30import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
Selim Cinek245090f2017-02-02 10:36:02 -080031
32import org.junit.Assert;
33import org.junit.Before;
34import org.junit.Test;
35import org.junit.runner.RunWith;
36
37@SmallTest
Jason Monk6dceace2018-05-15 20:24:07 -040038@RunWith(AndroidTestingRunner.class)
Jason Monka716bac2018-12-05 15:48:21 -050039@RunWithLooper
Jason Monkfba8faf2017-05-23 10:42:59 -040040public class NotificationCustomViewWrapperTest extends SysuiTestCase {
Selim Cinek245090f2017-02-02 10:36:02 -080041
Selim Cinek245090f2017-02-02 10:36:02 -080042 private ExpandableNotificationRow mRow;
43
44 @Before
Selim Cinek515b2032017-11-15 10:20:19 -080045 public void setUp() throws Exception {
Jason Monka716bac2018-12-05 15:48:21 -050046 com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper();
Selim Cinek515b2032017-11-15 10:20:19 -080047 mRow = new NotificationTestHelper(mContext).createRow();
Selim Cinek245090f2017-02-02 10:36:02 -080048 }
49
50 @Test
51 public void testBackgroundPersists() {
52 RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.custom_view_dark);
53 View v = views.apply(mContext, null);
54 NotificationViewWrapper wrap = NotificationCustomViewWrapper.wrap(mContext, v, mRow);
Selim Cinek131f1a42017-06-05 17:50:19 -070055 wrap.onContentUpdated(mRow);
56 Assert.assertTrue("No background set, when applying custom background view",
57 wrap.getCustomBackgroundColor() != 0);
Selim Cinek245090f2017-02-02 10:36:02 -080058 views.reapply(mContext, v);
Selim Cinek131f1a42017-06-05 17:50:19 -070059 wrap.onReinflated();
60 wrap.onContentUpdated(mRow);
61 Assert.assertTrue("Reapplying a custom remote view lost it's background!",
62 wrap.getCustomBackgroundColor() != 0);
Selim Cinek245090f2017-02-02 10:36:02 -080063 }
64
Selim Cinek414ad332017-02-24 19:06:12 -080065}