diff --git a/build.gradle b/build.gradle index 57789f9..04c7422 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ buildscript { repositories { mavenLocal() jcenter() - mavenCentral() google() } @@ -27,7 +26,6 @@ buildscript { classpath plugs.agp classpath plugs.screenshot classpath plugs.kotlin - classpath "io.screenshotbot:plugin:0.1.6" } } @@ -35,7 +33,6 @@ allprojects { repositories { mavenLocal() jcenter() - mavenCentral() google() } } @@ -45,8 +42,6 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'com.facebook.testing.screenshot' -apply plugin: 'io.screenshotbot.plugin' - android { compileSdkVersion versions.compileSdk @@ -57,7 +52,10 @@ android { versionCode 1 versionName "1.0" testInstrumentationRunner "com.facebook.testing.screenshot.sample.ScreenshotTestRunner" - ndkVersion "20.1.5948944" + testInstrumentationRunnerArguments clearPackageData: 'true' + } + testOptions { + execution 'ANDROIDX_TEST_ORCHESTRATOR' } } @@ -73,11 +71,12 @@ dependencies { kapt deps.lithoProcessor implementation deps.soLoader - implementation "androidx.constraintlayout:constraintlayout:2.0.4" androidTestImplementation deps.screenshotTestCommon androidTestImplementation deps.screenshotTestLitho androidTestImplementation deps.junit + androidTestImplementation deps.testRunner + androidTestUtil deps.orchestrator androidTestImplementation(deps.espresso) { exclude group: 'com.android.support', module: 'support-annotations' exclude group: 'com.google.code.findbugs', module: 'jsr305' @@ -87,9 +86,5 @@ dependencies { screenshots { multipleDevices true -} - -screenshotbot { - channelName "screenshotbot-example" - githubRepo "https://github.com/tdrhq/screenshotbot-example" + pythonExecutable 'python3' } diff --git a/src/androidTest/java/com/facebook/testing/screenshot/sample/ExampleScreenshotTest.java b/src/androidTest/java/com/facebook/testing/screenshot/sample/ExampleScreenshotTest.java index b0f368e..55fa2e0 100644 --- a/src/androidTest/java/com/facebook/testing/screenshot/sample/ExampleScreenshotTest.java +++ b/src/androidTest/java/com/facebook/testing/screenshot/sample/ExampleScreenshotTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,14 +18,22 @@ import android.content.Context; import android.view.LayoutInflater; +import androidx.test.annotation.UiThreadTest; import androidx.test.platform.app.InstrumentationRegistry; import com.facebook.litho.LithoView; import com.facebook.testing.screenshot.Screenshot; import com.facebook.testing.screenshot.ViewHelpers; +import org.junit.Before; import org.junit.Test; public class ExampleScreenshotTest { + @Before + public void before() { + InstrumentationRegistry.getInstrumentation().getUiAutomation(); + } + @Test + @UiThreadTest public void testDefault() { Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); LayoutInflater inflater = LayoutInflater.from(targetContext); @@ -33,7 +41,7 @@ public void testDefault() { view.setComponent(Example.create(view.getComponentContext()).build()); - ViewHelpers.setupView(view).setExactWidthDp(303).layout(); + ViewHelpers.setupView(view).setExactWidthDp(300).setExactHeightDp(300).layout(); Screenshot.snap(view).record(); } } diff --git a/src/androidTest/java/com/facebook/testing/screenshot/sample/ImageRowScreenshotTest.java b/src/androidTest/java/com/facebook/testing/screenshot/sample/ImageRowScreenshotTest.java index 4ded650..a038d56 100644 --- a/src/androidTest/java/com/facebook/testing/screenshot/sample/ImageRowScreenshotTest.java +++ b/src/androidTest/java/com/facebook/testing/screenshot/sample/ImageRowScreenshotTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,15 +18,23 @@ import android.content.Context; import android.view.LayoutInflater; +import androidx.test.annotation.UiThreadTest; import androidx.test.platform.app.InstrumentationRegistry; import com.facebook.litho.LithoView; import com.facebook.testing.screenshot.Screenshot; import com.facebook.testing.screenshot.ViewHelpers; +import org.junit.Before; import org.junit.Test; public class ImageRowScreenshotTest { + @Before + public void before() { + InstrumentationRegistry.getInstrumentation().getUiAutomation(); + } + @Test - public void testDefault2() { + @UiThreadTest + public void testDefault() { Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); LayoutInflater inflater = LayoutInflater.from(targetContext); LithoView view = (LithoView) inflater.inflate(R.layout.litho_view, null, false); diff --git a/src/androidTest/java/com/facebook/testing/screenshot/sample/MainActivityTest.kt b/src/androidTest/java/com/facebook/testing/screenshot/sample/MainActivityTest.kt index 92a5c53..cba6a0b 100644 --- a/src/androidTest/java/com/facebook/testing/screenshot/sample/MainActivityTest.kt +++ b/src/androidTest/java/com/facebook/testing/screenshot/sample/MainActivityTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,16 +16,17 @@ package com.facebook.testing.screenshot.sample - import android.view.View import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.platform.app.InstrumentationRegistry import androidx.test.rule.ActivityTestRule import com.facebook.testing.screenshot.Screenshot import org.hamcrest.core.AllOf.allOf +import org.junit.Before import org.junit.Rule import org.junit.Test @@ -33,6 +34,11 @@ class MainActivityTest { @get:Rule var activityTestRule = ActivityTestRule(MainActivity::class.java, false, false) + @Before + fun before() { + InstrumentationRegistry.getInstrumentation().getUiAutomation() + } + @Test fun testScreenshotEntireActivity() { val activity = activityTestRule.launchActivity(null) diff --git a/src/androidTest/java/com/facebook/testing/screenshot/sample/ScreenshotTestRunner.kt b/src/androidTest/java/com/facebook/testing/screenshot/sample/ScreenshotTestRunner.kt index 0292303..0756e55 100644 --- a/src/androidTest/java/com/facebook/testing/screenshot/sample/ScreenshotTestRunner.kt +++ b/src/androidTest/java/com/facebook/testing/screenshot/sample/ScreenshotTestRunner.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,4 +43,3 @@ class ScreenshotTestRunner : AndroidJUnitRunner() { super.finish(resultCode, results) } } - diff --git a/src/androidTest/java/com/facebook/testing/screenshot/sample/ScreenshotViewAction.kt b/src/androidTest/java/com/facebook/testing/screenshot/sample/ScreenshotViewAction.kt index 9893500..b69d204 100644 --- a/src/androidTest/java/com/facebook/testing/screenshot/sample/ScreenshotViewAction.kt +++ b/src/androidTest/java/com/facebook/testing/screenshot/sample/ScreenshotViewAction.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package com.facebook.testing.screenshot.sample - import android.view.View import androidx.test.espresso.UiController import androidx.test.espresso.ViewAction diff --git a/src/androidTest/java/com/facebook/testing/screenshot/sample/StandardAndroidViewTest.kt b/src/androidTest/java/com/facebook/testing/screenshot/sample/StandardAndroidViewTest.kt index dd6e566..dd4db55 100644 --- a/src/androidTest/java/com/facebook/testing/screenshot/sample/StandardAndroidViewTest.kt +++ b/src/androidTest/java/com/facebook/testing/screenshot/sample/StandardAndroidViewTest.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,4 +69,3 @@ class StandardAndroidViewTest { Screenshot.snap(view).record() } } - diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index bf7fa24..9223f20 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -21,18 +21,6 @@ - - - - - - - - - diff --git a/src/main/java/com/facebook/testing/screenshot/sample/App.kt b/src/main/java/com/facebook/testing/screenshot/sample/App.kt index e7266c0..703fa3b 100644 --- a/src/main/java/com/facebook/testing/screenshot/sample/App.kt +++ b/src/main/java/com/facebook/testing/screenshot/sample/App.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,4 +24,4 @@ class App : Application() { super.onCreate() SoLoader.init(this, false) } -} \ No newline at end of file +} diff --git a/src/main/java/com/facebook/testing/screenshot/sample/ExampleSpec.kt b/src/main/java/com/facebook/testing/screenshot/sample/ExampleSpec.kt index 995a394..3299a68 100644 --- a/src/main/java/com/facebook/testing/screenshot/sample/ExampleSpec.kt +++ b/src/main/java/com/facebook/testing/screenshot/sample/ExampleSpec.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,9 +31,7 @@ object ExampleSpec { fun onCreateLayout(c: ComponentContext): Component = Column.create(c) .child(ImageRow.create(c)) - .child( - Text.create(c) - .textRes(R.string.large_text)) + .child(Text.create(c).textRes(R.string.large_text)) .paddingDip(YogaEdge.ALL, 16f) .border( Border.create(c) diff --git a/src/main/java/com/facebook/testing/screenshot/sample/ImageRowSpec.kt b/src/main/java/com/facebook/testing/screenshot/sample/ImageRowSpec.kt index ae783c3..3db7c50 100644 --- a/src/main/java/com/facebook/testing/screenshot/sample/ImageRowSpec.kt +++ b/src/main/java/com/facebook/testing/screenshot/sample/ImageRowSpec.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/com/facebook/testing/screenshot/sample/MainActivity.kt b/src/main/java/com/facebook/testing/screenshot/sample/MainActivity.kt index c2de17f..309c252 100644 --- a/src/main/java/com/facebook/testing/screenshot/sample/MainActivity.kt +++ b/src/main/java/com/facebook/testing/screenshot/sample/MainActivity.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) Facebook, Inc. and its affiliates. + * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,24 +19,19 @@ package com.facebook.testing.screenshot.sample import android.content.Context import android.content.Intent import android.os.Bundle +import android.view.Menu +import android.widget.TextView import androidx.annotation.ColorRes +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.snackbar.Snackbar -import androidx.core.content.ContextCompat -import androidx.appcompat.app.AppCompatActivity -import androidx.appcompat.widget.Toolbar -import android.view.Menu -import android.view.View -import android.widget.TextView -import com.facebook.litho.LithoView class MainActivity : AppCompatActivity() { companion object { private const val STATUS = "status" - fun intent(status: Status) = Intent().apply { - putExtra(STATUS, status.name) - } + fun intent(status: Status) = Intent().apply { putExtra(STATUS, status.name) } } enum class Status { @@ -53,18 +48,21 @@ class MainActivity : AppCompatActivity() { val textView = findViewById(R.id.text_view) val status = Status.valueOf(intent.string(STATUS, Status.OK.name)) when (status) { - Status.OK -> textView.run { - setTextColor(context.color(R.color.ok)) - text = "Status is OK" - } - Status.WARNING -> textView.run { - setTextColor(context.color(R.color.warning)) - text = "Status is WARNING" - } - Status.ERROR -> textView.run { - setTextColor(context.color(R.color.error)) - text = "Status is ERROR" - } + Status.OK -> + textView.run { + setTextColor(context.color(R.color.ok)) + text = "Status is OK" + } + Status.WARNING -> + textView.run { + setTextColor(context.color(R.color.warning)) + text = "Status is WARNING" + } + Status.ERROR -> + textView.run { + setTextColor(context.color(R.color.error)) + text = "Status is ERROR" + } } findViewById(R.id.fab).setOnClickListener { view -> diff --git a/src/main/res/layout/search_bar.xml b/src/main/res/layout/search_bar.xml index 76ffe2f..7633a22 100644 --- a/src/main/res/layout/search_bar.xml +++ b/src/main/res/layout/search_bar.xml @@ -10,10 +10,10 @@ android:layout_weight="1" android:singleLine="true" android:textColor="@android:color/black" - android:hint="Search the world!" /> + android:hint="Search the world" />