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

Commit fd683f71 authored by Nataniel Borges's avatar Nataniel Borges
Browse files

Add meaningful exception when the device is in an unknown state

Currently, when the device is in an incorrect state (e.g. in split
screen) because another test failed to teardown the error message is a
java.lang.NullPointerException. Instead of this error, show a message
warning about the problem to aid debugging.

Test: atest FlickerTests
Change-Id: If3bd75c14c90209952484802ee17f817ab4f0f20
parent b1d388c7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.server.wm.flicker.helpers;

import static android.os.SystemClock.sleep;

import static org.junit.Assert.assertNotNull;

import android.app.Instrumentation;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
@@ -35,6 +37,8 @@ public class ImeAppHelper extends FlickerAppHelper {

    public void clickEditTextWidget(UiDevice device) {
        UiObject2 editText = device.findObject(By.res(getPackage(), "plain_text_input"));
        assertNotNull("Text field not found, this usually happens when the device was left "
                + "in an unknown state (e.g. in split screen)", editText);
        editText.click();
        sleep(500);
    }
+6 −7
Original line number Diff line number Diff line
@@ -16,13 +16,14 @@

package com.android.server.wm.flicker.helpers;

import static com.android.server.wm.flicker.helpers.AutomationUtils.getPipWindowSelector;
import static com.android.server.wm.flicker.helpers.AutomationUtils.hasPipWindow;

import static org.junit.Assert.assertNotNull;

import android.app.Instrumentation;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.Until;

public class PipAppHelper extends FlickerAppHelper {

@@ -32,12 +33,10 @@ public class PipAppHelper extends FlickerAppHelper {

    public void clickEnterPipButton(UiDevice device) {
        UiObject2 enterPipButton = device.findObject(By.res(getPackage(), "enter_pip"));
        assertNotNull("Pip button not found, this usually happens when the device was left "
                + "in an unknown state (e.g. in split screen)", enterPipButton);
        enterPipButton.click();
        UiObject2 pipWindow = device.wait(Until.findObject(getPipWindowSelector()), sFindTimeout);

        if (pipWindow == null) {
            throw new RuntimeException("Unable to find PIP window");
        }
        hasPipWindow(device);
    }

    public void closePipWindow(UiDevice device) {