Skip to content

Commit bd9c269

Browse files
committed
Apply convention to UserShowPostsView
1 parent b1d212b commit bd9c269

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

app/src/androidTest/kotlin/com/hana053/micropost/pages/main/MainActivityTest.kt

+6-6
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class MainActivityTest : InjectableTest by InjectableTestImpl() {
7171
activityRule.launchActivity(null)
7272

7373
onView(withId(R.id.list_post))
74-
.check(matches(atPositionOnView(0, withText("my test content"), R.id.content)))
74+
.check(matches(atPositionOnView(0, withText("my test content"), R.id.tv_post_content)))
7575
}
7676

7777
@Test
@@ -94,9 +94,9 @@ class MainActivityTest : InjectableTest by InjectableTestImpl() {
9494
onView(withId(R.id.swipe_refresh)).perform(swipeDown())
9595

9696
onView(withId(R.id.list_post))
97-
.check(matches(atPositionOnView(0, withText("my new content"), R.id.content)))
97+
.check(matches(atPositionOnView(0, withText("my new content"), R.id.tv_post_content)))
9898
onView(withId(R.id.list_post))
99-
.check(matches(atPositionOnView(1, withText("my test content"), R.id.content)))
99+
.check(matches(atPositionOnView(1, withText("my test content"), R.id.tv_post_content)))
100100
}
101101

102102
@Test
@@ -118,9 +118,9 @@ class MainActivityTest : InjectableTest by InjectableTestImpl() {
118118
activityRule.launchActivity(null)
119119

120120
onView(withId(R.id.list_post))
121-
.check(matches(atPositionOnView(0, withText("my test content"), R.id.content)))
121+
.check(matches(atPositionOnView(0, withText("my test content"), R.id.tv_post_content)))
122122
onView(withId(R.id.list_post))
123-
.check(matches(atPositionOnView(1, withText("my old content"), R.id.content)))
123+
.check(matches(atPositionOnView(1, withText("my old content"), R.id.tv_post_content)))
124124
}
125125

126126
@Test
@@ -139,7 +139,7 @@ class MainActivityTest : InjectableTest by InjectableTestImpl() {
139139
}
140140

141141
activityRule.launchActivity(null)
142-
onView(withId(R.id.avatar)).perform(click())
142+
onView(withId(R.id.img_avatar)).perform(click())
143143

144144
verify(navigator).navigateToUserShow(1)
145145
}

app/src/androidTest/kotlin/com/hana053/micropost/pages/usershow/UserShowActivityTest.kt

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import android.content.Intent
44
import android.support.test.espresso.Espresso.onView
55
import android.support.test.espresso.action.ViewActions.click
66
import android.support.test.espresso.assertion.ViewAssertions.matches
7-
import android.support.test.espresso.matcher.ViewMatchers.*
7+
import android.support.test.espresso.matcher.ViewMatchers.withId
8+
import android.support.test.espresso.matcher.ViewMatchers.withText
89
import android.support.test.filters.LargeTest
910
import android.support.test.rule.ActivityTestRule
1011
import android.support.test.runner.AndroidJUnit4
@@ -147,8 +148,8 @@ class UserShowActivityTest : InjectableTest by InjectableTestImpl() {
147148

148149
launchActivityWithUserId(1)
149150

150-
onView(withId(R.id.postRecyclerView))
151-
.check(matches(atPositionOnView(0, withText("my test content"), R.id.content)))
151+
onView(withId(R.id.list_post))
152+
.check(matches(atPositionOnView(0, withText("my test content"), R.id.tv_post_content)))
152153
}
153154

154155
private fun launchActivityWithUserId(userId: Long) {

app/src/main/kotlin/com/hana053/micropost/pages/usershow/posts/UserShowPostsView.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class UserShowPostsView(
1212
postListAdapter: PostListAdapter
1313
) : ViewWrapper {
1414

15-
private val postRecyclerView = content.postRecyclerView
15+
private val listPost = content.list_post
1616

1717
init {
18-
with(postRecyclerView) {
18+
with(listPost) {
1919
layoutManager = LinearLayoutManager(context())
2020
adapter = postListAdapter
2121
isNestedScrollingEnabled = false

app/src/main/kotlin/com/hana053/micropost/shared/posts/PostListAdapter.kt

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class PostListAdapter(
2424

2525
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
2626
val container: LinearLayout = view.container
27-
val avatar: ImageView = view.avatar
28-
val userName: TextView = view.userName
29-
val createdAt: RelativeTimeTextView = view.createdAt
30-
val content: TextView = view.content
27+
val avatar: ImageView = view.img_avatar
28+
val userName: TextView = view.tv_post_user_name
29+
val createdAt: RelativeTimeTextView = view.tv_post_created_at
30+
val content: TextView = view.tv_post_content
3131
}
3232

3333
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
@@ -48,7 +48,6 @@ class PostListAdapter(
4848
avatarClicksSubject.onNext(item.user)
4949
}
5050
}
51-
5251
}
5352

5453
override fun getItemCount(): Int = posts.size

app/src/main/res/layout/_user_posts.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
android:elevation="2dp">
99

1010
<android.support.v7.widget.RecyclerView
11-
android:id="@+id/postRecyclerView"
11+
android:id="@+id/list_post"
1212
android:layout_width="match_parent"
1313
android:layout_height="wrap_content"
1414
android:clipToPadding="false"

app/src/main/res/layout/item_posts.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
android:paddingTop="@dimen/margin_small">
1414

1515
<ImageView
16-
android:id="@+id/avatar"
16+
android:id="@+id/img_avatar"
1717
android:layout_width="@dimen/avatar_size_medium"
1818
android:layout_height="@dimen/avatar_size_medium"
1919
android:layout_marginEnd="@dimen/activity_horizontal_margin"
@@ -25,22 +25,22 @@
2525
android:layout_height="wrap_content">
2626

2727
<TextView
28-
android:id="@+id/userName"
28+
android:id="@+id/tv_post_user_name"
2929
android:layout_width="match_parent"
3030
android:layout_height="wrap_content"
3131
android:textStyle="bold"/>
3232

3333
<com.github.curioustechizen.ago.RelativeTimeTextView
34-
android:id="@+id/createdAt"
34+
android:id="@+id/tv_post_created_at"
3535
android:layout_width="wrap_content"
3636
android:layout_height="wrap_content"
3737
android:layout_alignParentEnd="true"
3838
tools:ignore="RelativeOverlap"/>
3939

4040
<TextView
41-
android:id="@+id/content"
41+
android:id="@+id/tv_post_content"
4242
android:layout_width="wrap_content"
4343
android:layout_height="wrap_content"
44-
android:layout_below="@id/userName"/>
44+
android:layout_below="@id/tv_post_user_name"/>
4545
</RelativeLayout>
4646
</LinearLayout>

0 commit comments

Comments
 (0)