Skip to content

Commit

Permalink
feat: 🎸 [DSY-1492] Refactoring packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mlcsouza committed Oct 13, 2020
1 parent 0910cf7 commit 6bc7ca1
Show file tree
Hide file tree
Showing 290 changed files with 1,359 additions and 171 deletions.
15 changes: 15 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
1 change: 1 addition & 0 deletions android/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
81 changes: 81 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.facebook.testing.screenshot'

project.ext.react = [
enableHermes : false, // clean and rebuild if changing
bundleInRelease: false,
]

apply from: "../../node_modules/react-native/react.gradle"

def enableHermes = project.ext.react.get("enableHermes", false);
def jscFlavor = 'org.webkit:android-jsc:+'

android {
compileSdkVersion 30
buildToolsVersion "30.0.0"

defaultConfig {
applicationId "com.natura.sampleintegration"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true

testInstrumentationRunner "com.natura.CustomTestRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])

implementation(name: 'SellingCartLibrary-release', ext: 'aar')
implementation(name: 'rn-sample-android-lib-release', ext: 'aar')

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
hmlImplementation files(hermesPath + "hermes-debug.aar")
qxxImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.multidex:multidex:2.0.0'
implementation "com.facebook.react:react-native:0.63.3" // From node_modules
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.test:rules:$rootProject.androidXTestVersion"
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'

// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:$rootProject.archLifecycleVersion"
kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.archLifecycleVersion"

//Natura Design System dependencies
implementation "com.natura.android:designsystem:$rootProject.designSystemVersion"
implementation "com.google.android.material:material:$rootProject.materialVersion"

//Screenshot tests
androidTestImplementation "com.facebook.testing.screenshot:layout-hierarchy-common:$rootProject.screenshotTestVersion"
androidTestImplementation "com.facebook.testing.screenshot:layout-hierarchy-litho:$rootProject.screenshotTestVersion"

}
Binary file added android/app/libs/SellingCartLibrary-release.aar
Binary file not shown.
Binary file not shown.
21 changes: 21 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.natura">

<!-- needed for screenshot test library -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application android:requestLegacyExternalStorage="true"/>
</manifest>
17 changes: 17 additions & 0 deletions android/app/src/androidTest/java/com/natura/CustomTestRunner.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.natura

import android.os.Bundle
import androidx.test.runner.AndroidJUnitRunner
import com.facebook.testing.screenshot.ScreenshotRunner

class CustomTestRunner: AndroidJUnitRunner() {
override fun onCreate(arguments: Bundle?) {
ScreenshotRunner.onCreate(this, arguments)
super.onCreate(arguments)
}

override fun finish(resultCode: Int, results: Bundle?) {
ScreenshotRunner.onDestroy()
super.finish(resultCode, results)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.natura

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.natura.sampleintegration", appContext.packageName)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.natura

import androidx.recyclerview.widget.RecyclerView
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.espresso.action.ViewActions.*
import androidx.test.espresso.*
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.rule.ActivityTestRule
import com.facebook.testing.screenshot.Screenshot
import kotlinx.android.synthetic.main.activity_native_icons.*
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class NativeIconsScreenshotTest {
@get:Rule
var activityTestRule = ActivityTestRule(NativeIconsActivity::class.java, false, false)
lateinit var iconsActivity: NativeIconsActivity

@Before
fun setup() {
iconsActivity = activityTestRule.launchActivity(null)
}

@Test
fun checkIcons() {
val totalIcons = iconsActivity.iconsRecyclerView.adapter?.itemCount ?: 0

for(i in 0..totalIcons) {
onView(withId(R.id.iconsRecyclerView))
.perform(scrollToPosition<RecyclerView.ViewHolder>(i))
Screenshot.snapActivity(iconsActivity).setName("Icons Activity $i").record()
}
}
}
25 changes: 25 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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="com.natura">

<application
android:allowBackup="true"
android:name=".SampleIntegrationApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Natura"
tools:replace="android:name">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NativeIconsActivity" />
</application>

</manifest>
Loading

0 comments on commit 6bc7ca1

Please sign in to comment.