Viewport { public void setWidthPixels(double newWidth) { setWidthTiles((int) Math.ceil(newWidth / TileRegister.TILE_SIZE)); } Viewport(double width, double height, World world); boolean isOnScreen(Drawable item); int getX(); int getY(); Point getPosition(); void setPosition(int newX, int newY); void move(int offsetX, int offsetY); int getWidthTiles(); int getMaxWidthTiles(); int getWidthPixels(); int getHeightTiles(); int getMaxHeightTiles(); int getHeightPixels(); void setWidthTiles(int newWidth); void setMaxWidthTiles(int newMaxWidth); void setHeightTiles(int newHeight); void setMaxHeightTiles(int newMaxHeight); void setSizeTiles(int width, int height); void setWidthPixels(double newWidth); void setHeightPixels(double newHeight); void setMaxWidthPixels(double newMaxWidth); void setMaxHeightPixels(double newMaxHeight);  }
@Test public void testSetWidthPixels() { Viewport viewport = new Viewport( 10 * TileRegister.TILE_SIZE, 10 * TileRegister.TILE_SIZE, world ); viewport.setWidthPixels(20 * TileRegister.TILE_SIZE); assertEquals("Width should be 10", 10, viewport.getWidthTiles()); viewport.setWidthPixels(4 * TileRegister.TILE_SIZE + 0.5); assertEquals("Width should be 5", 5, viewport.getWidthTiles()); }