Skip to content

Commit

Permalink
Add utils-fragment-androidx-integration-test module
Browse files Browse the repository at this point in the history
  • Loading branch information
uOOOO committed Dec 9, 2019
1 parent 1aa6a4f commit 9957787
Show file tree
Hide file tree
Showing 37 changed files with 1,358 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.android.tools.build:gradle:3.2.0'
// classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.2'
//classpath 'me.tatarka:gradle-retrolambda:3.5.0'
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Apr 07 13:18:33 CEST 2018
#Mon Dec 09 15:14:32 KST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ include ':mvp-common', ':mvp-queuing-presenter',
':presentermanager',
':utils-fragment'
// ':utils-fragment-integration-test'
// ':utils-fragment-androidx-integration-test'
59 changes: 59 additions & 0 deletions utils-fragment-androidx-integration-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Built application files
*.apk
*.ap_
bin/
gen/
classes/
gen-external-apklibs/

# Eclipse project files
.classpath
.project
.metadata
.settings

# IntelliJ files
.idea
*.iml

# OSX files
.DS_Store

# Windows files
Thumbs.db

# vi swap files
*.swp

# backup files
*.bak


# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Gradle files
.gradle/
build/
.gradle

#maven files
target/
/null

# Local configuration file (sdk path, etc)

local.properties

# Proguard folder generated by Eclipse
proguard/

#Log Files
*.log
63 changes: 63 additions & 0 deletions utils-fragment-androidx-integration-test/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2016 Hannes Dorfmann.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
apply plugin: 'com.android.application'

repositories {
flatDir {
dirs 'libs'
}
}

android {
compileSdkVersion 29
buildToolsVersion rootProject.ext.buildToolsVersion

compileOptions {
sourceCompatibility rootProject.ext.javaSourceCompatibility
targetCompatibility rootProject.ext.javaTargetCompatibility
}

defaultConfig {
applicationId "com.hannesdorfmann.mosby3.utils.fragment.integrationtest"
minSdkVersion rootProject.ext.minSdk
targetSdkVersion 29
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

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

lintOptions {
abortOnError false
}
}

dependencies {
implementation "androidx.appcompat:appcompat:1.1.0"
implementation project(':utils-fragment')

androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'junit:junit:' + rootProject.ext.junitVersion
}
2 changes: 2 additions & 0 deletions utils-fragment-androidx-integration-test/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android.useAndroidX=true
android.enableJetifier=true
Binary file not shown.
17 changes: 17 additions & 0 deletions utils-fragment-androidx-integration-test/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/hannes/android-sdks/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# 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 *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2016 Hannes Dorfmann.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.hannesdorfmann.mosby3.utils.fragment.integrationtest.backstack;

import android.content.pm.ActivityInfo;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import junit.framework.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class) public class AddFragmentTransactionActivityTest {

@Rule public ActivityTestRule<AddFragmentTransactionActivity> rule =
new ActivityTestRule<>(AddFragmentTransactionActivity.class);

@Ignore("We trust that FragmentManager implementation runs as expected")
@Test
public void fragmentsOnBackstack() throws Exception {
// Context of the app under test.
AddFragmentTransactionActivity activity = rule.getActivity();
Thread.sleep(1000);

//
// Screen orientation change
//
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// Will call onStop() where we set the onbackStack flag
Thread.sleep(1000);

Assert.assertEquals(AddFragmentTransactionActivity.FRAGMENTS_COUNT,
AddTransactionFragment.notOnBackStackCount);
Assert.assertEquals(AddFragmentTransactionActivity.FRAGMENTS_COUNT,
AddTransactionFragment.onBackStackCount);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2016 Hannes Dorfmann.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.hannesdorfmann.mosby3.utils.fragment.integrationtest.backstack;

import android.content.pm.ActivityInfo;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import junit.framework.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class) public class BackstackActivityWithChildFragmentsTest {

@Rule public ActivityTestRule<BackstackActivityWithChildFragments> rule =
new ActivityTestRule<>(BackstackActivityWithChildFragments.class);

@Ignore("We trust that FragmentManager implementation runs as expected")
@Test public void fragmentsOnBackstack() throws Exception {
// Context of the app under test.
BackstackActivityWithChildFragments activity = rule.getActivity();
Thread.sleep(1000);

FragmentOnBackstack fragmentOnBackstack;
ChildFragmentOnBackstack childFragmentOnBackstack;
ChildChildFragmentOnBackstack childChildFragmentOnBackstack;

SimpleFragmentNotOnBackstack simpleFragmentNotOnBackstack;
SimpleChildFragmentNotOnBackstack simpleChildFragmentNotOnBackstack;
SimpleChildChildFragmentNotOnBackstack simpleChildChildFragmentNotOnBackstack;

fragmentOnBackstack = activity.getFragmentOnBackstack();
Assert.assertNotNull(fragmentOnBackstack);
childFragmentOnBackstack = fragmentOnBackstack.getChilFragment();
Assert.assertNotNull(childFragmentOnBackstack);
childChildFragmentOnBackstack = childFragmentOnBackstack.getChildFragment();
Assert.assertNotNull(childChildFragmentOnBackstack);

simpleFragmentNotOnBackstack = activity.getFragmentNotOnBackstack();
Assert.assertNotNull(simpleFragmentNotOnBackstack);
simpleChildFragmentNotOnBackstack = simpleFragmentNotOnBackstack.getChilFragment();
Assert.assertNotNull(simpleChildFragmentNotOnBackstack);
simpleChildChildFragmentNotOnBackstack = simpleChildFragmentNotOnBackstack.getChildFragment();
Assert.assertNotNull(simpleChildChildFragmentNotOnBackstack);

Thread.sleep(1000);
//
// Screen orientation change
//
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// Will call onStop() where we set the onbackStack flag
Thread.sleep(1000);

Assert.assertTrue(fragmentOnBackstack.onBackStack);
Assert.assertTrue(childFragmentOnBackstack.onBackStack);
Assert.assertTrue(childChildFragmentOnBackstack.onBackStack);

Assert.assertFalse(simpleFragmentNotOnBackstack.onBackStack);
Assert.assertFalse(simpleChildFragmentNotOnBackstack.onBackStack);
Assert.assertFalse(simpleChildChildFragmentNotOnBackstack.onBackStack);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2016 Hannes Dorfmann.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.hannesdorfmann.mosby3.utils.fragment.integrationtest.backstack;

import android.content.pm.ActivityInfo;

import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import junit.framework.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class) public class ReplaceFragmentTransactionActivityTest {

@Rule public ActivityTestRule<ReplaceFragmentTransactionActivity> rule =
new ActivityTestRule<>(ReplaceFragmentTransactionActivity.class);

@Ignore("We trust that FragmentManager implementation runs as expected")
@Test public void fragmentsOnBackstack() throws Exception {
// Context of the app under test.
ReplaceFragmentTransactionActivity activity = rule.getActivity();

Thread.sleep(25000);

//
// Screen orientation change
//
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// Will call onStop() where we set the onbackStack flag
Thread.sleep(1000);

Assert.assertEquals(ReplaceFragmentTransactionActivity.FRAGMENTS_COUNT,
ReplaceTransactionFragment.onBackStackCount);

Assert.assertEquals(ReplaceFragmentTransactionActivity.FRAGMENTS_COUNT,
ReplaceTransactionFragment.notOnBackStackCount);
}
}
Loading

0 comments on commit 9957787

Please sign in to comment.