mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
This code contains utility clases that can change the display
of a device and make it look like another device.
The function DisplayEmulator#emulate receives a DeviceEmulationData
a certain grid to emulate and a callback, everyting that happens
inside of the callback will happen when the device is being emulated
and can be used by other tests.
Example test:
package com.android.launcher3.deviceemulator;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
import com.android.launcher3.deviceemulator.models.DeviceEmulationData;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.concurrent.TimeUnit;
@MediumTest
@RunWith(AndroidJUnit4.class)
public class TestTest extends AbstractLauncherUiTest {
@Test
public void testEmulation() throws Exception {
String deviceCode = "pixel6pro";
DeviceEmulationData deviceData = DeviceEmulationData.getDevice(deviceCode);
String grid = "normal";
DisplayEmulator displayEmulator = new DisplayEmulator(mTargetContext);
displayEmulator.emulate(deviceData, grid, () ->{
TimeUnit.SECONDS.sleep(10);
return true;
});
}
}
Test: You could use the test above to make your device look like a
Pixel6 pro for 10 secons.
Fix: 229028257
Change-Id: Icd79be405a2e14dda0bc5f555b0e46149e16f912
46 lines
885 B
JSON
46 lines
885 B
JSON
{
|
|
"pixel6pro": {
|
|
"width": 1440,
|
|
"height": 3120,
|
|
"density": 560,
|
|
"name": "pixel6pro",
|
|
"cutout": "0, 130, 0, 0",
|
|
"grids": [
|
|
"normal",
|
|
"reasonable",
|
|
"practical",
|
|
"big",
|
|
"crazy_big"
|
|
],
|
|
"resourceOverrides": {
|
|
"status_bar_height": 98,
|
|
"navigation_bar_height_landscape": 56,
|
|
"navigation_bar_height": 56,
|
|
"navigation_bar_width": 56
|
|
}
|
|
},
|
|
"test": {
|
|
"data needs updating": 0
|
|
},
|
|
"pixel5": {
|
|
"width": 1080,
|
|
"height": 2340,
|
|
"density": 440,
|
|
"name": "pixel5",
|
|
"cutout": "0, 136, 0, 0",
|
|
"grids": [
|
|
"normal",
|
|
"reasonable",
|
|
"practical",
|
|
"big",
|
|
"crazy_big"
|
|
],
|
|
"resourceOverrides": {
|
|
"status_bar_height": 66,
|
|
"navigation_bar_height_landscape": 44,
|
|
"navigation_bar_height": 44,
|
|
"navigation_bar_width": 44
|
|
}
|
|
}
|
|
}
|