-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from AAkira/v1.5.0
V1.5.0
- Loading branch information
Showing
35 changed files
with
2,226 additions
and
179 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
120 changes: 120 additions & 0 deletions
120
...Test/java/com/github/aakira/expandablelayout/uitest/ExpandableLinearLayoutActivityTest.kt
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,120 @@ | ||
package com.github.aakira.expandablelayout.uitest | ||
|
||
import android.app.Activity | ||
import android.support.test.InstrumentationRegistry | ||
import android.support.test.espresso.Espresso | ||
import android.support.test.espresso.Espresso.onView | ||
import android.support.test.espresso.assertion.ViewAssertions.matches | ||
import android.support.test.espresso.matcher.ViewMatchers.withId | ||
import android.support.test.runner.AndroidJUnit4 | ||
import android.test.ActivityInstrumentationTestCase2 | ||
import android.widget.TextView | ||
import com.github.aakira.expandablelayout.ExpandableLinearLayout | ||
import com.github.aakira.expandablelayout.uitest.utils.ElapsedIdLingResource | ||
import com.github.aakira.expandablelayout.uitest.utils.equalHeight | ||
import com.github.aakira.expandablelayout.uitest.utils.orMoreHeight | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.core.IsNull.notNullValue | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.hamcrest.CoreMatchers.`is` as _is | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ExpandableLinearLayoutActivityTest : ActivityInstrumentationTestCase2<ExpandableLinearLayoutActivity> | ||
(ExpandableLinearLayoutActivity::class.java) { | ||
|
||
companion object { | ||
val DURATION = 500L | ||
} | ||
|
||
@Before | ||
@Throws(Exception::class) | ||
public override fun setUp() { | ||
super.setUp() | ||
injectInstrumentation(InstrumentationRegistry.getInstrumentation()) | ||
} | ||
|
||
@After | ||
@Throws(Exception::class) | ||
public override fun tearDown() { | ||
super.tearDown() | ||
} | ||
|
||
@Test | ||
fun testExpandableRelativeLayout() { | ||
val activity = activity | ||
val instrumentation = instrumentation | ||
|
||
// check activity | ||
assertThat<Activity>(activity, notNullValue()) | ||
assertThat(instrumentation, notNullValue()) | ||
|
||
val expandableLayout = activity.findViewById(R.id.expandableLayout) as ExpandableLinearLayout | ||
val child1 = activity.findViewById(R.id.child1) as TextView | ||
val child2 = activity.findViewById(R.id.child2) as TextView | ||
val child3 = activity.findViewById(R.id.child3) as TextView | ||
val marginSmall = getActivity().resources.getDimensionPixelSize(R.dimen.margin_small) | ||
|
||
// default close | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight(0))) | ||
|
||
// open toggle | ||
instrumentation.runOnMainSync { expandableLayout.toggle() } | ||
var idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
onView(withId(R.id.expandableLayout)).check(matches(orMoreHeight(1))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
|
||
// move to first layout | ||
instrumentation.runOnMainSync { expandableLayout.moveChild(0) } | ||
idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight( | ||
child1, | ||
margin = marginSmall | ||
))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
|
||
// set close height | ||
instrumentation.runOnMainSync { expandableLayout.closePosition = expandableLayout.currentPosition; } | ||
|
||
// move to second layout | ||
instrumentation.runOnMainSync { expandableLayout.moveChild(1) } | ||
idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
// second.height != 0 && first.height + second.height == expandableLayout.height | ||
onView(withId(R.id.child2)).check(matches(orMoreHeight(1))) | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight( | ||
child1, | ||
child2, | ||
margin = marginSmall | ||
))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
|
||
// check toggle (close to first) | ||
instrumentation.runOnMainSync { expandableLayout.toggle() } | ||
idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
// move to first position | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight( | ||
child1, | ||
margin = marginSmall | ||
))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
|
||
// check toggle open (full) | ||
instrumentation.runOnMainSync { expandableLayout.toggle() } | ||
idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
// move to first position | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight( | ||
child1, | ||
child2, | ||
child3, | ||
margin = marginSmall | ||
))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
...est/java/com/github/aakira/expandablelayout/uitest/ExpandableLinearLayoutActivityTest2.kt
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,122 @@ | ||
package com.github.aakira.expandablelayout.uitest | ||
|
||
import android.app.Activity | ||
import android.support.test.InstrumentationRegistry | ||
import android.support.test.espresso.Espresso | ||
import android.support.test.espresso.Espresso.onView | ||
import android.support.test.espresso.assertion.ViewAssertions.matches | ||
import android.support.test.espresso.matcher.ViewMatchers.withId | ||
import android.support.test.runner.AndroidJUnit4 | ||
import android.test.ActivityInstrumentationTestCase2 | ||
import android.widget.RelativeLayout | ||
import android.widget.TextView | ||
import com.github.aakira.expandablelayout.ExpandableLinearLayout | ||
import com.github.aakira.expandablelayout.uitest.utils.ElapsedIdLingResource | ||
import com.github.aakira.expandablelayout.uitest.utils.equalHeight | ||
import com.github.aakira.expandablelayout.uitest.utils.orMoreHeight | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.core.IsNull.notNullValue | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.hamcrest.CoreMatchers.`is` as _is | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class ExpandableLinearLayoutActivityTest2 : ActivityInstrumentationTestCase2<ExpandableLinearLayoutActivity2> | ||
(ExpandableLinearLayoutActivity2::class.java) { | ||
|
||
companion object { | ||
val DURATION = 500L | ||
} | ||
|
||
@Before | ||
@Throws(Exception::class) | ||
public override fun setUp() { | ||
super.setUp() | ||
injectInstrumentation(InstrumentationRegistry.getInstrumentation()) | ||
} | ||
|
||
@After | ||
@Throws(Exception::class) | ||
public override fun tearDown() { | ||
super.tearDown() | ||
} | ||
|
||
@Test | ||
fun testExpandableRelativeLayout() { | ||
val activity = activity | ||
val instrumentation = instrumentation | ||
|
||
// check activity | ||
assertThat<Activity>(activity, notNullValue()) | ||
assertThat(instrumentation, notNullValue()) | ||
|
||
val expandableLayout = activity.findViewById(R.id.expandableLayout) as ExpandableLinearLayout | ||
val child1 = activity.findViewById(R.id.child1) as TextView | ||
val child2 = activity.findViewById(R.id.child2) as RelativeLayout | ||
val child3 = activity.findViewById(R.id.child3) as TextView | ||
val child4 = activity.findViewById(R.id.child4) as TextView | ||
val marginSmall = getActivity().resources.getDimensionPixelSize(R.dimen.margin_small) | ||
|
||
// default close | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight(0))) | ||
|
||
// open toggle | ||
instrumentation.runOnMainSync { expandableLayout.toggle() } | ||
var idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
onView(withId(R.id.expandableLayout)).check(matches(orMoreHeight(1))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
|
||
// move to first layout | ||
instrumentation.runOnMainSync { expandableLayout.moveChild(0) } | ||
idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight( | ||
child1, | ||
margin = marginSmall | ||
))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
|
||
// set close height | ||
instrumentation.runOnMainSync { expandableLayout.closePosition = expandableLayout.currentPosition; } | ||
|
||
// move to second layout | ||
instrumentation.runOnMainSync { expandableLayout.moveChild(1) } | ||
idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
onView(withId(R.id.child2)).check(matches(orMoreHeight(1))) | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight( | ||
child1, | ||
child2, | ||
margin = marginSmall | ||
))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
|
||
// check toggle (close to first) | ||
instrumentation.runOnMainSync { expandableLayout.toggle() } | ||
idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
// move to first position | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight( | ||
child1, | ||
margin = marginSmall | ||
))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
|
||
// check toggle open (full) | ||
instrumentation.runOnMainSync { expandableLayout.toggle() } | ||
idlingResource = ElapsedIdLingResource(DURATION) | ||
Espresso.registerIdlingResources(idlingResource) | ||
// move to first position | ||
onView(withId(R.id.expandableLayout)).check(matches(equalHeight( | ||
child1, | ||
child2, | ||
child3, | ||
child4, | ||
margin = marginSmall | ||
))) | ||
Espresso.unregisterIdlingResources(idlingResource) | ||
} | ||
} |
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
Oops, something went wrong.