Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 1 | /* |
| 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 Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 17 | package com.android.systemui.statusbar.notification.row.wrapper; |
Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 18 | |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 19 | import android.testing.AndroidTestingRunner; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 20 | import android.testing.TestableLooper; |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 21 | import android.testing.TestableLooper.RunWithLooper; |
Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 22 | import android.view.View; |
| 23 | import android.widget.RemoteViews; |
| 24 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 25 | import androidx.test.filters.SmallTest; |
| 26 | |
Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 27 | import com.android.systemui.R; |
Jason Monk | fba8faf | 2017-05-23 10:42:59 -0400 | [diff] [blame] | 28 | import com.android.systemui.SysuiTestCase; |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 29 | import com.android.systemui.statusbar.NotificationTestHelper; |
| 30 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 31 | |
| 32 | import org.junit.Assert; |
| 33 | import org.junit.Before; |
| 34 | import org.junit.Test; |
| 35 | import org.junit.runner.RunWith; |
| 36 | |
| 37 | @SmallTest |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 38 | @RunWith(AndroidTestingRunner.class) |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 39 | @RunWithLooper |
Jason Monk | fba8faf | 2017-05-23 10:42:59 -0400 | [diff] [blame] | 40 | public class NotificationCustomViewWrapperTest extends SysuiTestCase { |
Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 41 | |
Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 42 | private ExpandableNotificationRow mRow; |
| 43 | |
| 44 | @Before |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 45 | public void setUp() throws Exception { |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 46 | com.android.systemui.util.Assert.sMainLooper = TestableLooper.get(this).getLooper(); |
Selim Cinek | 515b203 | 2017-11-15 10:20:19 -0800 | [diff] [blame] | 47 | mRow = new NotificationTestHelper(mContext).createRow(); |
Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 48 | } |
| 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 Cinek | 131f1a4 | 2017-06-05 17:50:19 -0700 | [diff] [blame] | 55 | wrap.onContentUpdated(mRow); |
| 56 | Assert.assertTrue("No background set, when applying custom background view", |
| 57 | wrap.getCustomBackgroundColor() != 0); |
Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 58 | views.reapply(mContext, v); |
Selim Cinek | 131f1a4 | 2017-06-05 17:50:19 -0700 | [diff] [blame] | 59 | wrap.onReinflated(); |
| 60 | wrap.onContentUpdated(mRow); |
| 61 | Assert.assertTrue("Reapplying a custom remote view lost it's background!", |
| 62 | wrap.getCustomBackgroundColor() != 0); |
Selim Cinek | 245090f | 2017-02-02 10:36:02 -0800 | [diff] [blame] | 63 | } |
| 64 | |
Selim Cinek | 414ad33 | 2017-02-24 19:06:12 -0800 | [diff] [blame] | 65 | } |