-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Metadata to query if an item is first or last
- Loading branch information
Showing
7 changed files
with
103 additions
and
5 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
46 changes: 46 additions & 0 deletions
46
...odules/item/metadata/WhenOnBindInvoked_ThenItemIsFirstMetadata_ShouldBeTrueOnFirstItem.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,46 @@ | ||
@file:Suppress("ClassName") | ||
|
||
package com.idanatz.oneadapter.tests.modules.item.metadata | ||
|
||
import android.util.Log | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.idanatz.oneadapter.external.modules.ItemModule | ||
import com.idanatz.oneadapter.helpers.BaseTest | ||
import com.idanatz.oneadapter.models.TestModel | ||
import com.idanatz.oneadapter.models.TestModel1 | ||
import com.idanatz.oneadapter.test.R | ||
import org.amshove.kluent.shouldBe | ||
import org.amshove.kluent.shouldContainSame | ||
import org.amshove.kluent.shouldEqualTo | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class WhenOnBindInvoked_ThenItemIsFirstMetadata_ShouldBeTrueOnFirstItem : BaseTest() { | ||
|
||
private var firstCondition = booleanArrayOf(false, false, false, false, false) | ||
|
||
@Test | ||
fun test() { | ||
configure { | ||
prepareOnActivity { | ||
oneAdapter.run { | ||
attachItemModule(TestItemModule()) | ||
setItems(modelGenerator.generateModels(5).toMutableList()) | ||
} | ||
} | ||
untilAsserted { | ||
firstCondition shouldContainSame booleanArrayOf(true, false, false, false, false) | ||
} | ||
} | ||
} | ||
|
||
inner class TestItemModule : ItemModule<TestModel>() { | ||
init { | ||
config = modulesGenerator.generateValidItemModuleConfig(R.layout.test_model_small) | ||
onBind { model, _, metadata -> | ||
firstCondition[metadata.position] = metadata.isFirst | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
.../modules/item/metadata/WhenOnBindInvoked_ThenItemIsLastMetadata_ShouldBeTrueOnLastItem.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,45 @@ | ||
@file:Suppress("ClassName") | ||
|
||
package com.idanatz.oneadapter.tests.modules.item.metadata | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.idanatz.oneadapter.external.modules.ItemModule | ||
import com.idanatz.oneadapter.helpers.BaseTest | ||
import com.idanatz.oneadapter.models.TestModel | ||
import com.idanatz.oneadapter.models.TestModel1 | ||
import com.idanatz.oneadapter.test.R | ||
import org.amshove.kluent.shouldBe | ||
import org.amshove.kluent.shouldContainSame | ||
import org.amshove.kluent.shouldEqualTo | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class WhenOnBindInvoked_ThenItemIsLastMetadata_ShouldBeTrueOnLastItem : BaseTest() { | ||
|
||
private var lastCondition = booleanArrayOf(false, false, false, false, false) | ||
|
||
@Test | ||
fun test() { | ||
configure { | ||
prepareOnActivity { | ||
oneAdapter.run { | ||
attachItemModule(TestItemModule()) | ||
setItems(modelGenerator.generateModels(5).toMutableList()) | ||
} | ||
} | ||
untilAsserted { | ||
lastCondition shouldContainSame booleanArrayOf(false, false, false, false, true) | ||
} | ||
} | ||
} | ||
|
||
inner class TestItemModule : ItemModule<TestModel>() { | ||
init { | ||
config = modulesGenerator.generateValidItemModuleConfig(R.layout.test_model_small) | ||
onBind { model, _, metadata -> | ||
lastCondition[metadata.position] = metadata.isLast | ||
} | ||
} | ||
} | ||
} |
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