Skip to content

Commit

Permalink
Android: Run tests on new emulators with api 34 (#4528)
Browse files Browse the repository at this point in the history
  • Loading branch information
gosha212 authored Jul 22, 2024
1 parent 8d2e16b commit c2f31e8
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,17 @@ private static int[] getScrollStartOffsetInView(View view, @MotionDir int direct
* @return a Point object, denoting the scroll start point.
*/
private static Point getScrollStartPoint(View view, @MotionDir int direction, Float startOffsetPercentX, Float startOffsetPercentY) {
Point result = getGlobalViewLocation(view);
Point globalViewPoint = getGlobalViewLocation(view);

// 1. Calculate the scroll start point, with respect to the view's location.
int[] coordinates = getScrollStartOffsetInView(view, direction, startOffsetPercentX, startOffsetPercentY);

globalViewPoint.offset(coordinates[0], coordinates[1]);

// 2. Make sure that the start point is within the scrollable area, taking into account the system gesture insets.
coordinates = applyScreenInsets(view, direction, coordinates[0], coordinates[1]);
coordinates = applyScreenInsets(view, direction, globalViewPoint.x, globalViewPoint.y);

result.offset(coordinates[0], coordinates[1]);
return result;
return new Point(coordinates[0], coordinates[1]);
}

/**
Expand Down Expand Up @@ -237,8 +238,8 @@ private static int[] applyScreenInsets(View view, int direction, int x, int y) {
Log.w(LOG_TAG, "Could not get root window insets");
} else {
Insets gestureInsets = rootWindowInsets.getSystemGestureInsets();
minX = gestureInsets.left;
minY = gestureInsets.top;
minX += gestureInsets.left;
minY += gestureInsets.top;
maxX -= gestureInsets.right;
maxY -= gestureInsets.bottom;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ private const val SCROLL_RANGE_SAFE_PERCENT = 0.9f // ScrollHelper.SCROLL_RANGE_

@Config(
qualifiers = "xxxhdpi", // 1280x1880
sdk = [33]
)
@RunWith(RobolectricTestRunner::class)
class ScrollHelperTest {
Expand Down Expand Up @@ -95,6 +94,7 @@ class ScrollHelperTest {
// Calculate where the scroll should end
val targetX = amountInPx +
touchSlopPx +
safetyMarginPx +
INSETS_SIZE

assertEquals(targetX, upEvent.x, 0.0f)
Expand All @@ -110,6 +110,7 @@ class ScrollHelperTest {
// Calculate where the scroll should end
val targetY = amountInPx +
touchSlopPx +
safetyMarginPx +
INSETS_SIZE

assertEquals(displayWidth / 2.0, upEvent.x.toDouble(), 0.0)
Expand Down
4 changes: 2 additions & 2 deletions detox/test/e2e/03.actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ describe('Actions', () => {
it('should swipe horizontally by offset from specified positions ', async () => {
await element(by.id('toggleScrollOverlays')).tap();

await element(by.id('ScrollViewH')).swipe('left', 'slow', 0.25, 0.85, 0.75);
await element(by.id('ScrollViewH')).swipe('left', 'slow', 0.28, 0.85, 0.75);
await expect(element(by.text('HText1'))).not.toBeVisible(1);

await element(by.id('ScrollViewH')).swipe('right', 'fast', 0.25, 0.15, 0.25);
await element(by.id('ScrollViewH')).swipe('right', 'fast', 0.28, 0.15, 0.25);
await expect(element(by.text('HText1'))).toBeVisible(1);
});

Expand Down
2 changes: 1 addition & 1 deletion detox/test/e2e/16.location.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('set location', () => {
}

const expectLocationToAppear = async (latitude, longitude) => {
await waitFor(element(by.id(LOCATION_LATITUDE_TEST_ID))).toHaveText(`Latitude: ${latitude}`).withTimeout(3000);
await waitFor(element(by.id(LOCATION_LATITUDE_TEST_ID))).toHaveText(`Latitude: ${latitude}`).withTimeout(5000);
await expect(element(by.id(LOCATION_LONGITUDE_TEST_ID))).toHaveText(`Longitude: ${longitude}`);
}

Expand Down
10 changes: 5 additions & 5 deletions detox/test/e2e/33.attributes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,25 +244,25 @@ describe('Attributes', () => {

expect(attributesArray[0]).toMatchObject({
...{
height: 394,
height: 412,
width: 1074,
},
...baseAttributes
});

expect(attributesArray[1]).toMatchObject({
...{
height: 197,
width: 262,
height: 206,
width: 275,
identifier: 'innerView1'
},
...baseAttributes
});

expect(attributesArray[2]).toMatchObject({
...{
height: 197,
width: 262,
height: 206,
width: 275,
identifier: 'innerView2'
},
...baseAttributes
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified detox/test/e2e/assets/focus-on-input-webview.android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified detox/test/e2e/assets/move-cursor-to-end-webview.android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified detox/test/e2e/assets/scroll-to-view-webview.android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified detox/test/e2e/assets/select-all-text-in-webview.android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions detox/test/e2e/detox.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const config = {
headless: Boolean(process.env.CI),
gpuMode: process.env.CI ? 'off' : undefined,
device: {
avdName: 'Pixel_3A_API_29'
avdName: 'Pixel_3a_API_34'
},
},

Expand All @@ -122,14 +122,14 @@ const config = {
'android.genycloud.uuid': {
type: 'android.genycloud',
device: {
recipeUUID: '90450ce0-cdd8-4229-8618-18a1fc195b62',
recipeUUID: 'ba2c588d-744f-473c-b72d-a2c467988f04',
},
},

'android.genycloud.name': {
type: 'android.genycloud',
device: {
recipeName: 'Detox_Pixel_3A_API_29',
recipeName: 'Detox_Pixel_3a_API_34',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion detox/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@react-native-async-storage/async-storage": "^1.17.3",
"@react-native-community/checkbox": "0.5.16",
"@react-native-community/datetimepicker": "^7.6.3",
"@react-native-community/geolocation": "^2.0.2",
"@react-native-community/geolocation": "^3.2.1",
"@react-native-community/slider": "4.5.0",
"@react-native-picker/picker": "^2.1.0",
"@react-native-segmented-control/segmented-control": "2.3.0",
Expand Down

0 comments on commit c2f31e8

Please sign in to comment.