diff options
Diffstat (limited to 'tests/tests/systemui/src/android/systemui/cts/MediaOutputDialogTest.java')
-rw-r--r-- | tests/tests/systemui/src/android/systemui/cts/MediaOutputDialogTest.java | 130 |
1 files changed, 0 insertions, 130 deletions
diff --git a/tests/tests/systemui/src/android/systemui/cts/MediaOutputDialogTest.java b/tests/tests/systemui/src/android/systemui/cts/MediaOutputDialogTest.java deleted file mode 100644 index b74678bc3af..00000000000 --- a/tests/tests/systemui/src/android/systemui/cts/MediaOutputDialogTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2022 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.systemui.cts; - -import static com.google.common.truth.Truth.assertThat; - -import static org.junit.Assume.assumeFalse; -import static org.junit.Assume.assumeTrue; - -import android.app.ActivityManager; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.server.wm.WindowManagerStateHelper; -import android.support.test.uiautomator.By; -import android.support.test.uiautomator.BySelector; -import android.support.test.uiautomator.UiDevice; -import android.support.test.uiautomator.Until; - -import androidx.test.InstrumentationRegistry; -import androidx.test.runner.AndroidJUnit4; - -import com.android.compatibility.common.util.SystemUtil; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * Tests related MediaOutputDialog: - * - * atest MediaDialogTest - */ -@RunWith(AndroidJUnit4.class) -public class MediaOutputDialogTest { - - private static final int TIMEOUT = 5000; - private static final String ACTION_LAUNCH_MEDIA_OUTPUT_DIALOG = - "com.android.systemui.action.LAUNCH_MEDIA_OUTPUT_DIALOG"; - private static final String SYSTEMUI_PACKAGE_NAME = "com.android.systemui"; - public static final String EXTRA_PACKAGE_NAME = "package_name"; - public static final String TEST_PACKAGE_NAME = "com.android.package.test"; - private static final BySelector MEDIA_DIALOG_SELECTOR = By.res(SYSTEMUI_PACKAGE_NAME, - "media_output_dialog"); - private WindowManagerStateHelper mWmState = new WindowManagerStateHelper(); - - private Context mContext; - private UiDevice mDevice; - private String mLauncherPackage; - private boolean mHasTouchScreen; - private ActivityManager mActivityManager; - private static final int DURATION_SCREEN_TOGGLE = 2000; - - @Before - public void setUp() { - mContext = InstrumentationRegistry.getTargetContext(); - mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); - final PackageManager packageManager = mContext.getPackageManager(); - - mHasTouchScreen = packageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN) - || packageManager.hasSystemFeature(PackageManager.FEATURE_FAKETOUCH); - - Intent launcherIntent = new Intent(Intent.ACTION_MAIN); - launcherIntent.addCategory(Intent.CATEGORY_HOME); - ResolveInfo resolveInfo = packageManager.resolveActivity(launcherIntent, - PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY)); - assumeFalse("Skipping test: can't get resolve info", resolveInfo == null); - assumeFalse("Skipping test: not supported on automotive yet", - packageManager.hasSystemFeature( - PackageManager.FEATURE_AUTOMOTIVE)); - mLauncherPackage = resolveInfo.activityInfo.packageName; - mActivityManager = mContext.getSystemService(ActivityManager.class); - } - - @Test - public void mediaOutputDialog_correctDialog() throws Exception { - prepareDevice(); - assumeTrue(mHasTouchScreen); - try { - if (mActivityManager.isLowRamDevice()) { - SystemUtil.runShellCommand(InstrumentationRegistry.getInstrumentation(), - "appops set " + SYSTEMUI_PACKAGE_NAME + " SYSTEM_ALERT_WINDOW allow"); - } - - launchMediaOutputDialog(); - - assertThat(mDevice.wait(Until.hasObject(MEDIA_DIALOG_SELECTOR), TIMEOUT)).isTrue(); - } finally { - if (mActivityManager.isLowRamDevice()) { - SystemUtil.runShellCommand(InstrumentationRegistry.getInstrumentation(), - "appops set " + SYSTEMUI_PACKAGE_NAME + " SYSTEM_ALERT_WINDOW ignore"); - } - } - } - - private void prepareDevice() throws Exception { - mDevice.executeShellCommand("input keyevent KEYCODE_WAKEUP"); - mDevice.executeShellCommand("wm dismiss-keyguard"); - // Since the screen on/off intent is ordered, they will not be sent right now. - mWmState.waitForKeyguardGone(); - } - - private void launchMediaOutputDialog() { - mDevice.pressHome(); - mDevice.wait(Until.hasObject(By.pkg(mLauncherPackage).depth(0)), TIMEOUT); - - Intent intent = new Intent(); - intent.setPackage(SYSTEMUI_PACKAGE_NAME) - .setAction(ACTION_LAUNCH_MEDIA_OUTPUT_DIALOG) - .putExtra(EXTRA_PACKAGE_NAME, TEST_PACKAGE_NAME); - - mContext.sendBroadcast(intent); - } - -} |