Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3ad41ed authored by Baptiste Billard's avatar Baptiste Billard
Browse files

Problem to run sceenshot tests

parent b467988b
Loading
Loading
Loading
Loading
Loading
+32 −15
Original line number Diff line number Diff line
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

//screenshot testing
apply plugin: 'com.facebook.testing.screenshot'



//buildscript {
//  repositories {
//    google()
//    jcenter()
//  }
buildscript {
  repositories {
    google()
    jcenter()
  }

  dependencies {
    //for screenshot testing

//  dependencies {
//    //for screenshot testing
//    classpath 'com.facebook.testing.screenshot:plugin:0.13.0'
//  }
//}
  }
}

android {
    compileSdkVersion 28
@@ -38,7 +39,7 @@ android {
        versionCode 49
        versionName "1.0.1"

        testInstrumentationRunner "com.facebook.testing.screenshot.app.ScreenshotTestRunner"
        testInstrumentationRunner "com.facebook.testing.screenshot.ScreenshotTestRunner"
    }
    buildTypes {
        release {
@@ -56,7 +57,7 @@ android {
}

dependencies {
    implementation project(':cert4android')
    implementation project(':cert4android')  //changed

    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxjava:1.3.8'
@@ -81,10 +82,26 @@ dependencies {
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test:rules:1.1.0'
    // Optional -- Hamcrest library
    //androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
    androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
    // Optional -- UI testing with Espresso
    //androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    // Optional -- UI testing with UI Automator
    //androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'

    // Standard Android View Plugins (TextView, etc)
    implementation 'com.facebook.testing.screenshot:layout-hierarchy-common:0.13.0'

    // Litho Component Plugins
    implementation 'com.facebook.testing.screenshot:layout-hierarchy-litho:0.13.0'

    // Core library
    androidTestImplementation 'androidx.test:core:1.0.0'
    implementation "androidx.core:core-ktx:+"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"


}
repositories {
    maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
    mavenCentral()
}
+26 −7
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.facebook.testing.screenshot;

import android.content.Context;
import android.test.InstrumentationTestCase;
import android.view.LayoutInflater;
import androidx.test.platform.app.InstrumentationRegistry;
import com.facebook.litho.LithoView;
@@ -24,16 +25,34 @@ import com.facebook.testing.screenshot.Screenshot;
import com.facebook.testing.screenshot.ViewHelpers;
import org.junit.Test;

import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import androidx.test.core.app.ApplicationProvider;

import foundation.e.notes.R;   //in order to use the right R.layout

public class ExampleScreenshotTest {
  @Test
  public void testDefault() {
    Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
    LayoutInflater inflater = LayoutInflater.from(targetContext);
    LithoView view = (LithoView) inflater.inflate(R.layout.litho_view, null, false);

    view.setComponent(Example.create(view.getComponentContext()).build());
  public void doScreenshot() {
    /*
     * Create and set up your view some how. This might be inflating,
     * or creating from a view class. You might want to set properties
     * on the view.
     */
    LayoutInflater inflater = LayoutInflater.from(getApplicationContext());  //removed the first argument getInstrumentation(),
    android.view.View view = inflater.inflate(R.layout.activity_notes_list_view, null, false);

    /*
     * Measure and layout the view. In this example we give an exact
     * width but all the height to be WRAP_CONTENT.
     */
    ViewHelpers.setupView(view).setExactWidthDp(300).layout();

    /*
     * Take the actual screenshot. At the end of this call the screenshot
     * is stored on the device, and the gradle plugin takes care of
     * pulling it and displaying it to you in nice ways.
     */
    Screenshot.snap(view).record();
  }
}
 No newline at end of file
+5 −3
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="foundation.e.notes">

    <uses-permission android:name="android.permission.INTERNET" />
@@ -11,8 +12,7 @@
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


    <uses-library android:name="android.test.runner"
                  android:required="false" />



    <application
@@ -23,7 +23,9 @@
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        android:theme="@style/AppTheme"
        android:debuggable="true"
        tools:ignore="HardcodedDebugMode">
        <activity
            android:name="foundation.e.notes.android.activity.SplashscreenActivity"
            android:theme="@style/SplashTheme">
+4 −1
Original line number Diff line number Diff line
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.4.0-rc'
    repositories {
        google()
        jcenter()
        maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }

    }
    dependencies {
        apply plugin: 'maven'
        classpath 'com.android.tools.build:gradle:3.5.2'
        classpath 'com.android.tools.build:gradle:4.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

        //for screenshot testing
        classpath 'com.facebook.testing.screenshot:plugin:0.13.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"


    }
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Loading