1context("geom_tile") 2 3test_that("accepts width and height params", { 4 df <- data_frame(x = c("a", "b"), y = c("a", "b")) 5 6 out1 <- layer_data(ggplot(df, aes(x, y)) + geom_tile()) 7 expect_equal(out1$xmin, new_mapped_discrete(c(0.5, 1.5))) 8 expect_equal(out1$xmax, new_mapped_discrete(c(1.5, 2.5))) 9 10 out2 <- layer_data(ggplot(df, aes(x, y)) + geom_tile(width = 0.5, height = 0.5)) 11 expect_equal(out2$xmin, new_mapped_discrete(c(0.75, 1.75))) 12 expect_equal(out2$xmax, new_mapped_discrete(c(1.25, 2.25))) 13}) 14 15test_that("accepts width and height aesthetics", { 16 df <- data_frame(x = 0, y = 0, width = c(2, 4), height = c(2, 4)) 17 18 p <- ggplot(df, aes(x, y, width = width, height = height)) + 19 geom_tile(fill = NA, colour = "black", size = 1) 20 out <- layer_data(p) 21 22 boundary <- as.data.frame(tibble::tribble( 23 ~xmin, ~xmax, ~ymin, ~ymax, 24 -1, 1, -1, 1, 25 -2, 2, -2, 2 26 )) 27 expect_equal(out[c("xmin", "xmax", "ymin", "ymax")], boundary) 28}) 29 30test_that("accepts linejoin parameter", { 31 df <- data_frame(x = c("a", "b"), y = c("a", "b")) 32 33 gp1 <- layer_grob(ggplot(df, aes(x, y)) + geom_tile())[[1]]$gp 34 expect_equal(gp1$linejoin, "mitre") 35 36 gp2 <- layer_grob(ggplot(df, aes(x, y)) + geom_tile(linejoin = "round"))[[1]]$gp 37 expect_equal(gp2$linejoin, "round") 38}) 39