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

Commit f29759cd authored by Marvin Ramin's avatar Marvin Ramin
Browse files

Fix HdmiCecLocalDevicePlaybackTest

Playback device implementation was unable to get an instance of
PowerManager to aquire the WakeLock that is acquired when the device is
active source.

Bug: 151147315
Test: atest HdmiCecLocalDevicePlaybackTest
Merged-In: I44a11d8d6365e32332818b08c84583c9afb5aa15
Change-Id: I44a11d8d6365e32332818b08c84583c9afb5aa15
parent da665a67
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -20,7 +20,12 @@ import static com.android.server.hdmi.HdmiControlService.INITIATED_BY_ENABLE_CEC

import static com.google.common.truth.Truth.assertThat;

import android.content.Context;
import android.os.Handler;
import android.os.IPowerManager;
import android.os.IThermalService;
import android.os.Looper;
import android.os.PowerManager;
import android.os.test.TestLooper;
import android.view.KeyEvent;

@@ -32,6 +37,8 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.ArrayList;

@@ -50,8 +57,17 @@ public class HdmiCecLocalDevicePlaybackTest {
    private int mPlaybackPhysicalAddress;
    private boolean mWokenUp;

    @Mock private IPowerManager mIPowerManagerMock;
    @Mock private IThermalService mIThermalServiceMock;

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);

        Context context = InstrumentationRegistry.getTargetContext();
        mMyLooper = mTestLooper.getLooper();
        PowerManager powerManager = new PowerManager(context, mIPowerManagerMock,
                mIThermalServiceMock, new Handler(mMyLooper));
        mHdmiControlService =
            new HdmiControlService(InstrumentationRegistry.getTargetContext()) {
                @Override
@@ -68,9 +84,13 @@ public class HdmiCecLocalDevicePlaybackTest {
                void writeStringSystemProperty(String key, String value) {
                    // do nothing
                }

                @Override
                PowerManager getPowerManager() {
                    return powerManager;
                }
            };

        mMyLooper = mTestLooper.getLooper();
        mHdmiCecLocalDevicePlayback = new HdmiCecLocalDevicePlayback(mHdmiControlService);
        mHdmiCecLocalDevicePlayback.init();
        mHdmiControlService.setIoLooper(mMyLooper);
@@ -140,7 +160,6 @@ public class HdmiCecLocalDevicePlaybackTest {
    }

    @Test
    @Ignore("b/151147315")
    public void doNotWakeUpOnHotPlug_PlugIn() {
        mWokenUp = false;
        mHdmiCecLocalDevicePlayback.onHotplug(0, true);
@@ -148,7 +167,6 @@ public class HdmiCecLocalDevicePlaybackTest {
    }

    @Test
    @Ignore("b/151147315")
    public void doNotWakeUpOnHotPlug_PlugOut() {
        mWokenUp = false;
        mHdmiCecLocalDevicePlayback.onHotplug(0, false);
@@ -156,7 +174,6 @@ public class HdmiCecLocalDevicePlaybackTest {
    }

    @Test
    @Ignore("b/151147315")
    public void sendVolumeKeyEvent_up_volumeEnabled() {
        mHdmiControlService.setHdmiCecVolumeControlEnabled(true);
        mHdmiCecLocalDevicePlayback.sendVolumeKeyEvent(KeyEvent.KEYCODE_VOLUME_UP, true);
@@ -166,7 +183,6 @@ public class HdmiCecLocalDevicePlaybackTest {
    }

    @Test
    @Ignore("b/151147315")
    public void sendVolumeKeyEvent_down_volumeEnabled() {
        mHdmiControlService.setHdmiCecVolumeControlEnabled(true);
        mHdmiCecLocalDevicePlayback.sendVolumeKeyEvent(KeyEvent.KEYCODE_VOLUME_DOWN, true);
@@ -176,7 +192,6 @@ public class HdmiCecLocalDevicePlaybackTest {
    }

    @Test
    @Ignore("b/151147315")
    public void sendVolumeKeyEvent_mute_volumeEnabled() {
        mHdmiControlService.setHdmiCecVolumeControlEnabled(true);
        mHdmiCecLocalDevicePlayback.sendVolumeKeyEvent(KeyEvent.KEYCODE_VOLUME_MUTE, true);
@@ -186,7 +201,6 @@ public class HdmiCecLocalDevicePlaybackTest {
    }

    @Test
    @Ignore("b/151147315")
    public void sendVolumeKeyEvent_up_volumeDisabled() {
        mHdmiControlService.setHdmiCecVolumeControlEnabled(false);
        mHdmiCecLocalDevicePlayback.sendVolumeKeyEvent(KeyEvent.KEYCODE_VOLUME_UP, true);
@@ -196,7 +210,6 @@ public class HdmiCecLocalDevicePlaybackTest {
    }

    @Test
    @Ignore("b/151147315")
    public void sendVolumeKeyEvent_down_volumeDisabled() {
        mHdmiControlService.setHdmiCecVolumeControlEnabled(false);
        mHdmiCecLocalDevicePlayback.sendVolumeKeyEvent(KeyEvent.KEYCODE_VOLUME_DOWN, true);
@@ -206,7 +219,6 @@ public class HdmiCecLocalDevicePlaybackTest {
    }

    @Test
    @Ignore("b/151147315")
    public void sendVolumeKeyEvent_mute_volumeDisabled() {
        mHdmiControlService.setHdmiCecVolumeControlEnabled(false);
        mHdmiCecLocalDevicePlayback.sendVolumeKeyEvent(KeyEvent.KEYCODE_VOLUME_MUTE, true);