Skip to content

Commit

Permalink
Restructure testing module
Browse files Browse the repository at this point in the history
Summary:
As part of the last diff, I had to move `LithoRepresentation` up one
level from where it should sit - under assertj. That was because of the testing
mega-module. This attempts to untangle things a bit and create more smaller
modules. This should generally help build speed. And this is a highly
depended-upon module.

Reviewed By: IanChilds

Differential Revision: D6198838

fbshipit-source-id: e058b63a0ac85fcf516cc71f6498058eb066dd56
  • Loading branch information
passy authored and facebook-github-bot committed Nov 1, 2017
1 parent c26bfd4 commit e4ca178
Show file tree
Hide file tree
Showing 53 changed files with 172 additions and 122 deletions.
2 changes: 2 additions & 0 deletions COMPONENTS_DEFS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ COMPONENTS_WIDGET_TARGET = make_dep_path('litho-widget/src/mai
COMPONENTS_COMPONENTS_FRESCO_TARGET = make_dep_path('litho-fresco/src/main/java/com/facebook/litho/fresco:fresco')
COMPONENTS_TESTING_TARGET = make_dep_path('litho-testing/src/main/java/com/facebook/litho/testing:testing')
COMPONENTS_TESTING_ASSERTJ_TARGET = make_dep_path('litho-testing/src/main/java/com/facebook/litho/testing/assertj:assertj')
COMPONENTS_TESTING_HELPER_TARGET = make_dep_path('litho-testing/src/main/java/com/facebook/litho/testing/helper:helper')
COMPONENTS_TESTING_SUBCOMPONENTS_TARGET = make_dep_path('litho-testing/src/main/java/com/facebook/litho/testing/subcomponents:subcomponents')
COMPONENTS_TEST_RES = make_dep_path('litho-it/src/main:res')
COMPONENTS_SECTIONS_TARGET = make_dep_path('litho-sections-core/src/main/java/com/facebook/litho/sections:sections')
COMPONENTS_SECTIONS_COMMON_TARGET = make_dep_path('litho-sections-core/src/main/java/com/facebook/litho/sections/common:common')
Expand Down
48 changes: 24 additions & 24 deletions docs/javadoc/com/facebook/litho/testing/ComponentTestHelper.html

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions docs/javadoc/com/facebook/litho/testing/InspectableComponent.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import static android.os.Build.VERSION_CODES.LOLLIPOP;
import static android.view.View.LAYOUT_DIRECTION_RTL;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.TestViewComponent.create;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static com.facebook.yoga.YogaDirection.LTR;
import static com.facebook.yoga.YogaDirection.RTL;
import static com.facebook.yoga.YogaEdge.END;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.facebook.litho.ComponentContext;
import com.facebook.litho.LithoView;
import com.facebook.litho.it.R;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.shadows.ColorDrawableShadow;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.widget.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import static android.graphics.Color.BLACK;
import static android.graphics.Color.YELLOW;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.TestDrawableComponent.create;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.robolectric.Shadows.shadowOf;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package com.facebook.litho;

import static com.facebook.litho.testing.ComponentTestHelper.measureAndLayout;
import static com.facebook.litho.testing.helper.ComponentTestHelper.measureAndLayout;
import static org.assertj.core.api.Java6Assertions.assertThat;

import android.graphics.Canvas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static com.facebook.litho.ComponentTree.create;
import static com.facebook.litho.SizeSpec.EXACTLY;
import static com.facebook.litho.SizeSpec.makeSizeSpec;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;

import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

package com.facebook.litho;

import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.TestDrawableComponent.create;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static com.facebook.yoga.YogaAlign.FLEX_END;
import static com.facebook.yoga.YogaEdge.ALL;
import static org.assertj.core.api.Java6Assertions.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package com.facebook.litho;

import static com.facebook.litho.Column.create;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;

import com.facebook.litho.testing.TestDrawableComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import static com.facebook.litho.FrameworkLogEvents.EVENT_MOUNT;
import static com.facebook.litho.FrameworkLogEvents.PARAM_MOUNTED_COUNT;
import static com.facebook.litho.FrameworkLogEvents.PARAM_UNMOUNTED_COUNT;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.TestViewComponent.create;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static com.facebook.yoga.YogaEdge.ALL;
import static com.facebook.yoga.YogaEdge.LEFT;
import static com.facebook.yoga.YogaEdge.TOP;
Expand All @@ -32,11 +32,11 @@
import android.content.Context;
import android.graphics.Rect;
import android.view.ViewGroup;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.TestComponent;
import com.facebook.litho.testing.TestComponentContextWithView;
import com.facebook.litho.testing.TestDrawableComponent;
import com.facebook.litho.testing.TestViewComponent;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.testing.util.InlineLayoutSpec;
import com.facebook.yoga.YogaEdge;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static com.facebook.litho.MountState.getComponentFocusChangeListener;
import static com.facebook.litho.MountState.getComponentLongClickListener;
import static com.facebook.litho.MountState.getComponentTouchListener;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;

import com.facebook.litho.testing.TestDrawableComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import static android.view.View.MeasureSpec.makeMeasureSpec;
import static com.facebook.litho.FrameworkLogEvents.EVENT_PREPARE_MOUNT;
import static com.facebook.litho.FrameworkLogEvents.PARAM_MOVED_COUNT;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.TestDrawableComponent.create;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
Expand All @@ -26,9 +26,9 @@
import static org.mockito.Mockito.when;

import android.graphics.Color;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.TestComponent;
import com.facebook.litho.testing.TestDrawableComponent;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.testing.util.InlineLayoutSpec;
import com.facebook.litho.widget.SolidColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

package com.facebook.litho;

import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.TestDrawableComponent.create;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.powermock.reflect.Whitebox.getInternalState;

import android.support.v4.util.LongSparseArray;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.TestComponent;
import com.facebook.litho.testing.TestDrawableComponent;
import com.facebook.litho.testing.TestViewComponent;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.testing.util.InlineLayoutSpec;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import static org.mockito.Mockito.mock;

import com.facebook.litho.config.ComponentsConfiguration;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.TestDrawableComponent;
import com.facebook.litho.testing.assertj.LithoViewAssert;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.testing.util.InlineLayoutSpec;
import com.facebook.litho.widget.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package com.facebook.litho;

import static com.facebook.litho.Column.create;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;

import com.facebook.litho.testing.TestDrawableComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package com.facebook.litho;

import static com.facebook.litho.Column.create;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;

import android.util.SparseArray;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
package com.facebook.litho;

import static com.facebook.litho.Column.create;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static com.facebook.yoga.YogaEdge.BOTTOM;
import static com.facebook.yoga.YogaEdge.LEFT;
import static com.facebook.yoga.YogaEdge.RIGHT;
Expand All @@ -22,11 +22,11 @@
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.TestComponent;
import com.facebook.litho.testing.TestComponentContextWithView;
import com.facebook.litho.testing.TestDrawableComponent;
import com.facebook.litho.testing.TestViewComponent;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.testing.util.InlineLayoutSpec;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import android.os.Looper;
import com.facebook.litho.ComponentLifecycle.StateContainer;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.testing.util.InlineLayoutSpec;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
package com.facebook.litho;

import static com.facebook.litho.ViewCompatComponent.get;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.ComponentTestHelper.unbindComponent;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.helper.ComponentTestHelper.unbindComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;

import android.content.Context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

package com.facebook.litho;

import static com.facebook.litho.testing.ComponentTestHelper.measureAndLayout;
import static com.facebook.litho.testing.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.ComponentTestHelper.unbindComponent;
import static com.facebook.litho.testing.TestViewComponent.create;
import static com.facebook.litho.testing.helper.ComponentTestHelper.measureAndLayout;
import static com.facebook.litho.testing.helper.ComponentTestHelper.mountComponent;
import static com.facebook.litho.testing.helper.ComponentTestHelper.unbindComponent;
import static org.assertj.core.api.Java6Assertions.assertThat;

import android.graphics.Rect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.facebook.litho.LithoView;
import com.facebook.litho.sections.SectionContext;
import com.facebook.litho.sections.common.SingleComponentSection;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.StateUpdatesTestHelper;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.testing.util.InlineLayoutSpec;
import com.facebook.litho.testing.viewtree.ViewTree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.facebook.litho.ComponentLayout;
import com.facebook.litho.config.ComponentsConfiguration;
import com.facebook.litho.testing.assertj.LithoAssertions;
import com.facebook.litho.testing.assertj.LithoRepresentation;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.testing.util.InlineLayoutSpec;
import com.facebook.litho.widget.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import com.facebook.litho.ComponentContext;
import com.facebook.litho.LithoView;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import com.facebook.litho.widget.Text;
import com.google.common.base.Predicates;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

import com.facebook.litho.ComponentContext;
import com.facebook.litho.LithoView;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.ComponentsRule;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import org.junit.Rule;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import android.view.View;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.LithoView;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.facebook.litho.ComponentContext;
import com.facebook.litho.EventHandler;
import com.facebook.litho.LithoView;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.eventhandler.EventHandlerTestHelper;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.testrunner.ComponentsTestRunner;
import org.junit.Before;
import org.junit.Test;
Expand Down
2 changes: 1 addition & 1 deletion litho-it/src/test/resources/processor/BasicTestSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import android.support.annotation.ColorRes;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.ResourceResolver;
import com.facebook.litho.testing.InspectableComponent;
import com.facebook.litho.testing.assertj.ComponentMatcher;
import com.facebook.litho.testing.subcomponents.InspectableComponent;
import javax.annotation.Nullable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import com.facebook.litho.ComponentContext;
import com.facebook.litho.ResourceResolver;
import com.facebook.litho.testing.InspectableComponent;
import com.facebook.litho.testing.assertj.ComponentMatcher;
import com.facebook.litho.testing.subcomponents.InspectableComponent;

public final class SimpleTestSample implements SimpleTestSampleSpec {
public static Matcher matcher(ComponentContext c) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public interface ClassNames {
ClassName COMPONENT_MATCHER =
ClassName.bestGuess("com.facebook.litho.testing.assertj.ComponentMatcher");
ClassName INSPECTABLE_COMPONENT =
ClassName.bestGuess("com.facebook.litho.testing.InspectableComponent");
ClassName.bestGuess("com.facebook.litho.testing.subcomponents.InspectableComponent");
ClassName HAMCREST_MATCHER = ClassName.bestGuess("org.hamcrest.Matcher");
ClassName HAMCREST_CORE_IS = ClassName.bestGuess("org.hamcrest.core.Is");
}
5 changes: 5 additions & 0 deletions litho-testing/src/main/java/com/facebook/litho/testing/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ include_defs("//COMPONENTS_DEFS")
litho_android_library(
name = "testing",
srcs = glob(["*.java"]),
exported_deps = [
COMPONENTS_TESTING_SUBCOMPONENTS_TARGET,
COMPONENTS_TESTING_HELPER_TARGET,
],
provided_deps = [
COMPONENTS_ROBOLECTRIC_TARGET,
],
Expand All @@ -22,6 +26,7 @@ litho_android_library(
"PUBLIC",
],
deps = [
COMPONENTS_TESTING_ASSERTJ_TARGET,
COMPONENTS_ANDROIDSUPPORT_TARGET,
COMPONENTS_JAVA_TARGET,
COMPONENTS_RES_TARGET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.app.Activity;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.R;
import com.facebook.litho.testing.assertj.LithoRepresentation;
import org.assertj.core.api.Assertions;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.facebook.litho.ComponentContext;
import com.facebook.litho.ComponentTree;
import com.facebook.litho.LithoView;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import org.powermock.reflect.Whitebox;
import org.robolectric.shadows.ShadowLooper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ litho_android_library(
COMPONENTS_JAVA_TARGET,
COMPONENTS_JSR_TARGET,
COMPONENTS_POWERMOCK_REFLECT_TARGET,
COMPONENTS_TESTING_HELPER_TARGET,
COMPONENTS_TESTING_SUBCOMPONENTS_TARGET,
make_dep_path("litho-testing/src/main/java/com/facebook/litho/testing/viewtree:viewtree"),
COMPONENTS_TESTING_TARGET,
COMPONENTS_HAMCREST_CORE_TARGET,
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import com.facebook.litho.ComponentContext;
import com.facebook.litho.ComponentLifecycle;
import com.facebook.litho.LithoView;
import com.facebook.litho.testing.ComponentTestHelper;
import com.facebook.litho.testing.InspectableComponent;
import com.facebook.litho.testing.SubComponent;
import com.facebook.litho.testing.helper.ComponentTestHelper;
import com.facebook.litho.testing.subcomponents.InspectableComponent;
import com.facebook.litho.testing.subcomponents.SubComponent;
import java.util.List;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.Java6Assertions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import static org.hamcrest.core.Is.is;

import com.facebook.litho.ComponentLifecycle;
import com.facebook.litho.testing.InspectableComponent;
import com.facebook.litho.testing.subcomponents.InspectableComponent;
import org.assertj.core.api.Condition;
import org.assertj.core.description.TextDescription;
import org.hamcrest.Matcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

package com.facebook.litho.testing.assertj;

import com.facebook.litho.testing.InspectableComponent;
import com.facebook.litho.testing.subcomponents.InspectableComponent;
import org.assertj.core.api.Condition;

public abstract class ComponentMatcher extends Condition<InspectableComponent> {}
Loading

0 comments on commit e4ca178

Please sign in to comment.