Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- packages/@expo/prebuild-config/src/**
- packages/@expo/router-server/**
- packages/@expo/log-box/**
- packages/@expo/metro-file-map/**
- packages/create-expo/**
- packages/eslint-config-expo/**
- packages/eslint-plugin-expo/**
Expand All @@ -37,6 +38,7 @@ on:
- packages/@expo/prebuild-config/src/**
- packages/@expo/router-server/**
- packages/@expo/log-box/**
- packages/@expo/metro-file-map/**
- packages/create-expo/**
- packages/eslint-config-expo/**
- packages/eslint-plugin-expo/**
Expand Down
4 changes: 0 additions & 4 deletions apps/observe-tester/app/(tabs)/(sessions)/sessions/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ export default function SessionDetail() {

useFocusEffect(
useCallback(() => {
if (Platform.OS !== 'ios') {
setLoaded(true);
return;
}
AppMetrics.getAllSessions().then((sessions) => {
setSession(sessions.find((s) => s.id === id) ?? null);
setLoaded(true);
Expand Down
6 changes: 1 addition & 5 deletions apps/observe-tester/app/(tabs)/(sessions)/sessions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ export default function SessionsList() {

useFocusEffect(
useCallback(() => {
if (Platform.OS === 'ios') {
refresh();
} else {
setLoaded(true);
}
refresh();
}, [refresh])
);

Expand Down
81 changes: 56 additions & 25 deletions apps/test-suite/tests/Brightness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@ import * as TestUtils from '../TestUtils';

export const name = 'Brightness (device-only)';

export const EPSILON = Math.pow(10, -5);
// Android system brightness is stored as an integer in the [1, 255] range
// This means the maximum error after mapping to the [0, 1] range can be half of the interval
const ANDROID_EPSILON = 1 / 254 / 2;
// Arbitrary precision, which compensates for floating-point inaccuracies
const IOS_EPSILON = Math.pow(10, -5);
const EPSILON = Platform.OS === 'android' ? ANDROID_EPSILON : IOS_EPSILON;
// Arbitrary delay to give the system time to set the brightness
const BRIGHTNESS_UPDATE_DELAY_MS = 400;

function timeoutWrapper(fn: () => void | Promise<void>, time: number): Promise<void> {
return new Promise((resolve, reject) => {
setTimeout(() => {
Promise.resolve(fn()).then(resolve, reject);
}, time);
});
}

export async function test(t) {
const shouldSkipTestsRequiringPermissions =
Expand All @@ -32,9 +47,11 @@ export async function test(t) {
} catch {
wasRejected = true;
}
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(originalValue - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
await timeoutWrapper(async () => {
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(originalValue - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
}, BRIGHTNESS_UPDATE_DELAY_MS);
});

t.it(
Expand All @@ -47,9 +64,11 @@ export async function test(t) {
} catch {
wasRejected = true;
}
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(0 - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
await timeoutWrapper(async () => {
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(0 - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
}, BRIGHTNESS_UPDATE_DELAY_MS);
}
);

Expand All @@ -63,9 +82,11 @@ export async function test(t) {
} catch {
wasRejected = true;
}
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(1 - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
await timeoutWrapper(async () => {
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(1 - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
}, BRIGHTNESS_UPDATE_DELAY_MS);
}
);

Expand Down Expand Up @@ -110,9 +131,11 @@ export async function test(t) {
} catch {
wasRejected = true;
}
const obtainedValue = await Brightness.getSystemBrightnessAsync();
t.expect(Math.abs(originalValue - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
await timeoutWrapper(async () => {
const obtainedValue = await Brightness.getSystemBrightnessAsync();
t.expect(Math.abs(originalValue - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
}, BRIGHTNESS_UPDATE_DELAY_MS);
});

t.it(
Expand All @@ -125,9 +148,11 @@ export async function test(t) {
} catch {
wasRejected = true;
}
const obtainedValue = await Brightness.getSystemBrightnessAsync();
t.expect(Math.abs(0 - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
await timeoutWrapper(async () => {
const obtainedValue = await Brightness.getSystemBrightnessAsync();
t.expect(Math.abs(0 - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
}, BRIGHTNESS_UPDATE_DELAY_MS);
}
);

Expand All @@ -141,9 +166,11 @@ export async function test(t) {
} catch {
wasRejected = true;
}
const obtainedValue = await Brightness.getSystemBrightnessAsync();
t.expect(Math.abs(1 - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
await timeoutWrapper(async () => {
const obtainedValue = await Brightness.getSystemBrightnessAsync();
t.expect(Math.abs(1 - obtainedValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
}, BRIGHTNESS_UPDATE_DELAY_MS);
}
);

Expand Down Expand Up @@ -183,9 +210,11 @@ export async function test(t) {
} catch {
wasRejected = true;
}
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(obtainedValue - systemValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
await timeoutWrapper(async () => {
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(obtainedValue - systemValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
}, BRIGHTNESS_UPDATE_DELAY_MS);
});

t.it(`is overridden by setting the app brightness`, async () => {
Expand All @@ -199,9 +228,11 @@ export async function test(t) {
} catch {
wasRejected = true;
}
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(obtainedValue - appValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
await timeoutWrapper(async () => {
const obtainedValue = await Brightness.getBrightnessAsync();
t.expect(Math.abs(obtainedValue - appValue)).toBeLessThan(EPSILON);
t.expect(wasRejected).toBe(false);
}, BRIGHTNESS_UPDATE_DELAY_MS);
});
});

Expand Down
1 change: 1 addition & 0 deletions docs/.vale/writing-styles/expo-docs/HeadingCase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ exceptions:
- '.*EAS Insights.*'
- '.*Element Inspector.*'
- '.*Environment Variables.*'
- '.*EXIF.*'
- '.*ESLint.*'
- '.*Expo.*'
- '.*ExpoKit.*'
Expand Down
2 changes: 2 additions & 0 deletions docs/components/plugins/api/APIStaticData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ export const nonLinkableTypes = [
'ExpandedFullScreenSearchBarProps',
'FC',
'FileSystemDirectory',
'FileSystemDownloadTask',
'FileSystemDownloadResult',
'FileSystemFile',
'FileSystemNetworkTaskProgressCallback',
'FileSystemUploadTask',
'FileSystemUploadOptions',
'FileSystemUploadResult',
'FileWriteOptions',
Expand Down
5 changes: 5 additions & 0 deletions docs/constants/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ export const general = [
'More',
[
makePage('workflow/upgrading-expo-sdk-walkthrough.mdx'),
makeSection('SDK libraries migration', [
makePage('guides/sdk-libraries-migration/media-library.mdx'),
makePage('guides/sdk-libraries-migration/calendar.mdx'),
makePage('guides/sdk-libraries-migration/contacts.mdx'),
]),
makeSection('Assorted', [
makePage('guides/authentication.mdx'),
makePage('guides/using-hermes.mdx'),
Expand Down
Loading
Loading