browser/components/downloads/test/unit/test_DownloadsCommon.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* Any copyright is dedicated to the Public Domain.
michael@0 4 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 5
michael@0 6 /**
michael@0 7 * Tests for the functions located directly in the "DownloadsCommon" object.
michael@0 8 */
michael@0 9
michael@0 10 function testFormatTimeLeft(aSeconds, aExpectedValue, aExpectedUnitString)
michael@0 11 {
michael@0 12 let expected = "";
michael@0 13 if (aExpectedValue) {
michael@0 14 // Format the expected result based on the current language.
michael@0 15 expected = DownloadsCommon.strings[aExpectedUnitString](aExpectedValue);
michael@0 16 }
michael@0 17 do_check_eq(DownloadsCommon.formatTimeLeft(aSeconds), expected);
michael@0 18 }
michael@0 19
michael@0 20 function run_test()
michael@0 21 {
michael@0 22 testFormatTimeLeft( 0, "", "");
michael@0 23 testFormatTimeLeft( 1, "1", "shortTimeLeftSeconds");
michael@0 24 testFormatTimeLeft( 29, "29", "shortTimeLeftSeconds");
michael@0 25 testFormatTimeLeft( 30, "30", "shortTimeLeftSeconds");
michael@0 26 testFormatTimeLeft( 31, "1", "shortTimeLeftMinutes");
michael@0 27 testFormatTimeLeft( 60, "1", "shortTimeLeftMinutes");
michael@0 28 testFormatTimeLeft( 89, "1", "shortTimeLeftMinutes");
michael@0 29 testFormatTimeLeft( 90, "2", "shortTimeLeftMinutes");
michael@0 30 testFormatTimeLeft( 91, "2", "shortTimeLeftMinutes");
michael@0 31 testFormatTimeLeft( 3600, "1", "shortTimeLeftHours");
michael@0 32 testFormatTimeLeft( 86400, "24", "shortTimeLeftHours");
michael@0 33 testFormatTimeLeft( 169200, "47", "shortTimeLeftHours");
michael@0 34 testFormatTimeLeft( 172800, "2", "shortTimeLeftDays");
michael@0 35 testFormatTimeLeft(8553600, "99", "shortTimeLeftDays");
michael@0 36 testFormatTimeLeft(8640000, "99", "shortTimeLeftDays");
michael@0 37 }

mercurial