mColors = new ColorExtractor.GradientColors();
updateScreenSize();
updateColorWithTint(false);
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
// We need to know about configuration changes to update the gradient size
// since it's independent from view bounds.
}
@Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+
+ ConfigurationController config = Dependency.get(ConfigurationController.class);
+ config.removeCallback(this);
+ }
+
+ @Override
protected void onDraw(Canvas canvas) {
if (mDrawAsSrc || mDrawable.getAlpha() > 0) {
if (!mHasExcludedArea) {
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
-import android.testing.AndroidTestingRunner;
import android.support.test.filters.SmallTest;
+import android.testing.AndroidTestingRunner;
+import android.testing.TestableLooper;
+import android.testing.TestableLooper.RunWithLooper;
+import android.testing.ViewUtils;
import android.view.View;
-import com.android.systemui.SysuiTestCase;
+import com.android.systemui.statusbar.policy.ConfigurationController;
+import com.android.systemui.utils.leaks.LeakCheckedTest;
import com.google.android.colorextraction.ColorExtractor;
import com.google.android.colorextraction.drawable.GradientDrawable;
@RunWith(AndroidTestingRunner.class)
@SmallTest
-public class ScrimViewTest extends SysuiTestCase {
+public class ScrimViewTest extends LeakCheckedTest {
ScrimView mView;
@Before
public void setUp() {
+ injectLeakCheckedDependency(ConfigurationController.class);
mView = new ScrimView(getContext());
mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
mView.layout(0, 0, 1920, 1080);
}
@Test
+ @RunWithLooper
+ public void testAttachDetach() {
+ ViewUtils.attachView(mView);
+ TestableLooper.get(this).processAllMessages();
+ ViewUtils.detachView(mView);
+ TestableLooper.get(this).processAllMessages();
+ }
+
+ @Test
public void testSetDrawable_UpdateDrawable() {
Drawable drawable = new ColorDrawable(Color.GREEN);
mView.setDrawable(drawable);
--- /dev/null
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package com.android.systemui.utils.leaks;
+
+import com.android.systemui.statusbar.policy.ConfigurationController;
+
+public class FakeConfigurationController
+ extends BaseLeakChecker<ConfigurationController.ConfigurationListener>
+ implements ConfigurationController {
+
+ public FakeConfigurationController(LeakCheckedTest.SysuiLeakCheck sysuiLeakCheck) {
+ super(sysuiLeakCheck, "config");
+ }
+}
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.statusbar.policy.CastController;
+import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.FlashlightController;
import com.android.systemui.statusbar.policy.HotspotController;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
PluginManager.class,
TunerService.class,
StatusBarIconController.class,
+ ConfigurationController.class,
};
@Rule
obj = new FakeTunerService(this);
} else if (cls == StatusBarIconController.class) {
obj = new FakeStatusBarIconController(this);
+ } else if (cls == ConfigurationController.class) {
+ obj = new FakeConfigurationController(this);
} else {
Assert.fail(cls.getName() + " is not supported by LeakCheckedTest yet");
}