Fix up the tests (yet again)

Turns out there was an actual bug in QSFooter where it was using
the wrong handler class (and not showing any of its security features),
and it would have been caught by presubmit if it was working...

Test: runtest systemui
Change-Id: Icbb19db1cc6f3f2a5f984618428ceb2899af69ab
This commit is contained in:
Jason Monk
2017-01-23 17:36:50 -05:00
parent 470ecb2c6c
commit 685db72eb7
7 changed files with 17 additions and 12 deletions

View File

@@ -60,7 +60,7 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
private AlertDialog mDialog;
private QSTileHost mHost;
protected Handler mHandler;
protected H mHandler;
private boolean mIsVisible;
private boolean mIsIconVisible;
@@ -83,7 +83,7 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene
mMainHandler = new Handler(Looper.getMainLooper());
mActivityStarter = Dependency.get(ActivityStarter.class);
mSecurityController = Dependency.get(SecurityController.class);
mHandler = new Handler((Looper) Dependency.get(Dependency.BG_LOOPER));
mHandler = new H(Dependency.get(Dependency.BG_LOOPER));
}
public void setHostEnvironment(QSTileHost host) {

View File

@@ -162,6 +162,10 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements
BatteryMeterView battery = (BatteryMeterView) findViewById(R.id.battery);
int colorSecondary = Utils.getColorAttr(getContext(), android.R.attr.textColorSecondary);
battery.setRawColors(colorForeground, colorSecondary);
mNextAlarmController = Dependency.get(NextAlarmController.class);
mUserInfoController = Dependency.get(UserInfoController.class);
mActivityStarter = Dependency.get(ActivityStarter.class);
}
@Override
@@ -259,14 +263,6 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements
mExpandIndicator.setExpanded(headerExpansionFraction > EXPAND_INDICATOR_THRESHOLD);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mNextAlarmController = Dependency.get(NextAlarmController.class);
mUserInfoController = Dependency.get(UserInfoController.class);
mActivityStarter = Dependency.get(ActivityStarter.class);
}
@Override
@VisibleForTesting
public void onDetachedFromWindow() {

View File

@@ -30,6 +30,9 @@
<uses-permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE" />
<uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_VR_MANAGER" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
<uses-permission android:name="android.permission.MANAGE_NETWORK_POLICY" />
<application>
<uses-library android:name="android.test.runner" />

View File

@@ -15,6 +15,7 @@
package com.android.systemui;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -25,6 +26,8 @@ import com.android.systemui.statusbar.policy.FlashlightController;
import org.junit.Test;
import java.io.PrintWriter;
public class DependencyTest extends SysuiTestCase {
@Test
@@ -46,8 +49,8 @@ public class DependencyTest extends SysuiTestCase {
Dumpable d = mock(Dumpable.class);
injectTestDependency("test", d);
Dependency.get("test");
mDependency.dump(null, null, null);
verify(d).dump(eq(null), eq(null), eq(null));
mDependency.dump(null, mock(PrintWriter.class), null);
verify(d).dump(eq(null), any(), eq(null));
}
@Test

View File

@@ -43,6 +43,7 @@ public abstract class SysuiTestCase {
public void SysuiSetup() throws Exception {
System.setProperty("dexmaker.share_classloader", "true");
mContext = new TestableContext(InstrumentationRegistry.getTargetContext(), this);
SystemUIFactory.createFromConfig(mContext);
mDependency = new TestDependency();
mDependency.mContext = mContext;
mDependency.start();

View File

@@ -58,6 +58,7 @@ public class QSFragmentTest extends FragmentTestCase {
@Before
public void addLeakCheckDependencies() {
injectTestDependency(Dependency.BG_LOOPER, Looper.getMainLooper());
injectMockDependency(UserSwitcherController.class);
injectLeakCheckedDependencies(BluetoothController.class, LocationController.class,
RotationLockController.class, NetworkController.class, ZenModeController.class,

View File

@@ -40,6 +40,7 @@ public class NavigationBarFragmentTest extends FragmentTestCase {
mContext.putComponent(PhoneStatusBar.class, mock(PhoneStatusBar.class));
mContext.putComponent(Recents.class, mock(Recents.class));
mContext.putComponent(Divider.class, mock(Divider.class));
mContext.addMockSystemService(Context.WINDOW_SERVICE, mock(WindowManager.class));
}
@Test