56
56
Test.add_data_func ("/Unit/Lens/Activation", test_lens_activation);
57
57
Test.add_data_func ("/Unit/Lens/Preview", test_lens_preview);
58
58
Test.add_data_func ("/Unit/Lens/PreviewSignal", test_lens_preview_signal);
59
Test.add_data_func ("/Unit/Lens/PreviewClosedSignal", test_lens_preview_closed_signal);
912
913
assert (request_item_signal_count == 0);
916
public static void test_lens_preview_closed_signal ()
918
SignalWrapper[] signals = null;
919
assert (local_scope != null);
921
var ml = new MainLoop ();
923
bool got_preview_uri_signal = false;
924
int got_closed_signal = 0;
926
var preview = new Unity.GenericPreview ("title", "description", null);
928
// this signal handler gets called when we updates are sent in the last step of the test
929
signals += new SignalWrapper (preview,
930
preview.closed.connect (() =>
935
// this signal handler gets called when activate is called with PREVIEW_RESULT
936
signals += new SignalWrapper (local_scope,
937
local_scope.preview_uri.connect ((uri) =>
939
assert (uri == "scheme://local/");
940
got_preview_uri_signal = true;
944
ml = new MainLoop ();
946
var lens_results_model =
947
exported_lens.get_model_internal (0) as Dee.SharedModel;
948
var iter = lens_results_model.get_first_iter ();
949
var mangled_uri = lens_results_model.get_string (iter, 0);
951
Unity.Protocol.GenericPreview? reconstructed = null;
952
call_lens_activate (mangled_uri, Unity.Protocol.ActionType.PREVIEW_RESULT, (reply) =>
954
var v = reply.get_child_value (0);
955
Unity.Protocol.ActivationReplyRaw reply_struct =
956
(Unity.Protocol.ActivationReplyRaw) v;
957
reconstructed = (Unity.Protocol.GenericPreview?)Unity.Protocol.Preview.parse (reply_struct.hints["preview"]);
960
run_with_timeout (ml, 5000);
962
assert (reconstructed != null);
963
assert (got_closed_signal == 0);
965
// send preview_closed "signal"; this will result in setting action=close in the updates hashtable.
966
reconstructed.begin_updates();
967
reconstructed.preview_closed();
968
var updates = reconstructed.end_updates_as_hashtable();
970
assert (updates != null);
971
assert (updates.size() == 1);
972
assert (updates.contains("base-preview-action"));
973
assert (updates["base-preview-action"].get_string() == "closed");
975
ml = new MainLoop ();
977
// send 'closed' signal
978
call_lens_update_preview_property (mangled_uri, updates, (reply) =>
982
run_with_timeout (ml, 5000);
984
assert (got_closed_signal == 1);