blob: fed66af07bccaabdd8d074c6d7dc1772af6662d2 [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
Selim Cinek245090f2017-02-02 10:36:02 -080019import android.support.test.filters.SmallTest;
Jason Monk6dceace2018-05-15 20:24:07 -040020import android.testing.AndroidTestingRunner;
Jason Monka716bac2018-12-05 15:48:21 -050021import android.testing.TestableLooper;
Jason Monk6dceace2018-05-15 20:24:07 -040022import android.testing.TestableLooper.RunWithLooper;
Selim Cinek245090f2017-02-02 10:36:02 -080023import android.view.View;
24import android.widget.RemoteViews;
25
26import com.android.systemui.R;
Jason Monkfba8faf2017-05-23 10:42:59 -040027import com.android.systemui.SysuiTestCase;
Rohan Shah20790b82018-07-02 17:21:04 -070028import com.android.systemui.statusbar.NotificationTestHelper;
29import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
Selim Cinek245090f2017-02-02 10:36:02 -080030
31import org.junit.Assert;
32import org.junit.Before;
33import org.junit.Test;
34import org.junit.runner.RunWith;
35
36@SmallTest
Jason Monk6dceace2018-05-15 20:24:07 -040037@RunWith(AndroidTestingRunner.class)
Jason Monka716bac2018-12-05 15:48:21 -050038@RunWithLooper
Jason Monkfba8faf2017-05-23 10:42:59 -040039public class NotificationCustomViewWrapperTest extends SysuiTestCase {
Selim Cinek245090f2017-02-02 10:36:02 -080040
Selim Cinek245090f2017-02-02 10:36:02 -080041 private ExpandableNotificationRow mRow;
42
43 @Before
Selim Cinek515b2032017-11-15 10:20:19 -080044 public void setUp() throws Exception {
Jason Monka716bac2018-12-05 15:48:21 -050045 com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper();
Selim Cinek515b2032017-11-15 10:20:19 -080046 mRow = new NotificationTestHelper(mContext).createRow();
Selim Cinek245090f2017-02-02 10:36:02 -080047 }
48
49 @Test
50 public void testBackgroundPersists() {
51 RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.custom_view_dark);
52 View v = views.apply(mContext, null);
53 NotificationViewWrapper wrap = NotificationCustomViewWrapper.wrap(mContext, v, mRow);
Selim Cinek131f1a42017-06-05 17:50:19 -070054 wrap.onContentUpdated(mRow);
55 Assert.assertTrue("No background set, when applying custom background view",
56 wrap.getCustomBackgroundColor() != 0);
Selim Cinek245090f2017-02-02 10:36:02 -080057 views.reapply(mContext, v);
Selim Cinek131f1a42017-06-05 17:50:19 -070058 wrap.onReinflated();
59 wrap.onContentUpdated(mRow);
60 Assert.assertTrue("Reapplying a custom remote view lost it's background!",
61 wrap.getCustomBackgroundColor() != 0);
Selim Cinek245090f2017-02-02 10:36:02 -080062 }
63
Selim Cinek414ad332017-02-24 19:06:12 -080064}