-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utils-fragment-androidx-integration-test module
- Loading branch information
Showing
37 changed files
with
1,358 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
17
utils-fragment-androidx-integration-test/proguard-rules.pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 *; | ||
#} |
60 changes: 60 additions & 0 deletions
60
...n/mosby3/utils/fragment/integrationtest/backstack/AddFragmentTransactionActivityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...by3/utils/fragment/integrationtest/backstack/BackstackActivityWithChildFragmentsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...sby3/utils/fragment/integrationtest/backstack/ReplaceFragmentTransactionActivityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.