-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
337 additions
and
64 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
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
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
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
71 changes: 71 additions & 0 deletions
71
moxy/src/test/java/com/arellomobile/mvp/provide_methods_test/ProvideMethodsTest.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,71 @@ | ||
package com.arellomobile.mvp.provide_methods_test; | ||
|
||
import android.os.Bundle; | ||
|
||
import com.arellomobile.mvp.MvpDelegate; | ||
import com.arellomobile.mvp.provide_methods_test.resources.LocalProvidedView; | ||
import com.arellomobile.mvp.provide_methods_test.resources.TwoLocalProvidedView; | ||
import com.arellomobile.mvp.provide_methods_test.resources.TwoWeakWithSamePresenterIdView; | ||
import com.arellomobile.mvp.provide_methods_test.resources.WeakProvidedView; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.RobolectricTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
/** | ||
* Date: 30.12.2016 | ||
* Time: 11:18 | ||
* | ||
* @author Yuri Shmakov | ||
*/ | ||
@RunWith(RobolectricTestRunner.class) | ||
@Config(manifest = Config.NONE) | ||
public class ProvideMethodsTest { | ||
|
||
@Test | ||
public void testLocalIsProvided() { | ||
LocalProvidedView view = new LocalProvidedView(); | ||
|
||
view.delegate = new MvpDelegate<>(view); | ||
view.delegate.onCreate(new Bundle()); | ||
|
||
Assert.assertNotNull(view.oneLocalPresenter); | ||
Assert.assertSame(view.oneLocalPresenter, view.oneLocalProvidedPresenter); | ||
} | ||
|
||
@Test | ||
public void testTwoLocalUseDifferentProvided() { | ||
TwoLocalProvidedView view = new TwoLocalProvidedView(); | ||
|
||
view.delegate = new MvpDelegate<>(view); | ||
view.delegate.onCreate(new Bundle()); | ||
|
||
Assert.assertNotSame(view.oneLocalPresenter, view.secondLocalPresenter); | ||
} | ||
|
||
@Test | ||
public void testWeakPresenterWithHardcodedTag() { | ||
WeakProvidedView view = new WeakProvidedView(); | ||
|
||
view.delegate = new MvpDelegate<>(view); | ||
view.delegate.onCreate(new Bundle()); | ||
|
||
Assert.assertNotNull(view.weakPresenter); | ||
Assert.assertSame(view.weakPresenter, view.weakProvidedPresenter); | ||
} | ||
|
||
@Test | ||
public void testTwoWeakPresenterWithSamePresenterIdTest() { | ||
TwoWeakWithSamePresenterIdView view = new TwoWeakWithSamePresenterIdView(); | ||
|
||
view.delegate = new MvpDelegate<>(view); | ||
view.delegate.onCreate(new Bundle()); | ||
|
||
Assert.assertNotNull(view.oneWeakPresenter); | ||
Assert.assertNotNull(view.secondWeakPresenter); | ||
|
||
Assert.assertSame(view.oneWeakPresenter, view.secondWeakPresenter); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../src/test/java/com/arellomobile/mvp/provide_methods_test/resources/LocalProvidedView.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,26 @@ | ||
package com.arellomobile.mvp.provide_methods_test.resources; | ||
|
||
import com.arellomobile.mvp.MvpDelegate; | ||
import com.arellomobile.mvp.presenter.InjectPresenter; | ||
import com.arellomobile.mvp.presenter.ProvidePresenter; | ||
|
||
/** | ||
* Date: 30.12.2016 | ||
* Time: 12:05 | ||
* | ||
* @author Yuri Shmakov | ||
*/ | ||
|
||
public class LocalProvidedView implements TestView { | ||
@InjectPresenter | ||
public TestPresenter oneLocalPresenter; | ||
public TestPresenter oneLocalProvidedPresenter; | ||
|
||
public MvpDelegate<LocalProvidedView> delegate; | ||
|
||
@ProvidePresenter | ||
TestPresenter provideLocalPresenter() { | ||
oneLocalProvidedPresenter = new TestPresenter(); | ||
return oneLocalProvidedPresenter; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
moxy/src/test/java/com/arellomobile/mvp/provide_methods_test/resources/SuperView.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,35 @@ | ||
package com.arellomobile.mvp.provide_methods_test.resources; | ||
|
||
import com.arellomobile.mvp.MvpDelegate; | ||
import com.arellomobile.mvp.presenter.InjectPresenter; | ||
import com.arellomobile.mvp.presenter.ProvidePresenter; | ||
|
||
/** | ||
* Date: 30.12.2016 | ||
* Time: 10:12 | ||
* | ||
* @author Yuri Shmakov | ||
*/ | ||
|
||
public class SuperView implements TestView { | ||
@InjectPresenter | ||
public TestPresenter oneLocalPresenter; | ||
public TestPresenter oneLocalProvidedPresenter; | ||
|
||
@InjectPresenter | ||
public TestPresenter secondLocalPresenter; | ||
|
||
@InjectPresenter(presenterId = "one_global") | ||
public TestPresenter oneGlobalPresenter; | ||
|
||
@InjectPresenter(presenterId = "second_global") | ||
public TestPresenter secondGlobalPresenter; | ||
|
||
public MvpDelegate<SuperView> delegate; | ||
|
||
@ProvidePresenter | ||
public TestPresenter provideLocalPresenter() { | ||
oneLocalProvidedPresenter = new TestPresenter(); | ||
return oneLocalProvidedPresenter; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
moxy/src/test/java/com/arellomobile/mvp/provide_methods_test/resources/TestPresenter.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,13 @@ | ||
package com.arellomobile.mvp.provide_methods_test.resources; | ||
|
||
import com.arellomobile.mvp.MvpPresenter; | ||
|
||
/** | ||
* Date: 30.12.2016 | ||
* Time: 10:10 | ||
* | ||
* @author Yuri Shmakov | ||
*/ | ||
|
||
public class TestPresenter extends MvpPresenter<TestView> { | ||
} |
13 changes: 13 additions & 0 deletions
13
moxy/src/test/java/com/arellomobile/mvp/provide_methods_test/resources/TestView.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,13 @@ | ||
package com.arellomobile.mvp.provide_methods_test.resources; | ||
|
||
import com.arellomobile.mvp.MvpView; | ||
|
||
/** | ||
* Date: 30.12.2016 | ||
* Time: 10:11 | ||
* | ||
* @author Yuri Shmakov | ||
*/ | ||
|
||
public interface TestView extends MvpView { | ||
} |
28 changes: 28 additions & 0 deletions
28
...c/test/java/com/arellomobile/mvp/provide_methods_test/resources/TwoLocalProvidedView.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,28 @@ | ||
package com.arellomobile.mvp.provide_methods_test.resources; | ||
|
||
import com.arellomobile.mvp.MvpDelegate; | ||
import com.arellomobile.mvp.presenter.InjectPresenter; | ||
import com.arellomobile.mvp.presenter.ProvidePresenter; | ||
|
||
/** | ||
* Date: 30.12.2016 | ||
* Time: 12:39 | ||
* | ||
* @author Yuri Shmakov | ||
*/ | ||
|
||
public class TwoLocalProvidedView implements TestView { | ||
|
||
@InjectPresenter | ||
public TestPresenter oneLocalPresenter; | ||
|
||
@InjectPresenter | ||
public TestPresenter secondLocalPresenter; | ||
|
||
public MvpDelegate<TwoLocalProvidedView> delegate; | ||
|
||
@ProvidePresenter | ||
TestPresenter provideLocalPresenter() { | ||
return new TestPresenter(); | ||
} | ||
} |
Oops, something went wrong.