~stolowski/unity-scope-home/handle-model-remove

« back to all changes in this revision

Viewing changes to tests/unit/test-home-scope.vala

  • Committer: Tarmac
  • Author(s): Pawel Stolowski
  • Date: 2013-09-19 14:32:17 UTC
  • mfrom: (163.1.3 fix-1220630)
  • Revision ID: tarmac-20130919143217-mw5gnxxjbqnju79c
Check if "images" member exists in metadata column to avoid assertion warnings. Fixes: https://bugs.launchpad.net/bugs/1220630.

Approved by PS Jenkins bot, Michal Hruby.

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
 
97
97
    Test.add_data_func ("/Unit/SmartScopes/Parse", Fixture.create<SmartScopesUtilTester> (SmartScopesUtilTester.test_smart_scopes_parse));
98
98
    Test.add_data_func ("/Unit/SmartScopes/ParseErrors", Fixture.create<SmartScopesUtilTester> (SmartScopesUtilTester.test_smart_scopes_parse_errors));
 
99
    Test.add_data_func ("/Unit/SmartScopes/ParseMissingOptionalFields", Fixture.create<SmartScopesUtilTester> (SmartScopesUtilTester.test_smart_scopes_parse_missing_optional_fields));
99
100
    Test.add_data_func ("/Unit/SmartScopes/SearchString", Fixture.create<SmartScopesUtilTester> (SmartScopesUtilTester.test_smart_scopes_search_string));
100
101
    Test.add_data_func ("/Unit/SmartScopes/OnChunkData", Fixture.create<SmartScopesUtilTester> (SmartScopesUtilTester.test_smart_scopes_on_chunk_data));
101
102
    Test.add_data_func ("/Unit/SmartScopes/Metrics", Fixture.create<SmartScopesUtilTester> (SmartScopesUtilTester.test_smart_scopes_metrics));
702
703
      catch (SmartScopes.ParseError e) { got_excp = true; }
703
704
    }
704
705
 
 
706
    internal void test_smart_scopes_parse_missing_optional_fields ()
 
707
    {
 
708
      int row_count = 0;
 
709
      var search_handler = new SmartScopes.SearchResponseHandler ();
 
710
 
 
711
      // missing or null 'images' in the metadata
 
712
      search_handler.parse_results_line ("""{"info": {"searchin-scope.scope": [{"title": "search in foursquare...", "icon_hint": "file:///usr/share/icons/unity-icon-theme/places/svg/group-info.svg", "uri": "scopes-query://foursquare:drink", "metadata": {"images":null}}, {"title": "search in recipepuppy...", "icon_hint": "file:///usr/share/icons/unity-icon-theme/places/svg/group-recipes.svg", "uri": "scopes-query://recipepuppy:drink", "metadata": {}}, {"title": "search in grooveshark...", "icon_hint": "file:///usr/share/icons/unity-icon-theme/places/svg/service-grooveshark.svg", "uri": "scopes-query://grooveshark:drink", "metadata": {}}, {"title": "search in ebay...", "icon_hint": "file:///usr/share/icons/unity-icon-theme/places/svg/service-ebay.svg", "uri": "scopes-query://ebay:drink", "metadata": {}}, {"title": "search in songkick...", "icon_hint": "file:///usr/share/icons/unity-icon-theme/places/svg/group-music.svg", "uri": "scopes-query://songkick:drink", "metadata": {}}]}, "type": "results"}""",
 
713
            (scope_id, row) => {
 
714
              assert (scope_id == "searchin-scope.scope");
 
715
              if (row_count == 0) {
 
716
                  assert (row[0].get_string () == "x-unity-no-preview-scopes-query://foursquare:drink"); // uri
 
717
                  assert (row[1].get_string () == "file:///usr/share/icons/unity-icon-theme/places/svg/group-info.svg"); // icon hint
 
718
                  assert (row[2].get_uint32 () == 0); // category
 
719
                  assert (row[3].get_uint32 () == Unity.ResultType.DEFAULT); // result type
 
720
                  assert (row[4].get_string () == "text/html"); // mimetype
 
721
                  assert (row[5].get_string () == "search in foursquare..."); // title
 
722
                  assert (row[6].get_string () == ""); // comment
 
723
                  assert (row[7].get_string () == "x-unity-no-preview-scopes-query://foursquare:drink"); // dnd uri
 
724
                  assert (row[8].is_of_type (new VariantType ("a{sv}")) && row[8].n_children () == 0); // metadata
 
725
              }
 
726
              row_count++;
 
727
            },
 
728
            (recommend) => { assert_not_reached (); });
 
729
 
 
730
      assert (row_count == 5);
 
731
    }
 
732
 
705
733
    const string SERVER_URI = "https://foobar.ubuntu.com";
706
734
    const string SEARCH_URI_PREFIX = SERVER_URI + "/smartscopes/v1/search";
707
735