Merge "Move notification service tests to be ui services tests"

This commit is contained in:
TreeHugger Robot
2017-12-07 01:16:28 +00:00
committed by Android (Google) Code Review
28 changed files with 29 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
#########################################################################
# Build FrameworksNotificationTests package
# Build FrameworksUiServicesTests package
#########################################################################
LOCAL_PATH:= $(call my-dir)
@@ -30,7 +30,7 @@ LOCAL_JAVA_LIBRARIES := android.test.runner
LOCAL_JACK_FLAGS := --multi-dex native
LOCAL_DX_FLAGS := --multi-dex
LOCAL_PACKAGE_NAME := FrameworksNotificationTests
LOCAL_PACKAGE_NAME := FrameworksUiServicesTests
LOCAL_COMPATIBILITY_SUITE := device-tests
LOCAL_CERTIFICATE := platform

View File

@@ -15,7 +15,7 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.frameworks.tests.notification">
package="com.android.frameworks.tests.uiservices">
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
@@ -32,6 +32,6 @@
<instrumentation
android:name="android.testing.TestableInstrumentation"
android:targetPackage="com.android.frameworks.tests.notification"
android:targetPackage="com.android.frameworks.tests.uiservices"
android:label="Notification Tests" />
</manifest>

View File

@@ -13,16 +13,16 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<configuration description="Runs Frameworks Notification Tests.">
<configuration description="Runs Frameworks UI Services Tests.">
<target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
<option name="test-file-name" value="FrameworksNotificationTests.apk" />
<option name="test-file-name" value="FrameworksUiServicesTests.apk" />
</target_preparer>
<option name="test-suite-tag" value="apct" />
<option name="test-suite-tag" value="framework-base-presubmit" />
<option name="test-tag" value="FrameworksNotificationTests" />
<option name="test-tag" value="FrameworksUiServicesTests" />
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="com.android.frameworks.tests.notification" />
<option name="package" value="com.android.frameworks.tests.uiservices" />
<option name="runner" value="android.testing.TestableInstrumentation" />
</test>
</configuration>

View File

@@ -1,49 +1,51 @@
package com.android.server.notification;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.spy;
import android.content.Intent;
import android.net.Uri;
import android.os.Looper;
import android.service.notification.Condition;
import android.service.notification.ScheduleCalendar;
import android.service.notification.ZenModeConfig;
import android.support.test.InstrumentationRegistry;
import android.test.ServiceTestCase;
import android.testing.TestableContext;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class ScheduleConditionProviderTest extends ServiceTestCase<ScheduleConditionProvider> {
@RunWith(AndroidJUnit4.class)
@SmallTest
public class ScheduleConditionProviderTest extends NotificationTestCase {
ScheduleConditionProvider mService;
@Rule
public final TestableContext mContext =
new TestableContext(InstrumentationRegistry.getContext(), null);
public ScheduleConditionProviderTest() {
super(ScheduleConditionProvider.class);
}
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
if (Looper.myLooper() == null) {
Looper.prepare();
}
Intent startIntent =
new Intent("com.android.server.notification.ScheduleConditionProvider");
startIntent.setPackage("android");
bindService(startIntent);
mService = spy(getService());
ScheduleConditionProvider service = new ScheduleConditionProvider();
service.attach(
getContext(),
null, // ActivityThread not actually used in Service
ScheduleConditionProvider.class.getName(),
null, // token not needed when not talking with the activity manager
null,
null // mocked services don't talk with the activity manager
);
service.onCreate();
service.onBind(startIntent);
mService = spy(service);
}
@Test