Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd57db6e authored by Chris Wren's avatar Chris Wren
Browse files

re-enable StatusBarTest tests

Also fix a broken test by passing the fake
logger deeper into the status bar.

Bug: 35138327
Test: runtest --path frameworks/base/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
Change-Id: I74dda6fbcf1e48d9723cd0e7f63eff4a5e561338
parent 956d00cb
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone;
import android.metrics.LogMaker;
import android.util.ArrayMap;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.systemui.EventLogConstants;
@@ -32,6 +33,7 @@ public class LockscreenGestureLogger {
    private ArrayMap<Integer, Integer> mLegacyMap;
    private LogMaker mLogMaker = new LogMaker(MetricsEvent.VIEW_UNKNOWN)
            .setType(MetricsEvent.TYPE_ACTION);
    private MetricsLogger mMetricsLogger = new MetricsLogger();

    public LockscreenGestureLogger() {
        mLegacyMap = new ArrayMap<>(EventLogConstants.METRICS_GESTURE_TYPE_MAP.length);
@@ -41,7 +43,7 @@ public class LockscreenGestureLogger {
    }

    public void write(int gesture, int length, int velocity) {
        MetricsLogger.action(mLogMaker.setCategory(gesture)
        mMetricsLogger.write(mLogMaker.setCategory(gesture)
                .setType(MetricsEvent.TYPE_ACTION)
                .addTaggedData(MetricsEvent.FIELD_GESTURE_LENGTH, length)
                .addTaggedData(MetricsEvent.FIELD_GESTURE_VELOCITY, velocity));
@@ -56,4 +58,9 @@ public class LockscreenGestureLogger {
        }
        return value;
    }

    @VisibleForTesting
    void setMetricsLogger(MetricsLogger metricsLogger) {
        mMetricsLogger = metricsLogger;
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ import android.os.Vibrator;
import android.provider.Settings;
import android.service.notification.NotificationListenerService.RankingMap;
import android.service.notification.StatusBarNotification;
import android.support.annotation.VisibleForTesting;
import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.EventLog;
@@ -751,6 +752,12 @@ public class StatusBar extends SystemUI implements DemoMode,
    private NavigationBarFragment mNavigationBar;
    private View mNavigationBarView;

    @VisibleForTesting
    void setMetricsLogger(MetricsLogger metricsLogger) {
        mMetricsLogger = metricsLogger;
        mLockscreenGestureLogger.setMetricsLogger(metricsLogger);
    }

    @Override
    public void start() {
        mNetworkController = Dependency.get(NetworkController.class);
+3 −17
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import android.metrics.LogMaker;
import android.support.test.filters.FlakyTest;
import android.support.test.filters.SmallTest;
import android.support.test.metricshelper.MetricsAsserts;
import android.support.test.runner.AndroidJUnit4;
@@ -40,7 +39,6 @@ import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -65,7 +63,8 @@ public class StatusBarTest extends SysuiTestCase {
        mStackScroller = mock(NotificationStackScrollLayout.class);
        mMetricsLogger = new FakeMetricsLogger();
        mStatusBar = new TestableStatusBar(mStatusBarKeyguardViewManager, mUnlockMethodCache,
                mKeyguardIndicationController, mStackScroller, mMetricsLogger);
                mKeyguardIndicationController, mStackScroller);
        mStatusBar.setMetricsLogger(mMetricsLogger);

        doAnswer(invocation -> {
            OnDismissAction onDismissAction = (OnDismissAction) invocation.getArguments()[0];
@@ -106,8 +105,6 @@ public class StatusBarTest extends SysuiTestCase {
        mStatusBar.executeRunnableDismissingKeyguard(null, null, false, false, false);
    }

    @Ignore("flaky test")
    @FlakyTest
    @Test
    public void lockscreenStateMetrics_notShowing() {
        // uninteresting state, except that fingerprint must be non-zero
@@ -126,8 +123,6 @@ public class StatusBarTest extends SysuiTestCase {
                        .setSubtype(0));
    }

    @Ignore("flaky test")
    @FlakyTest
    @Test
    public void lockscreenStateMetrics_notShowing_secure() {
        // uninteresting state, except that fingerprint must be non-zero
@@ -147,8 +142,6 @@ public class StatusBarTest extends SysuiTestCase {
                        .setSubtype(1));
    }

    @Ignore("flaky test")
    @FlakyTest
    @Test
    public void lockscreenStateMetrics_isShowing() {
        // uninteresting state, except that fingerprint must be non-zero
@@ -168,8 +161,6 @@ public class StatusBarTest extends SysuiTestCase {
                        .setSubtype(0));
    }

    @Ignore("flaky test")
    @FlakyTest
    @Test
    public void lockscreenStateMetrics_isShowing_secure() {
        // uninteresting state, except that fingerprint must be non-zero
@@ -189,8 +180,6 @@ public class StatusBarTest extends SysuiTestCase {
                        .setSubtype(1));
    }

    @Ignore("flaky test")
    @FlakyTest
    @Test
    public void lockscreenStateMetrics_isShowingBouncer() {
        // uninteresting state, except that fingerprint must be non-zero
@@ -210,8 +199,6 @@ public class StatusBarTest extends SysuiTestCase {
                        .setSubtype(1));
    }

    @Ignore("flaky test")
    @FlakyTest
    @Test
    public void onActivatedMetrics() {
        ActivatableNotificationView view =  mock(ActivatableNotificationView.class);
@@ -226,12 +213,11 @@ public class StatusBarTest extends SysuiTestCase {
    static class TestableStatusBar extends StatusBar {
        public TestableStatusBar(StatusBarKeyguardViewManager man,
                UnlockMethodCache unlock, KeyguardIndicationController key,
                NotificationStackScrollLayout stack, MetricsLogger logger) {
                NotificationStackScrollLayout stack) {
            mStatusBarKeyguardViewManager = man;
            mUnlockMethodCache = unlock;
            mKeyguardIndicationController = key;
            mStackScroller = stack;
            mMetricsLogger = logger;
        }

        @Override