Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change BackstackAccessor.isInBackStackAndroidX() implementation #338

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ android:
components:
- tools
- platform-tools
- build-tools-28.0.1
- build-tools-28.0.2
- extra-android-m2repository
- android-28
- sys-img-armeabi-v7a-android-17
Expand Down
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.10.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ActivityMviDelegateImpl<V extends MvpView, P extends MviPresenter<V
implements ActivityMviDelegate {


public static boolean DEBUG = false;
public static final boolean DEBUG = false;
private static final String DEBUG_TAG = "ActivityMviDelegateImpl";
private static final String KEY_MOSBY_VIEW_ID = "com.hannesdorfmann.mosby3.activity.mvi.id";
private String mosbyViewId = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
public class FragmentMviDelegateImpl<V extends MvpView, P extends MviPresenter<V, ?>>
implements FragmentMviDelegate<V, P> {

public static boolean DEBUG = false;
public static final boolean DEBUG = false;
private static final String DEBUG_TAG = "FragmentMviDelegateImpl";
private static final String KEY_MOSBY_VIEW_ID = "com.hannesdorfmann.mosby3.fragment.mvi.id";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ViewGroupMviDelegateImpl<V extends MvpView, P extends MviPresenter<

// TODO allow custom save state hook in

public static boolean DEBUG = false;
public static final boolean DEBUG = false;
private static final String DEBUG_TAG = "ViewGroupMviDelegateImp";

private ViewGroupMviDelegateCallback<V, P> delegateCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class ActivityMvpDelegateImpl<V extends MvpView, P extends MvpPresenter<V

protected static final String KEY_MOSBY_VIEW_ID = "com.hannesdorfmann.mosby3.activity.mvp.id";

public static boolean DEBUG = false;
public static final boolean DEBUG = false;
private static final String DEBUG_TAG = "ActivityMvpDelegateImpl";

private MvpDelegateCallback<V, P> delegateCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class FragmentMvpDelegateImpl<V extends MvpView, P extends MvpPresenter<V

protected static final String KEY_MOSBY_VIEW_ID = "com.hannesdorfmann.mosby3.fragment.mvp.id";

public static boolean DEBUG = false;
public static final boolean DEBUG = false;
private static final String DEBUG_TAG = "FragmentMvpVSDelegate";

private MvpDelegateCallback<V, P> delegateCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ViewGroupMvpDelegateImpl<V extends MvpView, P extends MvpPresenter<

// TODO allow custom save state hook in

public static boolean DEBUG = false;
public static final boolean DEBUG = false;
private static final String DEBUG_TAG = "ViewGroupMvpDelegateImp";

private ViewGroupDelegateCallback<V, P> delegateCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
final public class PresenterManager {

public static boolean DEBUG = false;
public static final boolean DEBUG = false;
public static final String DEBUG_TAG = "PresenterManager";
final static String KEY_ACTIVITY_ID = "com.hannesdorfmann.mosby3.MosbyPresenterManagerActivityId";

Expand Down
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);
}
}
Loading