@@ -0,0 +1,3006 @@
+/*%0A * Copyright 2018 New Vector Ltd%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.matrix.androidsdk.data.room;%0A%0Aimport android.content.Context;%0Aimport android.support.test.InstrumentationRegistry;%0A%0Aimport junit.framework.Assert;%0A%0Aimport org.junit.Test;%0Aimport org.matrix.androidsdk.MXDataHandler;%0Aimport org.matrix.androidsdk.data.Room;%0Aimport org.matrix.androidsdk.data.store.IMXStore;%0Aimport org.matrix.androidsdk.data.store.MXMemoryStore;%0Aimport org.matrix.androidsdk.rest.model.login.Credentials;%0A%0Aimport java.util.ArrayList;%0A%0Apublic class RoomNameTest %7B%0A%0A    @Test%0A    public void RoomName_getRoomDisplayName_emptyRoom() %7B%0A        Context context = InstrumentationRegistry.getContext();%0A        Room room = createRoom(context, false);%0A%0A        Assert.assertEquals(%22Empty room%22, room.getRoomDisplayName(context));%0A    %7D%0A%0A    @Test%0A    public void RoomName_getRoomDisplayName_noLL_roomName() %7B%0A        RoomName_getRoomDisplayName_roomName(false);%0A    %7D%0A%0A    @Test%0A    public void RoomName_getRoomDisplayName_LL_roomName() %7B%0A        RoomName_getRoomDisplayName_roomName(true);%0A    %7D%0A%0A    private void RoomName_getRoomDisplayName_roomName(boolean withLazyLoading) %7B%0A        Context context = InstrumentationRegistry.getContext();%0A        Room room = createRoom(context, withLazyLoading);%0A%0A        room.getState().aliases = new ArrayList%3C%3E();%0A        room.getState().aliases.add(%22Alias%22);%0A        Assert.assertEquals(%22Alias%22, room.getRoomDisplayName(context));%0A%0A        // Canonical alias get priority over alias%0A        room.getState().setCanonicalAlias(%22Canonical%22);%0A        Assert.assertEquals(%22Canonical%22, room.getRoomDisplayName(context));%0A%0A        // Room name get priority over alias and canonical alias%0A        room.getState().name = %22Room Name%22;%0A        Assert.assertEquals(%22Room Name%22, room.getRoomDisplayName(context));%0A    %7D%0A%0A    /* ==========================================================================================%0A     * Private%0A     * ========================================================================================== */%0A%0A    private Room createRoom(Context context, boolean withLazyLoading) %7B%0A        Credentials credentials = new Credentials();%0A        IMXStore store = new MXMemoryStore(credentials, context);%0A%0A        MXDataHandler mxDataHandler = new MXDataHandler(store, credentials);%0A        mxDataHandler.setLazyLoadingEnabled(withLazyLoading);%0A%0A        Room room = new Room(mxDataHandler, store, %22roomId%22);%0A%0A        return room;%0A    %7D%0A%7D%0A

Add RoomNameTest