mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 07:09:56 +01:00
Split up AvatarManagerImplTests
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user