~stolowski/libunity/libunity.error-state

« back to all changes in this revision

Viewing changes to test/vala/test-lens.vala

  • Committer: Tarmac
  • Author(s): Michal Hruby
  • Date: 2012-08-16 09:39:51 UTC
  • mfrom: (159.1.4 libunity)
  • Revision ID: tarmac-20120816093951-nznxnzvwf5d0t5up
Switch visibility of AsyncPreview and SeriesPreview, add no-details hint to base preview. Fixes: . Approved by Pawel Stolowski.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
    Test.add_data_func ("/Unit/Lens/Sources", test_lens_sources);
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
 
    Test.add_data_func ("/Unit/Lens/PreviewSignal", test_lens_preview_signal);
59
 
    Test.add_data_func ("/Unit/Lens/PreviewClosedSignal", test_lens_preview_closed_signal);
 
58
    Test.add_data_func ("/Unit/Lens/Preview/Async", test_lens_preview_async);
 
59
    Test.add_data_func ("/Unit/Lens/Preview/Signal", test_lens_preview_signal);
 
60
    Test.add_data_func ("/Unit/Lens/Preview/ClosedSignal", test_lens_preview_closed_signal);
60
61
 
61
62
    Test.run ();
62
63
 
799
800
    assert (got_action_activated_signal);
800
801
  }
801
802
 
 
803
  public static void test_lens_preview_async ()
 
804
  {
 
805
    SignalWrapper[] signals = null;
 
806
    assert (local_scope != null);
 
807
 
 
808
    var ml = new MainLoop ();
 
809
 
 
810
    var lens_results_model =
 
811
      exported_lens.get_model_internal (0) as Dee.SharedModel;
 
812
    var iter = lens_results_model.get_first_iter ();
 
813
    var mangled_uri = lens_results_model.get_string (iter, 0);
 
814
 
 
815
    bool got_activate_uri_signal = false;
 
816
    bool got_preview_uri_signal = false;
 
817
    Unity.PreviewAction? action = null;
 
818
 
 
819
    signals += new SignalWrapper (local_scope,
 
820
      local_scope.activate_uri.connect ((uri) =>
 
821
    {
 
822
      got_activate_uri_signal = true;
 
823
      return null;
 
824
    }));
 
825
 
 
826
    signals += new SignalWrapper (local_scope,
 
827
      local_scope.preview_uri.connect ((uri) =>
 
828
    {
 
829
      assert (uri == "scheme://local/");
 
830
      got_preview_uri_signal = true;
 
831
      var async_preview = new Unity.AsyncPreview ();
 
832
 
 
833
      Timeout.add (100, () =>
 
834
      {
 
835
        var p = new Unity.ApplicationPreview ("App title", "Subtitle",
 
836
                                              "Description",
 
837
                                              new ThemedIcon ("internet"),
 
838
                                              null);
 
839
        action = new Unity.PreviewAction ("button1", "Do stuff!", null);
 
840
        p.add_action (action);
 
841
        async_preview.preview_ready (p);
 
842
        return false;
 
843
      });
 
844
      return async_preview;
 
845
    }));
 
846
 
 
847
    ml = new MainLoop ();
 
848
    Unity.Protocol.Preview? reconstructed = null;
 
849
    call_lens_activate (mangled_uri, 1, (reply) =>
 
850
    {
 
851
      var v = reply.get_child_value (0);
 
852
      Unity.Protocol.ActivationReplyRaw reply_struct =
 
853
        (Unity.Protocol.ActivationReplyRaw) v;
 
854
      reconstructed = Unity.Protocol.Preview.parse (reply_struct.hints["preview"]);
 
855
      ml.quit ();
 
856
    });
 
857
    run_with_timeout (ml, 5000);
 
858
 
 
859
    assert (reconstructed != null);
 
860
    assert (reconstructed is Unity.Protocol.ApplicationPreview);
 
861
    assert (reconstructed.title == "App title");
 
862
    assert (action != null);
 
863
    assert (got_preview_uri_signal);
 
864
    assert (!got_activate_uri_signal);
 
865
 
 
866
    bool got_action_activated_signal = false;
 
867
    action.activated.connect (() =>
 
868
    {
 
869
      got_action_activated_signal = true;
 
870
      return new Unity.ActivationResponse (Unity.HandledType.NOT_HANDLED);
 
871
    });
 
872
 
 
873
    // expecting button_id:scope_uid:uri
 
874
    ml = new MainLoop ();
 
875
    call_lens_activate ("%s:%s".printf (action.id, mangled_uri), 2, (reply) =>
 
876
    {
 
877
      ml.quit ();
 
878
    });
 
879
    run_with_timeout (ml, 5000);
 
880
 
 
881
    assert (got_action_activated_signal);
 
882
  }
 
883
 
802
884
  public static void test_lens_preview_signal ()
803
885
  {
804
886
    SignalWrapper[] signals = null;