summaryrefslogtreecommitdiff
path: root/app/tests/windows/main.cpp
blob: 53c9386da527e47a471fd6a2246469552d6d5a85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "turns/app/windows/main.hpp"

#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>

#include <string>

#include <adwaita.h>
#include <glibmm/i18n.h>
#include <glibmm/ustring.h>
#include <gtkmm/builder.h>
#include <gtkmm/widget.h>

namespace turns::app::windows::tests
{

  TEST_CASE("Newly constructed main window", "[windows]")
  {
    auto locale = GENERATE("en_US.UTF-8", "de_CH.UTF-8");
    setlocale(LC_ALL, locale);

    auto builder = Gtk::Builder::create_from_resource("/turns/windows/main_window.ui");
    auto instance = Gtk::Builder::get_widget_derived<main>(builder, "main_window");

    SECTION("construction via builder succeeds")
    {
      REQUIRE(instance);
    }

    SECTION("the window sub-title is not empty")
    {
      auto widget = builder->get_widget<Gtk::Widget>("title");
      auto adw = ADW_WINDOW_TITLE(widget->gobj());
      REQUIRE(adw_window_title_get_subtitle(adw));
    }

    SECTION("the window sub-title is set according to the active language")
    {
      auto widget = builder->get_widget<Gtk::Widget>("title");
      auto adw = ADW_WINDOW_TITLE(widget->gobj());
      REQUIRE(adw_window_title_get_subtitle(adw) == Glib::ustring{_("No active turn-order")});
    }

    SECTION("the window title is not empty")
    {
      auto widget = builder->get_widget<Gtk::Widget>("title");
      auto adw = ADW_WINDOW_TITLE(widget->gobj());
      REQUIRE(adw_window_title_get_title(adw));
    }

    SECTION("the window title is set according to the active language")
    {
      auto widget = builder->get_widget<Gtk::Widget>("title");
      auto adw = ADW_WINDOW_TITLE(widget->gobj());
      REQUIRE(adw_window_title_get_title(adw) == Glib::ustring{_("Turns")});
    }
  }

}  // namespace turns::app::windows::tests