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
17package com.android.systemui.statusbar;
18
19import android.content.Context;
20import android.support.test.InstrumentationRegistry;
21import android.support.test.annotation.UiThreadTest;
22import android.support.test.filters.FlakyTest;
23import android.support.test.filters.SmallTest;
24import android.support.test.runner.AndroidJUnit4;
25import android.view.View;
26import android.widget.RemoteViews;
27
28import com.android.systemui.R;
29import com.android.systemui.SysuiTestCase;
30import com.android.systemui.statusbar.notification.NotificationCustomViewWrapper;
31import com.android.systemui.statusbar.notification.NotificationViewWrapper;
32
33import org.junit.Assert;
34import org.junit.Before;
35import org.junit.Ignore;
36import org.junit.Test;
37import org.junit.runner.RunWith;
38
39@SmallTest
40@RunWith(AndroidJUnit4.class)
41public class NotificationCustomViewWrapperTest extends SysuiTestCase {
42
43    private ExpandableNotificationRow mRow;
44
45    @Before
46    @UiThreadTest
47    public void setUp() {
48        mRow = new ExpandableNotificationRow(mContext, null);
49    }
50
51    @Test
52    public void testBackgroundPersists() {
53        RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.custom_view_dark);
54        View v = views.apply(mContext, null);
55        NotificationViewWrapper wrap = NotificationCustomViewWrapper.wrap(mContext, v, mRow);
56        wrap.onContentUpdated(mRow);
57        Assert.assertTrue("No background set, when applying custom background view",
58                wrap.getCustomBackgroundColor() != 0);
59        views.reapply(mContext, v);
60        wrap.onReinflated();
61        wrap.onContentUpdated(mRow);
62        Assert.assertTrue("Reapplying a custom remote view lost it's background!",
63                wrap.getCustomBackgroundColor() != 0);
64    }
65
66}
67