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.

     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  * Tests for the functions located directly in the "DownloadsCommon" object.
     8  */
    10 function testFormatTimeLeft(aSeconds, aExpectedValue, aExpectedUnitString)
    11 {
    12   let expected = "";
    13   if (aExpectedValue) {
    14     // Format the expected result based on the current language.
    15     expected = DownloadsCommon.strings[aExpectedUnitString](aExpectedValue);
    16   }
    17   do_check_eq(DownloadsCommon.formatTimeLeft(aSeconds), expected);
    18 }
    20 function run_test()
    21 {
    22   testFormatTimeLeft(      0,   "", "");
    23   testFormatTimeLeft(      1,  "1", "shortTimeLeftSeconds");
    24   testFormatTimeLeft(     29, "29", "shortTimeLeftSeconds");
    25   testFormatTimeLeft(     30, "30", "shortTimeLeftSeconds");
    26   testFormatTimeLeft(     31,  "1", "shortTimeLeftMinutes");
    27   testFormatTimeLeft(     60,  "1", "shortTimeLeftMinutes");
    28   testFormatTimeLeft(     89,  "1", "shortTimeLeftMinutes");
    29   testFormatTimeLeft(     90,  "2", "shortTimeLeftMinutes");
    30   testFormatTimeLeft(     91,  "2", "shortTimeLeftMinutes");
    31   testFormatTimeLeft(   3600,  "1", "shortTimeLeftHours");
    32   testFormatTimeLeft(  86400, "24", "shortTimeLeftHours");
    33   testFormatTimeLeft( 169200, "47", "shortTimeLeftHours");
    34   testFormatTimeLeft( 172800,  "2", "shortTimeLeftDays");
    35   testFormatTimeLeft(8553600, "99", "shortTimeLeftDays");
    36   testFormatTimeLeft(8640000, "99", "shortTimeLeftDays");
    37 }

mercurial