Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/0.9.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Oct 18, 2018
2 parents 0236850 + 63e093d commit b558c49
Show file tree
Hide file tree
Showing 95 changed files with 2,041 additions and 395 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ script:
- ./gradlew clean lintRelease test assembleRelease assembleAndroidTest --stacktrace
- ./tools/check/check_code_quality.sh
- ./tools/travis/check_pr.sh
# Check that indonesian files are identical. Due to Android issue, the resource folder must be value-in/, and Weblate export data into value-id/.
- diff ./matrix-sdk/src/main/res/values-id/strings.xml ./matrix-sdk/src/main/res/values-in/strings.xml
12 changes: 12 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Changes to Matrix Android SDK in 0.9.12 (2018-10-18)
=======================================================

Improvements:
- Improve certificate pinning management for HomeServerConnectionConfig.
- Room display name is now computed by the Matrix SDK

Bugfix:
- Fix strip previous reply when they contain new line (vector-im/riot-android#2612)
- Enable CLEARTEXT communication for http endpoints (vector-im/riot-android#2495)
- Back paginating in a room with LL makes some avatars to vanish (vector-im/riot-android#2639)

Changes to Matrix Android SDK in 0.9.11 (2018-10-10)
=======================================================

Expand Down
4 changes: 2 additions & 2 deletions matrix-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 911
versionName "0.9.11"
versionCode 912
versionName "0.9.12"
resValue "string", "flavor_description", "SDKApp"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public HomeServerConnectionConfig createHomeServerConfig(@Nullable Credentials c
final HomeServerConnectionConfig hs = new HomeServerConnectionConfig.Builder()
.withHomeServerUri(Uri.parse(TestConstants.TESTS_HOME_SERVER_URL))
.withCredentials(credentials)
.withAllowHttpConnection()
.build();
return hs;
}
Expand Down Expand Up @@ -355,4 +354,17 @@ public void onSuccess(Credentials credentials) {
public void await(CountDownLatch latch) throws InterruptedException {
Assert.assertTrue(latch.await(TestConstants.AWAIT_TIME_OUT_MILLIS, TimeUnit.MILLISECONDS));
}

/**
* Clear all provided sessions
*
* @param sessions the sessions to clear
*/
public void clearAllSessions(List<MXSession> sessions) {
final Context context = InstrumentationRegistry.getContext();

for (MXSession session : sessions) {
session.clear(context);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.matrix.androidsdk.data.room;

import android.content.Context;
import android.support.test.InstrumentationRegistry;

import junit.framework.Assert;

import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.matrix.androidsdk.data.Room;

@FixMethodOrder(MethodSorters.JVM)
public class RoomAvatarResolverTest {

private RoomTestHelper mRoomTestHelper = new RoomTestHelper();

@Test
public void RoomAvatar_getAvatar_noLL_avatar() {
RoomAvatar_getAvatar_avatar(false);
}

@Test
public void RoomAvatar_getAvatar_LL_avatar() {
RoomAvatar_getAvatar_avatar(true);
}

private void RoomAvatar_getAvatar_avatar(boolean withLazyLoading) {
Context context = InstrumentationRegistry.getContext();

// It does not depend on the number of users
for (int i = 0; i < 10; i++) {
Room room = mRoomTestHelper.createRoom(context, withLazyLoading, i, false);

room.getState().avatar_url = "mxc://avatar_url";
Assert.assertEquals("mxc://avatar_url", room.getAvatarUrl());
}
}

@Test
public void RoomAvatar_getAvatar_noLL_noAvatar() {
RoomAvatar_getAvatar_noAvatar(false);
}

@Test
public void RoomAvatar_getAvatar_LL_noAvatar() {
RoomAvatar_getAvatar_noAvatar(true);
}

private void RoomAvatar_getAvatar_noAvatar(boolean withLazyLoading) {
Context context = InstrumentationRegistry.getContext();

Room room;

// Only me in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 1, false);
Assert.assertNull(room.getAvatarUrl());

// I have an avatar
room.getMember(mRoomTestHelper.getMyUserId()).avatarUrl = "mxc://my_avatar_url";
Assert.assertEquals("mxc://my_avatar_url", room.getAvatarUrl());

// One other user in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 2, false);
Assert.assertNull(room.getAvatarUrl());

// I have an avatar
room.getMember(mRoomTestHelper.getMyUserId()).avatarUrl = "mxc://my_avatar_url";
Assert.assertNull(room.getAvatarUrl());

// Other user has an avatar
room.getMember(mRoomTestHelper.getUserId(2)).avatarUrl = "mxc://other_user_avatar_url";
Assert.assertEquals("mxc://other_user_avatar_url", room.getAvatarUrl());

// 2 other users in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 3, false);

// I have an avatar
room.getMember(mRoomTestHelper.getMyUserId()).avatarUrl = "mxc://my_avatar_url";
// Other user has an avatar
room.getMember(mRoomTestHelper.getUserId(2)).avatarUrl = "mxc://other_user_avatar_url";

Assert.assertNull(room.getAvatarUrl());
}

@Test
public void RoomAvatar_getAvatar_noLL_invitation() {
RoomAvatar_getAvatar_invitation(false);
}

@Test
public void RoomAvatar_getAvatar_LL_invitation() {
RoomAvatar_getAvatar_invitation(true);
}

private void RoomAvatar_getAvatar_invitation(boolean withLazyLoading) {
Context context = InstrumentationRegistry.getContext();

Room room;

// Only me in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 1, true);
Assert.assertNull(room.getAvatarUrl());

// I have an avatar
room.getMember(mRoomTestHelper.getMyUserId()).avatarUrl = "mxc://my_avatar_url";
Assert.assertEquals("mxc://my_avatar_url", room.getAvatarUrl());

// One other user in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 2, true);
Assert.assertNull(room.getAvatarUrl());

// I have an avatar
room.getMember(mRoomTestHelper.getMyUserId()).avatarUrl = "mxc://my_avatar_url";
Assert.assertNull(room.getAvatarUrl());

// Inviter has an avatar
room.getMember(mRoomTestHelper.getUserId(2)).avatarUrl = "mxc://other_user_avatar_url";
Assert.assertEquals("mxc://other_user_avatar_url", room.getAvatarUrl());

// 2 other users in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 3, true);

// I have an avatar
room.getMember(mRoomTestHelper.getMyUserId()).avatarUrl = "mxc://my_avatar_url";
// Other user has an avatar
room.getMember(mRoomTestHelper.getUserId(2)).avatarUrl = "mxc://other_user_avatar_url";

Assert.assertEquals("mxc://other_user_avatar_url", room.getAvatarUrl());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
* Copyright 2018 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.matrix.androidsdk.data.room;

import android.content.Context;
import android.support.test.InstrumentationRegistry;

import junit.framework.Assert;

import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.matrix.androidsdk.data.Room;

import java.util.ArrayList;

@FixMethodOrder(MethodSorters.JVM)
public class RoomDisplayNameResolverTest {

private RoomTestHelper mRoomTestHelper = new RoomTestHelper();

@Test
public void RoomName_getRoomDisplayName_noLL_emptyRoom() {
RoomName_getRoomDisplayName_emptyRoom(false);
}

@Test
public void RoomName_getRoomDisplayName_LL_emptyRoom() {
RoomName_getRoomDisplayName_emptyRoom(true);
}

private void RoomName_getRoomDisplayName_emptyRoom(boolean withLazyLoading) {
Context context = InstrumentationRegistry.getContext();
Room room = mRoomTestHelper.createRoom(context, withLazyLoading, 0, false);

Assert.assertEquals("Empty room", room.getRoomDisplayName(context));
}

@Test
public void RoomName_getRoomDisplayName_noLL_roomName() {
RoomName_getRoomDisplayName_roomName(false);
}

@Test
public void RoomName_getRoomDisplayName_LL_roomName() {
RoomName_getRoomDisplayName_roomName(true);
}

private void RoomName_getRoomDisplayName_roomName(boolean withLazyLoading) {
Context context = InstrumentationRegistry.getContext();

// It does not depend on the number of users
for (int i = 0; i < 10; i++) {
Room room = mRoomTestHelper.createRoom(context, withLazyLoading, i, false);

room.getState().aliases = new ArrayList<>();
room.getState().aliases.add("Alias");
Assert.assertEquals("Alias", room.getRoomDisplayName(context));

// Canonical alias get priority over alias
room.getState().setCanonicalAlias("Canonical");
Assert.assertEquals("Canonical", room.getRoomDisplayName(context));

// Room name get priority over alias and canonical alias
room.getState().name = "Room Name";
Assert.assertEquals("Room Name", room.getRoomDisplayName(context));
}
}

@Test
public void RoomName_getRoomDisplayName_noLL_user() {
RoomName_getRoomDisplayName_user(false);
}

@Test
public void RoomName_getRoomDisplayName_LL_user() {
RoomName_getRoomDisplayName_user(true);
}

private void RoomName_getRoomDisplayName_user(boolean withLazyLoading) {
Context context = InstrumentationRegistry.getContext();

Room room;

// Only me in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 1, false);
Assert.assertEquals("Empty room", room.getRoomDisplayName(context));

// One other user in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 2, false);
Assert.assertEquals("UserName_2", room.getRoomDisplayName(context));

// 2 other users in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 3, false);
Assert.assertEquals("UserName_2 and UserName_3", room.getRoomDisplayName(context));

room = mRoomTestHelper.createRoom(context, withLazyLoading, 4, false);
Assert.assertEquals("UserName_2 and 3 others", room.getRoomDisplayName(context));

room = mRoomTestHelper.createRoom(context, withLazyLoading, 5, false);
Assert.assertEquals("UserName_2 and 4 others", room.getRoomDisplayName(context));

room = mRoomTestHelper.createRoom(context, withLazyLoading, 10, false);
Assert.assertEquals("UserName_2 and 9 others", room.getRoomDisplayName(context));
}

@Test
public void RoomName_getRoomDisplayName_noLL_invitation() {
RoomName_getRoomDisplayName_invitation(false);
}

@Test
public void RoomName_getRoomDisplayName_LL_invitation() {
RoomName_getRoomDisplayName_invitation(true);
}

private void RoomName_getRoomDisplayName_invitation(boolean withLazyLoading) {
Context context = InstrumentationRegistry.getContext();

Room room;

// Only me in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 1, true);
Assert.assertEquals("Room Invite", room.getRoomDisplayName(context));

// One other user in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 2, true);
Assert.assertEquals("Invite from UserName_2", room.getRoomDisplayName(context));

// 2 other users in the room
room = mRoomTestHelper.createRoom(context, withLazyLoading, 3, true);
Assert.assertEquals("Invite from UserName_2", room.getRoomDisplayName(context));

room = mRoomTestHelper.createRoom(context, withLazyLoading, 4, true);
Assert.assertEquals("Invite from UserName_2", room.getRoomDisplayName(context));

room = mRoomTestHelper.createRoom(context, withLazyLoading, 5, true);
Assert.assertEquals("Invite from UserName_2", room.getRoomDisplayName(context));

room = mRoomTestHelper.createRoom(context, withLazyLoading, 10, true);
Assert.assertEquals("Invite from UserName_2", room.getRoomDisplayName(context));
}
}
Loading

0 comments on commit b558c49

Please sign in to comment.