[required-props] Added tests for Component.Builder prop added in the chain of calls.

Summary: Component.Builder has its own non-required props that are inherited by the MyComponent.Builder. Add tests where these common props are set in the chain of calls.

Reviewed By: Katalune

Differential Revision: D17710294

fbshipit-source-id: f3c5ef28c
master
Ezgi Çiçek 5 years ago committed by Facebook Github Bot
parent c68dc542b7
commit d163be3b87

@ -41,5 +41,10 @@ public class Column extends Component {
public Column build() {
return mColumn;
}
@Override
public Builder getThis() {
return this;
}
}
}

@ -9,8 +9,14 @@ package com.facebook.litho;
public class Component {
public abstract static class Builder {
public abstract static class Builder<T extends Builder<T>> {
public abstract Component build();
public abstract T getThis();
public T commonProp(Object prop) {
return getThis();
}
}
}

@ -31,7 +31,7 @@ class MyComponent extends Component {
return new Builder();
}
static class Builder extends Component.Builder {
static class Builder extends Component.Builder<Builder> {
MyComponent mMyComponent;
public Builder prop1(Object o) {
@ -52,6 +52,11 @@ class MyComponent extends Component {
public MyComponent build() {
return mMyComponent;
}
@Override
public Builder getThis() {
return this;
}
}
}
@ -64,7 +69,7 @@ class MyTreeComponent extends Component {
return new Builder();
}
static class Builder extends Component.Builder {
static class Builder extends Component.Builder<Builder> {
MyTreeComponent mMyTreeComponent;
public Builder prop1(Object o) {
@ -75,6 +80,11 @@ class MyTreeComponent extends Component {
public MyTreeComponent build() {
return mMyTreeComponent;
}
@Override
public Builder getThis() {
return this;
}
}
}
@ -91,7 +101,7 @@ class ResPropComponent extends Component {
return new Builder();
}
static class Builder extends Component.Builder {
static class Builder extends Component.Builder<Builder> {
ResPropComponent mResPropComponent;
@ -128,6 +138,11 @@ class ResPropComponent extends Component {
public ResPropComponent build() {
return mResPropComponent;
}
@Override
public Builder getThis() {
return this;
}
}
}
@ -141,7 +156,7 @@ class VarArgPropComponent extends Component {
return new Builder();
}
static class Builder extends Component.Builder {
static class Builder extends Component.Builder<Builder> {
VarArgPropComponent mVarArgPropComponent;
@ -194,6 +209,11 @@ class VarArgPropComponent extends Component {
public VarArgPropComponent build() {
return mVarArgPropComponent;
}
@Override
public Builder getThis() {
return this;
}
}
}
@ -227,6 +247,15 @@ public class RequiredProps {
return mMyComponent.create().prop1(new Object()).prop2(new Object()).build();
}
public Component buildWithCommonPropOk() {
return mMyComponent
.create()
.prop1(new Object())
.commonProp(new Object())
.prop3(new Object())
.build();
}
private static MyComponent.Builder setProp1(MyComponent.Builder builder) {
return builder.prop1(new Object());
}

Loading…
Cancel
Save