Search in sources :

Example 1 with MockContext

use of org.terasology.context.internal.MockContext in project Terasology by MovingBlocks.

the class TreeTests method setup.

@Before
public void setup() {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    // Needed only as long as #1536 is unresolved
    context.put(Config.class, new Config(new MockContext()));
    blockManager = Mockito.mock(BlockManager.class);
    Block air = blockManager.getBlock(BlockManager.AIR_ID);
    biomeManager = Mockito.mock(BiomeManager.class);
    Mockito.when(blockManager.getBlock(Matchers.<BlockUri>any())).thenReturn(air);
    Mockito.when(blockManager.getBlock(Matchers.<String>any())).thenReturn(air);
    context.put(BlockManager.class, blockManager);
}
Also used : BiomeManager(org.terasology.world.biomes.BiomeManager) MockContext(org.terasology.context.internal.MockContext) Config(org.terasology.config.Config) BlockManager(org.terasology.world.block.BlockManager) Block(org.terasology.world.block.Block) ContextImpl(org.terasology.context.internal.ContextImpl) Before(org.junit.Before)

Example 2 with MockContext

use of org.terasology.context.internal.MockContext in project Terasology by MovingBlocks.

the class InputConfig method reset.

public void reset() {
    Config defaultConfig = new Config(new MockContext());
    defaultConfig.loadDefaults();
    InputConfig defaultInputConfig = defaultConfig.getInput();
    setMouseSensitivity(defaultInputConfig.mouseSensitivity);
    setMouseYAxisInverted(defaultInputConfig.mouseYAxisInverted);
}
Also used : MockContext(org.terasology.context.internal.MockContext)

Example 3 with MockContext

use of org.terasology.context.internal.MockContext in project Terasology by MovingBlocks.

the class ChunkMathTest method testRegionPositions.

@Test
public void testRegionPositions() {
    CoreRegistry.setContext(new ContextImpl());
    CoreRegistry.put(Config.class, new Config(new MockContext()));
    assertEquals(1, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(0, 0, 0))).length);
    assertEquals(1, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(31, 63, 31))).length);
    assertEquals(2, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(32, 63, 31))).length);
    assertEquals(4, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(32, 63, 32))).length);
    assertEquals(8, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(32, 64, 32))).length);
    assertEquals(12, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(-1, 0, 0), new Vector3i(32, 64, 32))).length);
    Vector3i[] chunks = ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(32, 63, 31)));
    assertEquals(new Vector3i(0, 0, 0), chunks[0]);
    assertEquals(new Vector3i(1, 0, 0), chunks[1]);
}
Also used : MockContext(org.terasology.context.internal.MockContext) Config(org.terasology.config.Config) Vector3i(org.terasology.math.geom.Vector3i) ContextImpl(org.terasology.context.internal.ContextImpl) Test(org.junit.Test)

Example 4 with MockContext

use of org.terasology.context.internal.MockContext in project Terasology by MovingBlocks.

the class IntMathTest method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    Config config = new Config(new MockContext());
    CoreRegistry.setContext(new ContextImpl());
    CoreRegistry.put(Config.class, config);
}
Also used : MockContext(org.terasology.context.internal.MockContext) Config(org.terasology.config.Config) ContextImpl(org.terasology.context.internal.ContextImpl) BeforeClass(org.junit.BeforeClass)

Aggregations

MockContext (org.terasology.context.internal.MockContext)4 Config (org.terasology.config.Config)3 ContextImpl (org.terasology.context.internal.ContextImpl)3 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1 Vector3i (org.terasology.math.geom.Vector3i)1 BiomeManager (org.terasology.world.biomes.BiomeManager)1 Block (org.terasology.world.block.Block)1 BlockManager (org.terasology.world.block.BlockManager)1