Adrian Roos | 7c68e29 | 2017-04-04 17:22:03 -0700 | [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 | |
Lucas Dupin | 6cfa5cd | 2019-02-14 17:33:19 -0800 | [diff] [blame] | 17 | package com.android.systemui.statusbar.notification.row.wrapper; |
| 18 | |
| 19 | import static org.mockito.Mockito.mock; |
Adrian Roos | 7c68e29 | 2017-04-04 17:22:03 -0700 | [diff] [blame] | 20 | |
| 21 | import android.content.Context; |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 22 | import android.testing.AndroidTestingRunner; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 23 | import android.testing.TestableLooper; |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 24 | import android.testing.TestableLooper.RunWithLooper; |
Adrian Roos | 7c68e29 | 2017-04-04 17:22:03 -0700 | [diff] [blame] | 25 | import android.view.View; |
Lucas Dupin | 6cfa5cd | 2019-02-14 17:33:19 -0800 | [diff] [blame] | 26 | import android.widget.LinearLayout; |
| 27 | import android.widget.TextView; |
Adrian Roos | 7c68e29 | 2017-04-04 17:22:03 -0700 | [diff] [blame] | 28 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 29 | import androidx.test.filters.SmallTest; |
| 30 | |
Jason Monk | 25a52b6 | 2017-05-23 10:42:59 -0400 | [diff] [blame] | 31 | import com.android.systemui.SysuiTestCase; |
Selim Cinek | 131f1a4 | 2017-06-05 17:50:19 -0700 | [diff] [blame] | 32 | import com.android.systemui.statusbar.NotificationTestHelper; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 33 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 34 | import com.android.systemui.util.Assert; |
Adrian Roos | 7c68e29 | 2017-04-04 17:22:03 -0700 | [diff] [blame] | 35 | |
Lucas Dupin | 6cfa5cd | 2019-02-14 17:33:19 -0800 | [diff] [blame] | 36 | import org.junit.Before; |
Adrian Roos | 7c68e29 | 2017-04-04 17:22:03 -0700 | [diff] [blame] | 37 | import org.junit.Test; |
| 38 | import org.junit.runner.RunWith; |
| 39 | |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 40 | @RunWith(AndroidTestingRunner.class) |
Jason Monk | 25a52b6 | 2017-05-23 10:42:59 -0400 | [diff] [blame] | 41 | @SmallTest |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 42 | @RunWithLooper |
Jason Monk | 25a52b6 | 2017-05-23 10:42:59 -0400 | [diff] [blame] | 43 | public class NotificationViewWrapperTest extends SysuiTestCase { |
Adrian Roos | 7c68e29 | 2017-04-04 17:22:03 -0700 | [diff] [blame] | 44 | |
Lucas Dupin | 6cfa5cd | 2019-02-14 17:33:19 -0800 | [diff] [blame] | 45 | private View mView; |
| 46 | private ExpandableNotificationRow mRow; |
| 47 | private TestableNotificationViewWrapper mNotificationViewWrapper; |
| 48 | |
| 49 | @Before |
| 50 | public void setup() throws Exception { |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 51 | Assert.sMainLooper = TestableLooper.get(this).getLooper(); |
Lucas Dupin | 6cfa5cd | 2019-02-14 17:33:19 -0800 | [diff] [blame] | 52 | mView = mock(View.class); |
| 53 | mRow = new NotificationTestHelper(getContext()).createRow(); |
| 54 | mNotificationViewWrapper = new TestableNotificationViewWrapper(mContext, mView, mRow); |
| 55 | } |
| 56 | |
| 57 | @Test |
| 58 | public void childrenNeedInversion_doesntCrash_whenOpacity() { |
| 59 | LinearLayout viewGroup = new LinearLayout(mContext); |
| 60 | TextView textView = new TextView(mContext); |
| 61 | textView.setTextColor(0xcc000000); |
| 62 | viewGroup.addView(textView); |
| 63 | |
| 64 | mNotificationViewWrapper.childrenNeedInversion(0xcc000000, viewGroup); |
Adrian Roos | 7c68e29 | 2017-04-04 17:22:03 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | static class TestableNotificationViewWrapper extends NotificationViewWrapper { |
| 68 | protected TestableNotificationViewWrapper(Context ctx, View view, |
| 69 | ExpandableNotificationRow row) { |
| 70 | super(ctx, view, row); |
| 71 | } |
| 72 | } |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 73 | } |