Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

50 linhas
2.1KB

  1. context("test-anim_options")
  2. test_that("merging of animation options works", {
  3. ao_new <- anim_options(5, 3, text_size = 9, title_size = 13)
  4. ao_old <- anim_options(ease_default = "cubic-in", text_family = "Times New Roman")
  5. ao_merged <- anim_options(5, 3, "cubic-in", text_size = 9, title_size = 13, text_family = "Times New Roman")
  6. expect_equal(merge(ao_new, ao_old), ao_merged)
  7. })
  8. test_that("setting and getting animation options works", {
  9. set_font_size(5, 10)
  10. expect_equal(get_anim_opt(), anim_options(text_size = 5, title_size = 10))
  11. expect_error(get_anim_opt("text_size"))
  12. expect_equal(get_text_size(), get_anim_opt()$text_size)
  13. expect_equal(get_title_size(), get_anim_opt()$title_size)
  14. anim_options_set(anim_options(2, 1))
  15. expect_equal(get_anim_opt("transition_length"), 2)
  16. expect_equal(get_anim_opt("state_length"), 1)
  17. expect_equal(get_anim_opt(), anim_options(2, 1, text_size = 5, title_size = 10))
  18. anim_options_set()
  19. expect_equal(get_anim_opt("transition_length"), plot_settings$default$transition_length)
  20. anim_options_set(anim_options(enter = enter_appear(early = TRUE)))
  21. expect_equal(names(get_anim_opt("enter")), "enter_appear(early = TRUE)")
  22. expect_s3_class(get_anim_opt("enter")[[1]], "ggproto")
  23. anim_options_set()
  24. })
  25. test_that("precedence: function > user-set global > default (> global default)", {
  26. ao_function <- anim_options(ease_default = "linear")
  27. ao_global <- anim_options(ease_default = "cubic", text_family = "Arial")
  28. expect_equal(default_anim_opts("gather", ao_function)$ease_default, "linear")
  29. anim_options_set(ao_global)
  30. expect_equal(default_anim_opts("gather")$ease_default, "cubic")
  31. expect_equal(default_anim_opts("gather", ao_function)$ease_default, "linear")
  32. ao_default <- default_anim_opts("gather", ao_function) # inside animate_ function
  33. ao_final <- validate_anim_opts(ao_default) # just before animate_plot() or static_plot()
  34. expect_equal(ao_final$ease_default, "linear")
  35. expect_equal(ao_final$text_family, "Arial")
  36. expect_equivalent(names(ao_final$ease_other), c("y", "x"))
  37. expect_equal(ao_final$title_family, plot_settings$default$title_family)
  38. anim_options_set()
  39. })