test_guidarray_sort.js
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
31 function runTest () {
32 
33  var databaseGUID = "test_guidarray_sort";
34  var library = createLibrary(databaseGUID);
35  var listId = library.QueryInterface(Ci.sbILocalDatabaseLibrary).getMediaItemIdForGuid("7e8dcc95-7a1d-4bb3-9b14-d4906a9952cb");
36  var array;
37 
38  // One level sort, small fetch size, ascending
39  array = makeArray(library);
40  array.baseTable = "media_items";
41  array.addSort("http://songbirdnest.com/data/1.0#trackName", true);
42  array.fetchSize = 1;
43  assertSort(array, "data_sort_trackname_asc.txt");
44 
45  // One level sort, small fetch size, descending
46  array = makeArray(library);
47  array.baseTable = "media_items";
48  array.addSort("http://songbirdnest.com/data/1.0#trackName", false);
49  array.fetchSize = 2;
50  assertSort(array, "data_sort_trackname_desc.txt");
51 
52  // One level sort, large fetch size, ascending
53  array = makeArray(library);
54  array.baseTable = "media_items";
55  array.addSort("http://songbirdnest.com/data/1.0#trackName", true);
56  array.fetchSize = 20;
57  assertSort(array, "data_sort_trackname_asc.txt");
58 
59  // One level sort, large fetch size, descending
60  array = makeArray(library);
61  array.baseTable = "media_items";
62  array.addSort("http://songbirdnest.com/data/1.0#trackName", false);
63  array.fetchSize = 200;
64  assertSort(array, "data_sort_trackname_desc.txt");
65 
66  // One level sort, ascending
67  array = makeArray(library);
68  array.baseTable = "media_items";
69  array.addSort("http://songbirdnest.com/data/1.0#playCount", true);
70  array.fetchSize = 40;
71  assertSort(array, "data_sort_playcount_asc.txt");
72 
73  // One level sort, descending
74  array = makeArray(library);
75  array.baseTable = "media_items";
76  array.addSort("http://songbirdnest.com/data/1.0#playCount", false);
77  array.fetchSize = 40;
78  assertSort(array, "data_sort_playcount_desc.txt");
79 
80  // One level top level property sort, ascending
81  array = makeArray(library);
82  array.baseTable = "media_items";
83  array.addSort("http://songbirdnest.com/data/1.0#contentURL", true);
84  array.fetchSize = 40;
85  assertSort(array, "data_sort_contenturl_asc.txt");
86 
87  // One level top level property sort, descending
88  array = makeArray(library);
89  array.baseTable = "media_items";
90  array.addSort("http://songbirdnest.com/data/1.0#contentURL", false);
91  array.fetchSize = 40;
92  assertSort(array, "data_sort_contenturl_desc.txt");
93 
94  // Sort a simple media list by the ordinal
95  array = makeArray(library);
96  array.baseTable = "simple_media_lists";
97  array.baseConstraintColumn = "media_item_id";
98  array.baseConstraintValue = listId;
99  array.addSort("http://songbirdnest.com/data/1.0#ordinal", true);
100  array.fetchSize = 40;
101  assertSort(array, "data_sort_sml101_ordinal_asc.txt");
102 
103  array = makeArray(library);
104  array.baseTable = "simple_media_lists";
105  array.baseConstraintColumn = "media_item_id";
106  array.baseConstraintValue = listId;
107  array.addSort("http://songbirdnest.com/data/1.0#ordinal", false);
108  array.fetchSize = 40;
109  assertSort(array, "data_sort_sml101_ordinal_desc.txt");
110 }
111 
inArray array
trim makeArray
function createLibrary(databaseGuid, databaseLocation)
Definition: test_load.js:151
function runTest()
Test file.
const Ci
function assertSort(array, dataFile)