Skip to content
A declarative framework for building efficient UIs on Android.
Branch: master
Clone or download
Chang Xing and facebook-github-bot add 'doesNotHaveVisibleText' into litho view & component assertion'
Summary:
I was writing tests for a text component that the content is determined by conditions. Obviously, I need to test that the content not in the target branch isn's showed up unexpectedly. Then I found we don't have the counter function for `hasVisibleText` like we had for `hasVisibleDrawable`.

I understood that testing text not show up is harder than drawable or test key because sub-string is counted too in this test framework, but the demand is real and test key isn't applicable to `MountSpec`.

Anyway, we should provide the ability and flexibility in the assertion framework then left the test author to solve the potential problems.

After some code search, I found we do have `doesNotHaveVisibleText` for `ViewTree` assertion, which is used in `LIthoViewAssert`, which is used in `ComponentAssert` which is used in litho spec tests.

Reviewed By: pasqualeanatriello

Differential Revision: D14941223

fbshipit-source-id: 43322b50f03fb0b9f72000c3c247dcc9645bedc1
Latest commit e4ebde6 Apr 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
.github
config
docs Re-enable snapshot for v0.25 Mar 15, 2019
gradle Cleanup Gradle deprecations (#530) Apr 10, 2019
lib
litho-annotations
litho-core
litho-espresso
litho-fresco Cleanup Gradle deprecations (#530) Apr 10, 2019
litho-instrumentation-tests
litho-intellij-plugin
litho-it-powermock
litho-it
litho-processor
litho-sections-annotations Move fb_native_wrapper to oss folder Oct 31, 2018
litho-sections-core
litho-sections-debug
litho-sections-processor
litho-sections-widget Disable RecyclerBinder#detach() by default Apr 16, 2019
litho-testing
litho-widget
sample-barebones-kotlin
sample-barebones Move targetSdk configuration from AndroidManifest to build.gradle. Fi… Apr 10, 2019
sample-codelab
sample-kotlin Move targetSdk configuration from AndroidManifest to build.gradle. Fi… Apr 10, 2019
sample Move targetSdk configuration from AndroidManifest to build.gradle. Fi… Apr 10, 2019
scripts
tools/build_defs/oss Back out "[litho-plugin] Configured plugin for deployment in fbandroid" Apr 2, 2019
.buckconfig
.gitignore Extend gitignore May 15, 2017
BUCK
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
LICENSE-examples
README.md
THIRD_PARTY_NOTICES.txt
build.gradle
gradle.properties Re-enable snapshot for v0.25 Mar 15, 2019
gradlew
gradlew.bat Initial gradle build Apr 5, 2017
settings.gradle

README.md

Litho CircleCI Join the chat at https://gitter.im/facebook/litho

Litho is a declarative framework for building efficient UIs on Android.

  • Declarative: Litho uses a declarative API to define UI components. You simply describe the layout for your UI based on a set of immutable inputs and the framework takes care of the rest.
  • Asynchronous layout: Litho can measure and layout your UI ahead of time without blocking the UI thread.
  • View flattening: Litho uses Yoga for layout and automatically reduces the number of ViewGroups that your UI contains.
  • Fine-grained recycling: Any component such as a text or image can be recycled and reused anywhere in the UI.

To get started, check out these links:

Installation

Litho can be integrated either in Gradle or Buck projects. Read our Getting Started guide for installation instructions.

Quick start

1. Initialize SoLoader in your Application class.

public class SampleApplication extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, false);
  }
}

2. Create and display a component in your Activity

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final ComponentContext context = new ComponentContext(this);

    final Component component = Text.create(context)
        .text("Hello World")
        .textSizeDip(50)
        .build();

    setContentView(LithoView.create(context, component));
}

Run sample

You can find more examples in our sample app.

To build and run (on an attached device/emulator) the sample app, execute

$ buck fetch sample
$ buck install -r sample

or, if you prefer Gradle,

$ ./gradlew :sample:installDebug

Contributing

Before contributing to Litho, please first read the Code of Conduct that we expect project participants to adhere to.

For pull requests, please see our CONTRIBUTING guide.

See our issues page for ideas on how to contribute or to let us know of any problems.

Please also read our Coding Style and Code of Conduct before you contribute.

Getting Help

  • Post on StackOverflow using the #litho tag.
  • Chat with us on Gitter.
  • Join our Facebook Group to stay up-to-date with announcements.
  • Please open GitHub issues only if you suspect a bug in the framework or have a feature request and not for general questions.

License

Litho is licensed under the Apache 2.0 License.

You can’t perform that action at this time.