summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-07-27 15:52:10 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-08 17:24:00 +0200
commit3fc0737dda213a7dc1e769523434d06902483426 (patch)
tree0808227282357529e9b35a8af533b8915ce3e2c6 /src
parentbc55aaf18c56a82ee3d12b8ba2a6d7f452dbda2c (diff)
app: try to parse ids.json, run embedded tests (debug output only)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src')
-rw-r--r--src/app.cpp62
1 files changed, 48 insertions, 14 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 9bd12ed..8a3abec 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -30,10 +30,8 @@ struct wm::area area_from_json(json const &j) {
return wm::area{
j["name"].get<std::string>(),
{
- get<uint32_t>(j["width"]),
- get<uint32_t>(j["height"]),
- get<int32_t>(j["x"]),
- get<int32_t>(j["y"]),
+ get<uint32_t>(j["width"]), get<uint32_t>(j["height"]),
+ get<int32_t>(j["x"]), get<int32_t>(j["y"]),
},
get<uint32_t>(j["zorder"]),
};
@@ -72,22 +70,58 @@ struct result<layouts_type> load_layout(char const *filename) {
return Ok(layouts);
}
+struct result<surface_id_to_layer_map>
+ load_layer_ids(char const *filename) {
+ DB("loading IDs from " << filename);
+
+ json jids;
+ std::ifstream i(filename);
+ i >> jids;
+
+ auto m = to_surface_id_to_layer_map(jids["mappings"]);
+
+ if (m.is_ok()) {
+ auto i = m.unwrap();
+
+ auto jtests = jids.value("tests", json());
+
+ std::vector<std::pair<int, int>> tests;
+ std::transform(std::cbegin(jtests), std::cend(jtests),
+ std::back_inserter(tests), [](json const &j) {
+ return std::make_pair(get<int>(j["surface_id"]),
+ get<int>(j["expect_layer_id"]));
+ });
+
+ for (auto sid : tests) {
+ DB("layer id for surface "
+ << sid.first << " is "
+ << i.get_layer_for_surface(sid.first).value_or(-1) << " expected "
+ << sid.second);
+ }
+ }
+
+ return m;
+}
+
} // namespace
App::App(wl::display *d)
- : api{this},
- display{d},
- controller{},
- outputs(),
- layouts() {
- // layouts(load_layout("../layout.json").unwrap()) {
+ : api{this}, display{d}, controller{}, outputs(), layouts() {
+ // layouts(load_layout("../layout.json").unwrap()) {
assert(g_app == nullptr);
g_app = this;
- auto l = load_layout("../layout.json");
- if (l.is_err()) {
- DB("Could not load layout: " << l.unwrap_err());
- }
+ auto a = load_layout("../layout.json");
+ auto b = a.map_err([](char const *e) -> char const * {
+ DB("Could not load layout: " << e);
+ return e;
+ });
+
+ auto c = load_layer_ids("../ids.json");
+ auto e = c.map_err([](char const *e) -> char const * {
+ DB("Could not load ids: " << e);
+ return e;
+ });
}
App::~App() { g_app = nullptr; }