summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-09-21 21:59:31 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-09-21 21:59:31 +0000
commit5c4ed33547da3cc3ce7fe06989c47e6762aa6e90 (patch)
tree83d4738603f84e443dbb92ca64d3406dc41cce64
parente2169d8dec2a4307d473efbf308329b344db70d5 (diff)
parent498634c1b82f27bfdaf74f8967acd0fb6f32562e (diff)
downloadplatform_testing-5c4ed33547da3cc3ce7fe06989c47e6762aa6e90.tar.gz
release-request-a84b3435-75fa-41e8-bd3c-ca0f4cbd5cc5-for-git_oc-m2-release-4352002 snap-temp-L88700000105039240
Change-Id: I7b574291d4f36236acc0b3642336fc4f463f9710
-rw-r--r--tests/functional/notificationtests/src/com/android/notification/functional/NotificationHelper.java38
-rw-r--r--tests/functional/notificationtests/src/com/android/notification/functional/NotificationInteractionTests.java2
-rw-r--r--tests/jank/uibench/src/com/android/uibench/janktests/UiBenchLeanbackJankTests.java10
3 files changed, 38 insertions, 12 deletions
diff --git a/tests/functional/notificationtests/src/com/android/notification/functional/NotificationHelper.java b/tests/functional/notificationtests/src/com/android/notification/functional/NotificationHelper.java
index dc9aeb451..12d346822 100644
--- a/tests/functional/notificationtests/src/com/android/notification/functional/NotificationHelper.java
+++ b/tests/functional/notificationtests/src/com/android/notification/functional/NotificationHelper.java
@@ -16,6 +16,9 @@
package com.android.notification.functional;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+import static android.app.NotificationManager.IMPORTANCE_LOW;
+
import android.app.Instrumentation;
import android.app.IntentService;
import android.app.KeyguardManager;
@@ -27,7 +30,6 @@ import android.app.RemoteInput;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
-import android.net.Uri;
import android.os.Handler;
import android.os.RemoteException;
import android.provider.Settings;
@@ -65,6 +67,10 @@ public class NotificationHelper {
public static final String FIRST_ACTION = "FIRST ACTION";
public static final String SECOND_ACTION = "SECOND ACTION";
public static final String CONTENT_TITLE = "THIS IS A NOTIFICATION";
+ private static final String BUZZY_CHANNEL_ID = "com.android.notification.functional.buzzy";
+ private static final String QUIET_CHANNEL_ID = "com.android.notification.functional.quiet";
+ private NotificationChannel mBuzzyChannel;
+ private NotificationChannel mQuietChannel;
private UiDevice mDevice;
private Instrumentation mInst;
@@ -76,6 +82,9 @@ public class NotificationHelper {
mInst = inst;
mNotificationManager = nm;
mContext = inst.getContext();
+ // create the channels we need
+ mBuzzyChannel = getChannel(true);
+ mQuietChannel = getChannel(false);
}
public void sleepAndWakeUpDevice() throws RemoteException, InterruptedException {
@@ -126,7 +135,7 @@ public class NotificationHelper {
public boolean removeScreenLock(int pin, String mode) throws Exception {
navigateToScreenLock();
- if (new UiObject(new UiSelector().text("Confirm your PIN")).exists()) {
+ if (new UiObject(new UiSelector().text("Re-enter your PIN")).exists()) {
UiObject pinField = new UiObject(new UiSelector().className(EditText.class.getName()));
pinField.setText(String.format("%04d", pin));
mDevice.pressEnter();
@@ -186,7 +195,7 @@ public class NotificationHelper {
.setContentText(subtitle)
.setContentIntent(pendingIntent)
.setVisibility(visibility)
- .setPriority(Notification.PRIORITY_HIGH)
+ .setChannelId(buzz ? BUZZY_CHANNEL_ID : QUIET_CHANNEL_ID)
.addAction(new Notification.Action.Builder(R.drawable.stat_notify_email,
FIRST_ACTION, emptyIntent)
.build())
@@ -194,9 +203,6 @@ public class NotificationHelper {
SECOND_ACTION, emptyIntent)
.build())
.setAutoCancel(false);
- if (buzz) {
- notification.setDefaults(Notification.DEFAULT_VIBRATE);
- }
mNotificationManager.notify(id, notification.build());
Thread.sleep(LONG_TIMEOUT);
}
@@ -361,6 +367,26 @@ public class NotificationHelper {
return mNotificationManager.getNotificationChannel(NotificationChannel.DEFAULT_CHANNEL_ID);
}
+ public NotificationChannel getChannel(boolean buzz) {
+ String id = (buzz ? BUZZY_CHANNEL_ID : QUIET_CHANNEL_ID);
+ String name = (buzz ? "This channel is buzzy" : "This channel is quiet");
+ int importance = (buzz ? IMPORTANCE_DEFAULT : IMPORTANCE_LOW);
+
+ NotificationChannel channel = (buzz ? mBuzzyChannel : mQuietChannel);
+ if (channel == null) {
+ channel = mNotificationManager.getNotificationChannel(id);
+ }
+ if (channel == null){
+ channel = new NotificationChannel(id, name, importance);
+ if (buzz) {
+ channel.enableVibration(true);
+ channel.setSound(null, null);
+ }
+ mNotificationManager.createNotificationChannel(channel);
+ }
+ return channel;
+ }
+
public static class ToastService extends IntentService {
private static final String TAG = "ToastService";
private static final String ACTION_TOAST = "toast";
diff --git a/tests/functional/notificationtests/src/com/android/notification/functional/NotificationInteractionTests.java b/tests/functional/notificationtests/src/com/android/notification/functional/NotificationInteractionTests.java
index 53b9c6963..d5b4f58cd 100644
--- a/tests/functional/notificationtests/src/com/android/notification/functional/NotificationInteractionTests.java
+++ b/tests/functional/notificationtests/src/com/android/notification/functional/NotificationInteractionTests.java
@@ -237,7 +237,7 @@ public class NotificationInteractionTests extends InstrumentationTestCase {
new LogMaker(MetricsEvent.NOTIFICATION_ALERT)
.setType(MetricsEvent.TYPE_OPEN)
.addTaggedData(MetricsEvent.NOTIFICATION_ID, id)
- .setSubtype(1) // 1: BUZZ, nop BEEP, nop BLINK
+ .setSubtype(MetricsEvent.ALERT_BUZZ) // no BEEP or BLINK
.setPackageName(mContext.getPackageName()));
MetricsAsserts.assertHasLog("missing notification action 0 click log", mMetricsReader,
new LogMaker(MetricsEvent.NOTIFICATION_ITEM_ACTION)
diff --git a/tests/jank/uibench/src/com/android/uibench/janktests/UiBenchLeanbackJankTests.java b/tests/jank/uibench/src/com/android/uibench/janktests/UiBenchLeanbackJankTests.java
index c6717305c..d03f1b217 100644
--- a/tests/jank/uibench/src/com/android/uibench/janktests/UiBenchLeanbackJankTests.java
+++ b/tests/jank/uibench/src/com/android/uibench/janktests/UiBenchLeanbackJankTests.java
@@ -25,7 +25,7 @@ import android.support.test.uiautomator.UiDevice;
import android.text.TextUtils;
import android.view.KeyEvent;
-import static com.android.uibench.janktests.UiBenchJankTestsHelper.EXPECTED_FRAMES;
+import static com.android.uibench.janktests.UiBenchJankTestsHelper.SHORT_EXPECTED_FRAMES;
import static com.android.uibench.janktests.UiBenchJankTestsHelper.PACKAGE_NAME;
import java.lang.annotation.ElementType;
@@ -125,7 +125,7 @@ public class UiBenchLeanbackJankTests extends JankTestBase {
/**
* Vertically scroll BrowseFragment in the fast lane
*/
- @JankTest(expectedFrames = EXPECTED_FRAMES)
+ @JankTest(expectedFrames = SHORT_EXPECTED_FRAMES)
@Option(activity = "leanback.BrowseActivity")
@GfxMonitor(processName = PACKAGE_NAME)
@GfxFrameStatsMonitor(processName = PACKAGE_NAME)
@@ -136,7 +136,7 @@ public class UiBenchLeanbackJankTests extends JankTestBase {
/**
* Vertically scroll BrowseFragment in the content (fast lane closed)
*/
- @JankTest(expectedFrames = EXPECTED_FRAMES)
+ @JankTest(expectedFrames = SHORT_EXPECTED_FRAMES)
@Option(activity = "leanback.BrowseActivity", postLaunch = "focusToBrowseContent")
@GfxMonitor(processName = PACKAGE_NAME)
@GfxFrameStatsMonitor(processName = PACKAGE_NAME)
@@ -148,7 +148,7 @@ public class UiBenchLeanbackJankTests extends JankTestBase {
* Vertically scroll BrowseFragment in the fast lane
* option: no bitmap upload
*/
- @JankTest(expectedFrames = EXPECTED_FRAMES)
+ @JankTest(expectedFrames = SHORT_EXPECTED_FRAMES)
@Option(activity = "leanback.BrowseActivity", extras = "noBitmapUpload")
@GfxMonitor(processName = PACKAGE_NAME)
@GfxFrameStatsMonitor(processName = PACKAGE_NAME)
@@ -160,7 +160,7 @@ public class UiBenchLeanbackJankTests extends JankTestBase {
* Vertically scroll BrowseFragment in the content (fast lane closed)
* option: no bitmap upload
*/
- @JankTest(expectedFrames = EXPECTED_FRAMES)
+ @JankTest(expectedFrames = SHORT_EXPECTED_FRAMES)
@Option(activity = "leanback.BrowseActivity", extras = "noBitmapUpload",
postLaunch = "focusToBrowseContent")
@GfxMonitor(processName = PACKAGE_NAME)