agoda-com / Kakao

This repo is no longer supported. Please visit a https://github.com/KakaoCup/Kakao
Apache License 2.0
1.11k stars 102 forks source link

KRecyclerView multiple childs assert not success #110

Closed alorma closed 5 years ago

alorma commented 6 years ago

Steps to reproduce:

  1. Build Screen with recycler view
  2. On your code, set more than one item at recyclerview adapter
  3. Try to do assert with more than one children

Observed Results:

https://gist.github.com/alorma/4b2cf664f6f92c6ba4f9abc8416c335e

+---------->AppCompatTextView{id=2131361887, res-name=addressView, visibility=VISIBLE, width=954, height=126, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.support.constraint.ConstraintLayout$LayoutParams@fff2b2b, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, text=Calle Llull nº 113 - 119, 08025 Barcelona, input-type=0, ime-target=false, has-links=false} ****MATCHES****

As you can see, the item shows a ****MATCHES****

Expected Results:

Two assertions success, as you can see, the second assert ("Calle Llull nº 113 - 119, 08025 Barcelona") is on the output of the view hierarchy

Relevant Code:

        screen {
            address {
                firstChild<AddressItem> {
                    name { hasText("Calle falsa nº 123, 08112 Springfield") }
                }
                lastChild<AddressItem> {
                    name { hasText("Calle Llull nº 113 - 119, 08025 Barcelona") }
                }
            }
        }
Unlimity commented 6 years ago

That is truly unexpected behavior. Can you share with us the version of Kakao you're using?

alorma commented 6 years ago

kakaoVersion = "1.4.0"

Unlimity commented 6 years ago

Thanks! I will investigate issue in when I will have free time. But for starters it seems that lastChild extension function's matcher is not matching correctly. You can try replacing this call with childAt<AddressItem>(size() - 1) { to see if there is any difference. Cheers!

Unlimity commented 6 years ago

Hi there! I'm very sorry that I didn't have any time lately to look into your issue. Have you managed to resolve it yourself by any chance?

ghost commented 5 years ago

Hi, I'm getting the same @alorma 's error.

I'm using kakao version 1.4.0

Output: https://gist.github.com/dsceinos/ec1302d49b447429898b8b497317d8eb

Code:

screen {
            recycler {
                hasSize(2)
                childAt<Screen.Item>(0) {
                  titleTextView { containsText(item1.description) }
                }
                childAt<Screen.Item>(1) {
                   titleTextView { containsText(item2.description) }
                }
            }
        }
Unlimity commented 5 years ago

Can you please provide your screen class source?

Unlimity commented 5 years ago

I saw your exception, and the matcher does not matching recycler view as your item's parent. My guess here is that you haven't declared your item class correctly.

ghost commented 5 years ago

I've recheck item declaration and I found that I forgot to add item's view constructor with parent parameter. Thanks!

Unlimity commented 5 years ago

Nice. I suppose @alorma had same problem, so I'm closing this issue.