From 29f7a7b0ae2264651c176ef50cc21cf9131247e3 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Mon, 17 Nov 2014 14:40:56 -0500 Subject: SysUI Tests: Make tests not break SysUI Now you can run the tests without getting the blank broken sysui. The tests instrument themselves so they include all of the source they need to run rather than piggybacking on the sysui process. A couple of changes were needed for this. The xml files cannot reference com.android.systemui, instead they must use res-auto. The tests can no longer make privileged calls, so some restructuring to avoid those calls was needed. Bug: 18222975 Change-Id: I67b794af854f1420583d48960bd6e52ca753b56d --- .../SystemUI/tests/src/com/android/systemui/EventLogTags.logtags | 1 + .../src/com/android/systemui/screenshot/ScreenshotStubActivity.java | 2 +- .../android/systemui/statusbar/policy/NetworkControllerBaseTest.java | 3 ++- .../systemui/statusbar/policy/NetworkControllerSignalTest.java | 5 ++++- 4 files changed, 8 insertions(+), 3 deletions(-) create mode 120000 packages/SystemUI/tests/src/com/android/systemui/EventLogTags.logtags (limited to 'packages/SystemUI/tests/src/com') diff --git a/packages/SystemUI/tests/src/com/android/systemui/EventLogTags.logtags b/packages/SystemUI/tests/src/com/android/systemui/EventLogTags.logtags new file mode 120000 index 0000000..2f243d7 --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/EventLogTags.logtags @@ -0,0 +1 @@ +../../../../../src/com/android/systemui/EventLogTags.logtags \ No newline at end of file diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotStubActivity.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotStubActivity.java index 2935373..784d035 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotStubActivity.java +++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/ScreenshotStubActivity.java @@ -15,7 +15,7 @@ */ package com.android.systemui.screenshot; -import com.android.systemui.tests.R; +import com.android.systemui.R; import android.app.Activity; import android.os.Bundle; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java index 97605ea..10cffc4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerBaseTest.java @@ -62,7 +62,8 @@ public class NetworkControllerBaseTest extends AndroidTestCase { mSignalCluster = mock(SignalCluster.class); mNetworkSignalChangedCallback = mock(NetworkSignalChangedCallback.class); - mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm); + mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, + mock(AccessPointController.class), mock(MobileDataController.class)); setupNetworkController(); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java index ed76ae5..af05309 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/NetworkControllerSignalTest.java @@ -1,5 +1,7 @@ package com.android.systemui.statusbar.policy; +import static org.mockito.Mockito.mock; + import android.net.ConnectivityManager; import android.telephony.ServiceState; import android.telephony.SignalStrength; @@ -15,7 +17,8 @@ public class NetworkControllerSignalTest extends NetworkControllerBaseTest { // Turn off mobile network support. Mockito.when(mMockCm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE)).thenReturn(false); // Create a new NetworkController as this is currently handled in constructor. - mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm); + mNetworkController = new NetworkControllerImpl(mContext, mMockCm, mMockTm, mMockWm, + mock(AccessPointController.class), mock(MobileDataController.class)); setupNetworkController(); verifyLastMobileDataIndicators(false, 0, 0); -- cgit v1.1