Split up AvatarManagerImplTests

This commit is contained in:
Torsten Grote
2020-11-23 14:35:38 -03:00
parent ec972e8a1d
commit 8b45e01c42
2 changed files with 29 additions and 21 deletions

View File

@@ -34,11 +34,11 @@ public class AvatarModule {
AvatarValidator provideAvatarValidator(ValidationManager validationManager, AvatarValidator provideAvatarValidator(ValidationManager validationManager,
BdfReaderFactory bdfReaderFactory, MetadataEncoder metadataEncoder, BdfReaderFactory bdfReaderFactory, MetadataEncoder metadataEncoder,
Clock clock) { Clock clock) {
AvatarValidator introductionValidator = AvatarValidator avatarValidator =
new AvatarValidator(bdfReaderFactory, metadataEncoder, clock); new AvatarValidator(bdfReaderFactory, metadataEncoder, clock);
validationManager.registerMessageValidator(CLIENT_ID, MAJOR_VERSION, validationManager.registerMessageValidator(CLIENT_ID, MAJOR_VERSION,
introductionValidator); avatarValidator);
return introductionValidator; return avatarValidator;
} }
@Provides @Provides

View File

@@ -96,7 +96,8 @@ public class AvatarManagerImplTest extends BrambleMockTestCase {
clock); clock);
@Test @Test
public void testOpenDatabaseHook() throws DbException, FormatException { public void testOpenDatabaseHookWhenGroupExists()
throws DbException, FormatException {
Transaction txn = new Transaction(null, false); Transaction txn = new Transaction(null, false);
// local group already exists, so nothing more to do // local group already exists, so nothing more to do
@@ -108,6 +109,11 @@ public class AvatarManagerImplTest extends BrambleMockTestCase {
will(returnValue(true)); will(returnValue(true));
}}); }});
avatarManager.onDatabaseOpened(txn); avatarManager.onDatabaseOpened(txn);
}
@Test
public void testOpenDatabaseHook() throws DbException, FormatException {
Transaction txn = new Transaction(null, false);
// local group does not exist, so we need to set things up for contacts // local group does not exist, so we need to set things up for contacts
expectCreateGroup(localAuthor.getId(), localGroup); expectCreateGroup(localAuthor.getId(), localGroup);
@@ -149,27 +155,29 @@ public class AvatarManagerImplTest extends BrambleMockTestCase {
} }
@Test @Test
public void testOnClientVisibilityChanging() throws DbException { public void testOnClientVisibilityChangingVisible() throws DbException {
testOnClientVisibilityChanging(VISIBLE);
}
@Test
public void testOnClientVisibilityChangingShared() throws DbException {
testOnClientVisibilityChanging(SHARED);
}
@Test
public void testOnClientVisibilityChangingInvisible() throws DbException {
testOnClientVisibilityChanging(INVISIBLE);
}
private void testOnClientVisibilityChanging(Visibility v)
throws DbException {
Transaction txn = new Transaction(null, false); Transaction txn = new Transaction(null, false);
expectGetOurGroup(txn); expectGetOurGroup(txn);
expectCreateGroup(contact.getAuthor().getId(), contactGroup); expectCreateGroup(contact.getAuthor().getId(), contactGroup);
expectSetGroupVisibility(txn, contact.getId(), localGroupId, VISIBLE); expectSetGroupVisibility(txn, contact.getId(), localGroupId, v);
expectSetGroupVisibility(txn, contact.getId(), contactGroupId, VISIBLE); expectSetGroupVisibility(txn, contact.getId(), contactGroupId, v);
avatarManager.onClientVisibilityChanging(txn, contact, VISIBLE); avatarManager.onClientVisibilityChanging(txn, contact, v);
expectGetOurGroup(txn);
expectCreateGroup(contact.getAuthor().getId(), contactGroup);
expectSetGroupVisibility(txn, contact.getId(), localGroupId, SHARED);
expectSetGroupVisibility(txn, contact.getId(), contactGroupId, SHARED);
avatarManager.onClientVisibilityChanging(txn, contact, SHARED);
expectGetOurGroup(txn);
expectCreateGroup(contact.getAuthor().getId(), contactGroup);
expectSetGroupVisibility(txn, contact.getId(), localGroupId, INVISIBLE);
expectSetGroupVisibility(txn, contact.getId(), contactGroupId,
INVISIBLE);
avatarManager.onClientVisibilityChanging(txn, contact, INVISIBLE);
} }
@Test @Test