Skip to content
Closed
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: 1 addition & 1 deletion packages/react-native-fantom/src/__tests__/Fantom-itest.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ describe('Fantom', () => {
},
],
props: {
foregroundColor: 'rgba(255, 255, 255, 127)',
foregroundColor: 'rgba(0, 0, 0, 0)',
},
type: 'Paragraph',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ describe('<Button>', () => {
).toEqual(
// Upper case on Android (also used by Fantom)
<rn-view backgroundColor="rgba(33, 150, 243, 255)">
<rn-paragraph
backgroundColor="rgba(255, 255, 255, 127)"
foregroundColor="rgba(255, 255, 255, 255)">
<rn-paragraph foregroundColor="rgba(255, 255, 255, 255)">
HELLO
</rn-paragraph>
</rn-view>,
Expand All @@ -57,9 +55,7 @@ describe('<Button>', () => {
.toJSX(),
).toEqual(
<rn-view backgroundColor="rgba(0, 0, 255, 255)">
<rn-paragraph
backgroundColor="rgba(255, 255, 255, 127)"
foregroundColor="rgba(255, 255, 255, 255)">
<rn-paragraph foregroundColor="rgba(255, 255, 255, 255)">
HELLO
</rn-paragraph>
</rn-view>,
Expand Down Expand Up @@ -105,9 +101,7 @@ describe('<Button>', () => {
.toJSX(),
).toEqual(
<rn-view backgroundColor="rgba(223, 223, 223, 255)">
<rn-paragraph
backgroundColor="rgba(255, 255, 255, 127)"
foregroundColor="rgba(161, 161, 161, 255)">
<rn-paragraph foregroundColor="rgba(161, 161, 161, 255)">
HELLO
</rn-paragraph>
</rn-view>,
Expand Down Expand Up @@ -189,9 +183,7 @@ describe('<Button>', () => {
.toJSX(),
).toEqual(
<rn-view backgroundColor="rgba(33, 150, 243, 255)">
<rn-paragraph
backgroundColor="rgba(255, 255, 255, 127)"
foregroundColor="rgba(255, 255, 255, 255)">
<rn-paragraph foregroundColor="rgba(255, 255, 255, 255)">
HELLO
</rn-paragraph>
</rn-view>,
Expand Down Expand Up @@ -233,9 +225,7 @@ describe('<Button>', () => {
.toJSX(),
).toEqual(
<rn-view backgroundColor="rgba(223, 223, 223, 255)">
<rn-paragraph
backgroundColor="rgba(255, 255, 255, 127)"
foregroundColor="rgba(161, 161, 161, 255)">
<rn-paragraph foregroundColor="rgba(161, 161, 161, 255)">
HELLO
</rn-paragraph>
</rn-view>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace facebook::react {
using Color = int32_t;

namespace HostPlatformColor {
static const facebook::react::Color UndefinedColor =
std::numeric_limits<facebook::react::Color>::max();
constexpr facebook::react::Color UndefinedColor = 0;
}

inline Color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ namespace facebook::react {
using Color = int32_t;

namespace HostPlatformColor {
static const facebook::react::Color UndefinedColor =
std::numeric_limits<facebook::react::Color>::max();
constexpr facebook::react::Color UndefinedColor = 0;
}

inline Color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,125 +231,159 @@ describe('ViewFlattening', () => {
'Insert {type: "View", parentNativeID: "J", index: 1, nativeID: "B"}',
]);
});
});

test('parent-child switching from unflattened-flattened to flattened-unflattened', () => {
const root = Fantom.createRoot();
test('parent-child switching from unflattened-flattened to flattened-unflattened', () => {
const root = Fantom.createRoot();

Fantom.runTask(() => {
root.render(
<View
style={{
marginTop: 100,
opacity: 0,
}}>
Fantom.runTask(() => {
root.render(
<View
style={{
marginTop: 50,
marginTop: 100,
opacity: 0,
}}>
<View
nativeID={'child'}
style={{height: 10, width: 10, backgroundColor: 'red'}}
/>
</View>
</View>,
);
});
style={{
marginTop: 50,
}}>
<View
nativeID={'child'}
style={{height: 10, width: 10, backgroundColor: 'red'}}
/>
</View>
</View>,
);
});

expect(root.takeMountingManagerLogs()).toEqual([
'Update {type: "RootView", nativeID: (root)}',
'Create {type: "View", nativeID: (N/A)}',
'Create {type: "View", nativeID: "child"}',
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
]);

// force view to be flattened.
Fantom.runTask(() => {
root.render(
<View
style={{
marginTop: 100,
}}>
expect(root.takeMountingManagerLogs()).toEqual([
'Update {type: "RootView", nativeID: (root)}',
'Create {type: "View", nativeID: (N/A)}',
'Create {type: "View", nativeID: "child"}',
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
]);

// force view to be flattened.
Fantom.runTask(() => {
root.render(
<View
style={{
marginTop: 50,
opacity: 0,
marginTop: 100,
}}>
<View
nativeID={'child'}
style={{height: 10, width: 10, backgroundColor: 'red'}}
/>
</View>
</View>,
);
style={{
marginTop: 50,
opacity: 0,
}}>
<View
nativeID={'child'}
style={{height: 10, width: 10, backgroundColor: 'red'}}
/>
</View>
</View>,
);
});

expect(root.takeMountingManagerLogs()).toEqual([
'Update {type: "View", nativeID: "child"}',
'Remove {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Remove {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
'Delete {type: "View", nativeID: (N/A)}',
'Create {type: "View", nativeID: (N/A)}',
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
]);
});

expect(root.takeMountingManagerLogs()).toEqual([
'Update {type: "View", nativeID: "child"}',
'Remove {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Remove {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
'Delete {type: "View", nativeID: (N/A)}',
'Create {type: "View", nativeID: (N/A)}',
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
]);
});
test('parent-child switching from flattened-unflattened to unflattened-flattened', () => {
const root = Fantom.createRoot();

test('parent-child switching from flattened-unflattened to unflattened-flattened', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<View
style={{
marginTop: 100,
}}>
<View
style={{
marginTop: 50,
opacity: 0,
}}>
<View nativeID={'child'} style={{height: 10, width: 10}} />
</View>
</View>,
);
});

Fantom.runTask(() => {
root.render(
<View
style={{
marginTop: 100,
}}>
expect(root.takeMountingManagerLogs()).toEqual([
'Update {type: "RootView", nativeID: (root)}',
'Create {type: "View", nativeID: (N/A)}',
'Create {type: "View", nativeID: "child"}',
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
]);

// force view to be flattened.
Fantom.runTask(() => {
root.render(
<View
style={{
marginTop: 50,
marginTop: 100,
opacity: 0,
}}>
<View nativeID={'child'} style={{height: 10, width: 10}} />
</View>
</View>,
);
<View
style={{
marginTop: 50,
}}>
<View nativeID={'child'} style={{height: 10, width: 10}} />
</View>
</View>,
);
});
expect(root.takeMountingManagerLogs()).toEqual([
'Update {type: "View", nativeID: "child"}',
'Remove {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
'Remove {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Delete {type: "View", nativeID: (N/A)}',
'Create {type: "View", nativeID: (N/A)}',
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
]);
});

expect(root.takeMountingManagerLogs()).toEqual([
'Update {type: "RootView", nativeID: (root)}',
'Create {type: "View", nativeID: (N/A)}',
'Create {type: "View", nativeID: "child"}',
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
]);

// force view to be flattened.
Fantom.runTask(() => {
root.render(
<View
style={{
marginTop: 100,
opacity: 0,
}}>
test('#51378: view with rgba(255,255,255,127/256) background color is not flattened', () => {
const root = Fantom.createRoot();

Fantom.runTask(() => {
root.render(
<View
style={{
marginTop: 50,
}}>
<View nativeID={'child'} style={{height: 10, width: 10}} />
</View>
</View>,
width: 100,
height: 100,
backgroundColor: `rgba(255, 255, 255, ${127 / 256})`,
}}
/>,
);
});

expect(root.takeMountingManagerLogs()).toEqual([
'Update {type: "RootView", nativeID: (root)}',
'Create {type: "View", nativeID: (N/A)}',
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
]);

expect(
root
.getRenderedOutput({props: ['width', 'height', 'backgroundColor']})
.toJSX(),
).toEqual(
<rn-view
width="100.000000"
height="100.000000"
backgroundColor="rgba(255, 255, 255, 127)"
/>,
);
});
expect(root.takeMountingManagerLogs()).toEqual([
'Update {type: "View", nativeID: "child"}',
'Remove {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
'Remove {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
'Delete {type: "View", nativeID: (N/A)}',
'Create {type: "View", nativeID: (N/A)}',
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: (N/A)}',
'Insert {type: "View", parentNativeID: (N/A), index: 0, nativeID: "child"}',
]);
});

describe('reconciliation of setNativeProps and React commit', () => {
Expand Down
Loading