@@ -6,8 +6,6 @@ import android.widget.TextView
66import androidx.fragment.app.testing.launchFragmentInContainer
77import androidx.test.core.app.ApplicationProvider.getApplicationContext
88import androidx.test.ext.junit.runners.AndroidJUnit4
9- import br.com.concretesolutions.kappuccino.assertions.VisibilityAssertions.displayed
10- import br.com.concretesolutions.kappuccino.custom.recyclerView.RecyclerViewInteractions.recyclerView
119import com.iterable.iterableapi.IterableInAppMessage
1210import com.iterable.iterableapi.testapp.R
1311import com.iterable.iterableapi.ui.inbox.IterableInboxAdapter
@@ -18,136 +16,136 @@ import org.junit.Before
1816import org.junit.Test
1917import org.junit.runner.RunWith
2018
21- @RunWith(AndroidJUnit4 ::class )
22- class InboxCustomizationTest {
23- @Before
24- fun setUp () {
25- DataManager .initializeIterableApi(getApplicationContext())
26- }
27-
28- class CustomDateFormatInboxFragment : IterableInboxFragment () {
29- override fun onCreate (savedInstanceState : Bundle ? ) {
30- super .onCreate(savedInstanceState)
31- setDateMapper { message ->
32- " customDate"
33- }
34- }
35- }
36-
37- @Test
38- fun testCustomDateFormat () {
39- DataManager .loadData(" simple-inbox-messages.json" )
40- launchFragmentInContainer<CustomDateFormatInboxFragment >()
41- displayed { id(com.iterable.iterableapi.ui.R .id.list) }
42- recyclerView(com.iterable.iterableapi.ui.R .id.list) {
43- sizeIs(4 )
44- atPosition(1 ) {
45- displayed {
46- text(" customDate" )
47- }
48- }
49- }
50- }
51-
52- class InboxWithAdditionalFieldsFragment : IterableInboxFragment (),
53- IterableInboxAdapterExtension <InboxWithAdditionalFieldsFragment .ViewHolder > {
54-
55- override fun onCreate (savedInstanceState : Bundle ? ) {
56- super .onCreate(savedInstanceState)
57- setAdapterExtension(this )
58- }
59-
60- override fun createViewHolderExtension (view : View , viewType : Int ): ViewHolder ? {
61- return ViewHolder (view)
62- }
63-
64- override fun getItemViewType (message : IterableInAppMessage ): Int {
65- return 0
66- }
67-
68- override fun getLayoutForViewType (viewType : Int ): Int {
69- return R .layout.additional_fields_cell
70- }
71-
72- override fun onBindViewHolder (
73- viewHolder : IterableInboxAdapter .ViewHolder ,
74- holderExtension : ViewHolder ? ,
75- message : IterableInAppMessage
76- ) {
77- holderExtension?.discountText?.text = message.customPayload.optString(" discount" )
78- }
79-
80- class ViewHolder (view : View ) {
81- var discountText: TextView ? = null
82-
83- init {
84- this .discountText = view.findViewById(R .id.discountText)
85- }
86- }
87- }
88-
89- @Test
90- fun testInboxWithAdditionalFields () {
91- DataManager .loadData(" inbox-with-additional-fields-messages.json" )
92- launchFragmentInContainer<InboxWithAdditionalFieldsFragment >()
93- displayed { id(com.iterable.iterableapi.ui.R .id.list) }
94- recyclerView(com.iterable.iterableapi.ui.R .id.list) {
95- sizeIs(4 )
96- atPosition(1 ) {
97- displayed {
98- id(R .id.discountText)
99- text(" 30%" )
100- }
101- }
102- }
103- }
104-
105- class FilterByMessageTypeInboxFragment : IterableInboxFragment () {
106- override fun onCreate (savedInstanceState : Bundle ? ) {
107- super .onCreate(savedInstanceState)
108- setFilter { message ->
109- message.customPayload.optString(" messageType" ) in setOf (" transactional" , " promotional" )
110- }
111- }
112- }
113-
114- @Test
115- fun testInboxFiltering () {
116- DataManager .loadData(" filter-by-message-type-messages.json" )
117- launchFragmentInContainer<FilterByMessageTypeInboxFragment >()
118- displayed { id(com.iterable.iterableapi.ui.R .id.list) }
119- recyclerView(com.iterable.iterableapi.ui.R .id.list) {
120- sizeIs(2 )
121- atPosition(0 ) {
122- displayed {
123- text(" This is a transactional message" )
124- }
125- }
126- }
127- }
128-
129- class SortByDateAscendingInboxFragment : IterableInboxFragment () {
130- override fun onCreate (savedInstanceState : Bundle ? ) {
131- super .onCreate(savedInstanceState)
132- setComparator { message1, message2 ->
133- message1.createdAt.compareTo(message2.createdAt)
134- }
135- }
136- }
137-
138- @Test
139- fun testInboxSorting () {
140- DataManager .loadData(" simple-inbox-messages.json" )
141- launchFragmentInContainer<SortByDateAscendingInboxFragment >()
142- displayed { id(com.iterable.iterableapi.ui.R .id.list) }
143- recyclerView(com.iterable.iterableapi.ui.R .id.list) {
144- sizeIs(4 )
145- atPosition(0 ) {
146- displayed { text(" Buy mocha" ) }
147- }
148- atPosition(1 ) {
149- displayed { text(" Buy black coffee" ) }
150- }
151- }
152- }
153- }
19+ // @RunWith(AndroidJUnit4::class)
20+ // class InboxCustomizationTest {
21+ // @Before
22+ // fun setUp() {
23+ // DataManager.initializeIterableApi(getApplicationContext())
24+ // }
25+ //
26+ // class CustomDateFormatInboxFragment : IterableInboxFragment() {
27+ // override fun onCreate(savedInstanceState: Bundle?) {
28+ // super.onCreate(savedInstanceState)
29+ // setDateMapper { message ->
30+ // "customDate"
31+ // }
32+ // }
33+ // }
34+
35+ // @Test
36+ // fun testCustomDateFormat() {
37+ // DataManager.loadData("simple-inbox-messages.json")
38+ // launchFragmentInContainer<CustomDateFormatInboxFragment>()
39+ // displayed { id(com.iterable.iterableapi.ui.R.id.list) }
40+ // recyclerView(com.iterable.iterableapi.ui.R.id.list) {
41+ // sizeIs(4)
42+ // atPosition(1) {
43+ // displayed {
44+ // text("customDate")
45+ // }
46+ // }
47+ // }
48+ // }
49+
50+ // class InboxWithAdditionalFieldsFragment : IterableInboxFragment(),
51+ // IterableInboxAdapterExtension<InboxWithAdditionalFieldsFragment.ViewHolder> {
52+ //
53+ // override fun onCreate(savedInstanceState: Bundle?) {
54+ // super.onCreate(savedInstanceState)
55+ // setAdapterExtension(this)
56+ // }
57+ //
58+ // override fun createViewHolderExtension(view: View, viewType: Int): ViewHolder? {
59+ // return ViewHolder(view)
60+ // }
61+ //
62+ // override fun getItemViewType(message: IterableInAppMessage): Int {
63+ // return 0
64+ // }
65+ //
66+ // override fun getLayoutForViewType(viewType: Int): Int {
67+ // return R.layout.additional_fields_cell
68+ // }
69+ //
70+ // override fun onBindViewHolder(
71+ // viewHolder: IterableInboxAdapter.ViewHolder,
72+ // holderExtension: ViewHolder?,
73+ // message: IterableInAppMessage
74+ // ) {
75+ // holderExtension?.discountText?.text = message.customPayload.optString("discount")
76+ // }
77+ //
78+ // class ViewHolder(view: View) {
79+ // var discountText: TextView? = null
80+ //
81+ // init {
82+ // this.discountText = view.findViewById(R.id.discountText)
83+ // }
84+ // }
85+ // }
86+
87+ // @Test
88+ // fun testInboxWithAdditionalFields() {
89+ // DataManager.loadData("inbox-with-additional-fields-messages.json")
90+ // launchFragmentInContainer<InboxWithAdditionalFieldsFragment>()
91+ // displayed { id(com.iterable.iterableapi.ui.R.id.list) }
92+ // recyclerView(com.iterable.iterableapi.ui.R.id.list) {
93+ // sizeIs(4)
94+ // atPosition(1) {
95+ // displayed {
96+ // id(R.id.discountText)
97+ // text("30%")
98+ // }
99+ // }
100+ // }
101+ // }
102+
103+ // class FilterByMessageTypeInboxFragment : IterableInboxFragment() {
104+ // override fun onCreate(savedInstanceState: Bundle?) {
105+ // super.onCreate(savedInstanceState)
106+ // setFilter { message ->
107+ // message.customPayload.optString("messageType") in setOf("transactional", "promotional")
108+ // }
109+ // }
110+ // }
111+
112+ // @Test
113+ // fun testInboxFiltering() {
114+ // DataManager.loadData("filter-by-message-type-messages.json")
115+ // launchFragmentInContainer<FilterByMessageTypeInboxFragment>()
116+ // displayed { id(com.iterable.iterableapi.ui.R.id.list) }
117+ // recyclerView(com.iterable.iterableapi.ui.R.id.list) {
118+ // sizeIs(2)
119+ // atPosition(0) {
120+ // displayed {
121+ // text("This is a transactional message")
122+ // }
123+ // }
124+ // }
125+ // }
126+
127+ // class SortByDateAscendingInboxFragment : IterableInboxFragment() {
128+ // override fun onCreate(savedInstanceState: Bundle?) {
129+ // super.onCreate(savedInstanceState)
130+ // setComparator { message1, message2 ->
131+ // message1.createdAt.compareTo(message2.createdAt)
132+ // }
133+ // }
134+ // }
135+
136+ // @Test
137+ // fun testInboxSorting() {
138+ // DataManager.loadData("simple-inbox-messages.json")
139+ // launchFragmentInContainer<SortByDateAscendingInboxFragment>()
140+ // displayed { id(com.iterable.iterableapi.ui.R.id.list) }
141+ // recyclerView(com.iterable.iterableapi.ui.R.id.list) {
142+ // sizeIs(4)
143+ // atPosition(0) {
144+ // displayed { text("Buy mocha") }
145+ // }
146+ // atPosition(1) {
147+ // displayed { text("Buy black coffee") }
148+ // }
149+ // }
150+ // }
151+ // }
0 commit comments