+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;
+}
+