Skip to content

Commit bb86660

Browse files
committed
Fix test compilation issue.
1 parent 7e2b01b commit bb86660

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

vector-app/src/androidTest/java/im/vector/app/core/utils/TestMatrixHelper.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
package im.vector.app.core.utils
1818

1919
import androidx.test.platform.app.InstrumentationRegistry
20-
import im.vector.app.features.room.VectorRoomDisplayNameFallbackProvider
2120
import org.matrix.android.sdk.api.Matrix
2221
import org.matrix.android.sdk.api.MatrixConfiguration
2322
import org.matrix.android.sdk.api.SyncConfig
2423

2524
fun getMatrixInstance(): Matrix {
2625
val context = InstrumentationRegistry.getInstrumentation().targetContext
2726
val configuration = MatrixConfiguration(
28-
roomDisplayNameFallbackProvider = VectorRoomDisplayNameFallbackProvider(context),
27+
roomDisplayNameFallbackProvider = TestRoomDisplayNameFallbackProvider(),
2928
syncConfig = SyncConfig(longPollTimeout = 5_000L),
3029
)
3130
return Matrix(context, configuration)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package im.vector.app.core.utils
18+
19+
import org.matrix.android.sdk.api.provider.RoomDisplayNameFallbackProvider
20+
21+
class TestRoomDisplayNameFallbackProvider : RoomDisplayNameFallbackProvider {
22+
23+
override fun excludedUserIds(roomId: String) = emptyList<String>()
24+
25+
override fun getNameForRoomInvite() =
26+
"Room invite"
27+
28+
override fun getNameForEmptyRoom(isDirect: Boolean, leftMemberNames: List<String>) =
29+
"Empty room"
30+
31+
override fun getNameFor1member(name: String) =
32+
name
33+
34+
override fun getNameFor2members(name1: String, name2: String) =
35+
"$name1 and $name2"
36+
37+
override fun getNameFor3members(name1: String, name2: String, name3: String) =
38+
"$name1, $name2 and $name3"
39+
40+
override fun getNameFor4members(name1: String, name2: String, name3: String, name4: String) =
41+
"$name1, $name2, $name3 and $name4"
42+
43+
override fun getNameFor4membersAndMore(name1: String, name2: String, name3: String, remainingCount: Int) =
44+
"$name1, $name2, $name3 and $remainingCount others"
45+
}

0 commit comments

Comments
 (0)