Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* Any copyright is dedicated to the Public Domain.
4 http://creativecommons.org/publicdomain/zero/1.0/ */
6 /**
7 * Make sure the downloads panel can display items in the right order and
8 * contains the expected data.
9 */
10 function test_task()
11 {
12 // Display one of each download state.
13 const DownloadData = [
14 { state: nsIDM.DOWNLOAD_NOTSTARTED },
15 { state: nsIDM.DOWNLOAD_PAUSED },
16 { state: nsIDM.DOWNLOAD_FINISHED },
17 { state: nsIDM.DOWNLOAD_FAILED },
18 { state: nsIDM.DOWNLOAD_CANCELED },
19 ];
21 try {
22 // Wait for focus first
23 yield promiseFocus();
25 // Ensure that state is reset in case previous tests didn't finish.
26 yield task_resetState();
28 // For testing purposes, show all the download items at once.
29 var originalCountLimit = DownloadsView.kItemCountLimit;
30 DownloadsView.kItemCountLimit = DownloadData.length;
31 registerCleanupFunction(function () {
32 DownloadsView.kItemCountLimit = originalCountLimit;
33 });
35 // Populate the downloads database with the data required by this test.
36 yield task_addDownloads(DownloadData);
38 // Open the user interface and wait for data to be fully loaded.
39 yield task_openPanel();
41 // Test item data and count. This also tests the ordering of the display.
42 let richlistbox = document.getElementById("downloadsListBox");
43 /* disabled for failing intermittently (bug 767828)
44 is(richlistbox.children.length, DownloadData.length,
45 "There is the correct number of richlistitems");
46 */
47 let itemCount = richlistbox.children.length;
48 for (let i = 0; i < itemCount; i++) {
49 let element = richlistbox.children[itemCount - i - 1];
50 let dataItem = new DownloadsViewItemController(element).dataItem;
51 is(dataItem.state, DownloadData[i].state, "Download states match up");
52 }
53 } finally {
54 // Clean up when the test finishes.
55 yield task_resetState();
56 }
57 }