Skip to content

Commit

Permalink
Merge pull request #2 from kajornsakp/1.0.0
Browse files Browse the repository at this point in the history
Update version to 1.0.0
  • Loading branch information
kajornsakp authored Dec 10, 2019
2 parents a946f50 + 1845e58 commit 995aea3
Show file tree
Hide file tree
Showing 53 changed files with 1,680 additions and 615 deletions.
80 changes: 76 additions & 4 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,77 @@
Code of Conduct
# Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
Examples of representing a project or community include using an official
project e-mail address, posting via an official social media account, or acting
as an appointed representative at an online or offline event. Representation of
a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at <[email protected]>. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

Facebook has adopted a Code of Conduct that we expect project participants to adhere to.
Please read the [full text](https://code.fb.com/codeofconduct/)
so that you can understand what actions will and will not be tolerated.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
0.11.0 (Oct 17 2019)
------
- Replaced direct usages of deprecated Gradle APIs
- Adopted the Contributor Covenant
- Added `failureDir` which saves the expected, actual and diff images of each failing test when verification fails.

0.10.0 (Jun 11 2019)
------
- Added batch downloading of screenshot images instead of pulling individual files
- Added Accessibility hierarchy information
- Added ability to specify max sizes for images
- Fixed addDeps functionality parameter in the plugin
- Fixed referenceDir functionality in the plugin
- Fixed an issue on Samsung devices where a crash would occur when faking a WindowAttachment
- Migrated to AndroidX

0.9.0 (Apr 1 2019)
-----
- Added a setMaxPixels method to the record builder interface to allow for really large images
Expand Down
15 changes: 0 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ buildscript {

dependencies {
classpath plugs.agp
classpath plugs.mavenGradle
classpath plugs.versions
}
}
Expand Down Expand Up @@ -51,20 +50,6 @@ task cleanAll(dependsOn: [
':layout-hierarchy-litho:clean',
])

task installAll(dependsOn: [
':core:install',
':plugin:install',
':layout-hierarchy-common:install',
':layout-hierarchy-litho:install',
])

task uploadAllArchives(dependsOn: [
':plugin:uploadArchives',
':core:uploadArchives',
':layout-hierarchy-common:install',
':layout-hierarchy-litho:install',
])

task integrationTest(dependsOn: ':sample:runDebugAndroidTestScreenshotTest') {
doLast {
assert taskLogOutput.toString().contains('Found 11 screenshots')
Expand Down
15 changes: 6 additions & 9 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

group = 'com.facebook.testing.screenshot'

Expand All @@ -38,6 +37,10 @@ android {
}
}

afterEvaluate {
generateReleaseBuildConfig.enabled = false
}

dependencies {

compileOnly deps.jsr305
Expand All @@ -47,17 +50,11 @@ dependencies {
androidTestImplementation deps.dexmaker
androidTestImplementation deps.dexmakerDx

androidTestImplementation deps.androidTestRules
androidTestImplementation deps.espresso
androidTestImplementation deps.mockito
androidTestImplementation deps.dexmakerMockito
androidTestImplementation deps.hamcrest
}

uploadArchives {
repositories {
mavenInstaller {
}
}
}

apply from: rootProject.file("release.gradle")
apply from: rootProject.file("gradle/gradle-mvn-push.gradle")
3 changes: 2 additions & 1 deletion core/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#

POM_NAME=Screenshot tests core android library
POM_NAME=Core
POM_DESCRIPTION=Screenshot tests core android library
POM_ARTIFACT_ID=core
POM_PACKAGING=aar
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.facebook.testing.screenshot;

import android.os.Bundle;
import android.support.test.runner.AndroidJUnitRunner;
import androidx.test.runner.AndroidJUnitRunner;

public class CustomScreenshotTestRunner extends AndroidJUnitRunner {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
*/
package com.facebook.testing.screenshot;

import android.test.InstrumentationTestCase;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.test.InstrumentationRegistry;
import org.junit.Before;

/**
* This is not really a test, this test is just a "fixture" for all the tests for the scripts
* related to running tests and getting screenshots.
*/
public class ScriptsFixtureTest extends InstrumentationTestCase {
public class ScriptsFixtureTest {
private static final int HEIGHT = 100;
private static final int WIDTH = 200;

private TextView mTextView;

@Override
@Before
public void setUp() throws Exception {
super.setUp();
mTextView = new TextView(getInstrumentation().getTargetContext());
mTextView = new TextView(InstrumentationRegistry.getInstrumentation().getTargetContext());
mTextView.setText("foobar");

// Unfortunately TextView needs a LayoutParams for onDraw
Expand All @@ -45,11 +45,6 @@ public void setUp() throws Exception {
measureAndLayout();
}

@Override
public void tearDown() throws Exception {
super.tearDown();
}

public void testGetTextViewScreenshot() throws Throwable {
Screenshot.snap(mTextView).record();
}
Expand All @@ -61,19 +56,24 @@ public void testSecondScreenshot() throws Throwable {
}

private void measureAndLayout() {
try {
runTestOnUiThread(
new Runnable() {
@Override
public void run() {
mTextView.measure(
View.MeasureSpec.makeMeasureSpec(WIDTH, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(HEIGHT, View.MeasureSpec.EXACTLY));
mTextView.layout(0, 0, mTextView.getMeasuredWidth(), mTextView.getMeasuredHeight());
}
});
} catch (Throwable t) {
throw new RuntimeException(t);
final Throwable[] exceptions = new Throwable[1];
InstrumentationRegistry.getInstrumentation()
.runOnMainSync(
new Runnable() {
public void run() {
try {
mTextView.measure(
View.MeasureSpec.makeMeasureSpec(WIDTH, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(HEIGHT, View.MeasureSpec.EXACTLY));
mTextView.layout(
0, 0, mTextView.getMeasuredWidth(), mTextView.getMeasuredHeight());
} catch (Throwable throwable) {
exceptions[0] = throwable;
}
}
});
if (exceptions[0] != null) {
throw new RuntimeException(exceptions[0]);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;

import android.test.InstrumentationTestCase;
import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.test.InstrumentationRegistry;
import com.facebook.testing.screenshot.test.R;
import org.junit.Before;

/** Tests {@link ViewHelpers} */
public class ViewHelpersTest extends InstrumentationTestCase {
public class ViewHelpersTest {
private TextView mTextView;
private Context targetContext;

@Override
@Before
public void setUp() throws Exception {
super.setUp();
mTextView = new TextView(getInstrumentation().getTargetContext());
targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
mTextView = new TextView(targetContext);
mTextView.setText("foobar");
}

Expand Down Expand Up @@ -72,11 +76,10 @@ public void testHeightAndWidthCorrectlyPropagated() throws Throwable {
}

public void testListViewHeight() throws Throwable {
ListView view = new ListView(getInstrumentation().getTargetContext());
ListView view = new ListView(targetContext);
view.setDividerHeight(0);
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(
getInstrumentation().getTargetContext(), R.layout.testing_simple_textview);
new ArrayAdapter<String>(targetContext, R.layout.testing_simple_textview);
view.setAdapter(adapter);

for (int i = 0; i < 20; i++) {
Expand Down
Loading

0 comments on commit 995aea3

Please sign in to comment.