Bump versions of agp and robolectric, and configure to use SDK 35 (flutter/engine#56732)
Bumps the version of AGP used in the IDE-support `build.gradle`, as well as the robolectric version in both the IDE-support `build.gradle` and test-runner-`build.gradle`. This is the current latest robolectric: https://github.com/robolectric/robolectric/releases/tag/robolectric-4.14.1. Also 1. configures robolectric to use API 35, and 2. removes the use of a deprecated class which (from what I could tell) looked like it was just used for setup, and the test still passes without it. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
a442db2c24
commit
2aae286c8d
@ -8,7 +8,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:7.4.2"
|
||||
classpath "com.android.tools.build:gradle:8.7.2"
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ repositories {
|
||||
apply plugin: "com.android.library"
|
||||
|
||||
android {
|
||||
namespace "io.flutter.embedding"
|
||||
compileSdk 35
|
||||
|
||||
defaultConfig {
|
||||
@ -52,7 +53,7 @@ android {
|
||||
implementation "androidx.test:core:1.4.0"
|
||||
implementation "com.google.android.play:core:1.8.0"
|
||||
implementation "com.ibm.icu:icu4j:69.1"
|
||||
implementation "org.robolectric:robolectric:4.12.1"
|
||||
implementation "org.robolectric:robolectric:4.14.1"
|
||||
implementation "junit:junit:4.13.2"
|
||||
implementation "androidx.test.ext:junit:1.1.4-alpha07"
|
||||
|
||||
|
@ -9,14 +9,10 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.util.SparseArray;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
@ -25,7 +21,6 @@ import io.flutter.util.FakeKeyEvent;
|
||||
import java.nio.ByteBuffer;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -33,14 +28,10 @@ import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.annotation.Implementation;
|
||||
import org.robolectric.annotation.Implements;
|
||||
import org.robolectric.annotation.Resetter;
|
||||
import org.robolectric.shadow.api.Shadow;
|
||||
|
||||
@Config(manifest = Config.NONE)
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@TargetApi(API_LEVELS.API_24)
|
||||
@TargetApi(API_LEVELS.API_35)
|
||||
public class KeyEventChannelTest {
|
||||
|
||||
KeyEvent keyEvent;
|
||||
@ -66,20 +57,8 @@ public class KeyEventChannelTest {
|
||||
keyEventChannel = new KeyEventChannel(fakeMessenger);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ShadowInputDevice.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowInputDevice.class})
|
||||
public void keyDownEventIsSentToFramework() throws JSONException {
|
||||
final InputDevice device = mock(InputDevice.class);
|
||||
when(device.isVirtual()).thenReturn(false);
|
||||
when(device.getName()).thenReturn("keyboard");
|
||||
ShadowInputDevice.sDeviceIds = new int[] {0};
|
||||
ShadowInputDevice.addDevice(0, device);
|
||||
|
||||
KeyEventChannel.FlutterKeyEvent flutterKeyEvent =
|
||||
new KeyEventChannel.FlutterKeyEvent(keyEvent, null);
|
||||
keyEventChannel.sendFlutterKeyEvent(
|
||||
@ -106,14 +85,7 @@ public class KeyEventChannelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = {ShadowInputDevice.class})
|
||||
public void keyUpEventIsSentToFramework() throws JSONException {
|
||||
final InputDevice device = mock(InputDevice.class);
|
||||
when(device.isVirtual()).thenReturn(false);
|
||||
when(device.getName()).thenReturn("keyboard");
|
||||
ShadowInputDevice.sDeviceIds = new int[] {0};
|
||||
ShadowInputDevice.addDevice(0, device);
|
||||
|
||||
keyEvent = new FakeKeyEvent(KeyEvent.ACTION_UP, 65);
|
||||
KeyEventChannel.FlutterKeyEvent flutterKeyEvent =
|
||||
new KeyEventChannel.FlutterKeyEvent(keyEvent, null);
|
||||
@ -139,48 +111,4 @@ public class KeyEventChannelTest {
|
||||
sendReply(true, replyArgumentCaptor.getValue());
|
||||
assertTrue(handled[0]);
|
||||
}
|
||||
|
||||
@Implements(InputDevice.class)
|
||||
public static class ShadowInputDevice extends org.robolectric.shadows.ShadowInputDevice {
|
||||
public static int[] sDeviceIds;
|
||||
private static SparseArray<InputDevice> sDeviceMap = new SparseArray<>();
|
||||
|
||||
private int mDeviceId;
|
||||
|
||||
@Implementation
|
||||
protected static int[] getDeviceIds() {
|
||||
return sDeviceIds;
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected static InputDevice getDevice(int id) {
|
||||
return sDeviceMap.get(id);
|
||||
}
|
||||
|
||||
public static void addDevice(int id, InputDevice device) {
|
||||
sDeviceMap.append(id, device);
|
||||
}
|
||||
|
||||
@Resetter
|
||||
public static void reset() {
|
||||
sDeviceIds = null;
|
||||
sDeviceMap.clear();
|
||||
}
|
||||
|
||||
@Implementation
|
||||
protected int getId() {
|
||||
return mDeviceId;
|
||||
}
|
||||
|
||||
public static InputDevice makeInputDevicebyId(int id) {
|
||||
final InputDevice inputDevice = Shadow.newInstanceOf(InputDevice.class);
|
||||
final ShadowInputDevice shadowInputDevice = Shadow.extract(inputDevice);
|
||||
shadowInputDevice.setId(id);
|
||||
return inputDevice;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
mDeviceId = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:8.5.0"
|
||||
classpath "com.android.tools.build:gradle:8.7.2"
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ android {
|
||||
testImplementation "androidx.test:core:1.4.0"
|
||||
testImplementation "com.google.android.play:core:1.8.0"
|
||||
testImplementation "com.ibm.icu:icu4j:69.1"
|
||||
testImplementation "org.robolectric:robolectric:4.12.1"
|
||||
testImplementation "org.robolectric:robolectric:4.14.1"
|
||||
testImplementation "junit:junit:4.13.2"
|
||||
testImplementation "androidx.test.ext:junit:1.1.4-alpha07"
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
sdk=33
|
||||
sdk=35
|
||||
shadows=io.flutter.CustomShadowContextImpl
|
||||
|
Loading…
x
Reference in New Issue
Block a user