tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

TestGfxWidgets.cpp (5267B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "gtest/gtest.h"
      8 #include "GfxDriverInfo.h"
      9 #include "nsVersionComparator.h"
     10 
     11 using namespace mozilla::widget;
     12 
     13 TEST(GfxWidgets, Split)
     14 {
     15  char aStr[8], bStr[8], cStr[8], dStr[8];
     16 
     17  ASSERT_TRUE(SplitDriverVersion("33.4.3.22", aStr, bStr, cStr, dStr));
     18  ASSERT_TRUE(atoi(aStr) == 33 && atoi(bStr) == 4 && atoi(cStr) == 3 &&
     19              atoi(dStr) == 22);
     20 
     21  ASSERT_TRUE(SplitDriverVersion("28.74.0.0", aStr, bStr, cStr, dStr));
     22  ASSERT_TRUE(atoi(aStr) == 28 && atoi(bStr) == 74 && atoi(cStr) == 0 &&
     23              atoi(dStr) == 0);
     24 
     25  ASSERT_TRUE(SplitDriverVersion("132.0.0.0", aStr, bStr, cStr, dStr));
     26  ASSERT_TRUE(atoi(aStr) == 132 && atoi(bStr) == 0 && atoi(cStr) == 0 &&
     27              atoi(dStr) == 0);
     28 
     29  ASSERT_TRUE(SplitDriverVersion("2.3.0.0", aStr, bStr, cStr, dStr));
     30  ASSERT_TRUE(atoi(aStr) == 2 && atoi(bStr) == 3 && atoi(cStr) == 0 &&
     31              atoi(dStr) == 0);
     32 
     33  ASSERT_TRUE(SplitDriverVersion("25.4.0.8", aStr, bStr, cStr, dStr));
     34  ASSERT_TRUE(atoi(aStr) == 25 && atoi(bStr) == 4 && atoi(cStr) == 0 &&
     35              atoi(dStr) == 8);
     36 
     37  ASSERT_TRUE(SplitDriverVersion("424.143.84437.3", aStr, bStr, cStr, dStr));
     38  ASSERT_TRUE(atoi(aStr) == 424 && atoi(bStr) == 143 && atoi(cStr) == 8443 &&
     39              atoi(dStr) == 3);
     40 
     41  ASSERT_FALSE(SplitDriverVersion("25.4.0.8.", aStr, bStr, cStr, dStr));
     42  ASSERT_TRUE(atoi(aStr) == 25 && atoi(bStr) == 4 && atoi(cStr) == 0 &&
     43              atoi(dStr) == 8);
     44 
     45  ASSERT_TRUE(SplitDriverVersion("424.143.8.3143243", aStr, bStr, cStr, dStr));
     46  ASSERT_TRUE(atoi(aStr) == 424 && atoi(bStr) == 143 && atoi(cStr) == 8 &&
     47              atoi(dStr) == 3143);
     48 
     49  ASSERT_FALSE(SplitDriverVersion("25.4.0.8..", aStr, bStr, cStr, dStr));
     50  ASSERT_TRUE(atoi(aStr) == 25 && atoi(bStr) == 4 && atoi(cStr) == 0 &&
     51              atoi(dStr) == 8);
     52 
     53  ASSERT_FALSE(
     54      SplitDriverVersion("424.143.8.3143243.", aStr, bStr, cStr, dStr));
     55  ASSERT_TRUE(atoi(aStr) == 424 && atoi(bStr) == 143 && atoi(cStr) == 8 &&
     56              atoi(dStr) == 3143);
     57 
     58  ASSERT_FALSE(SplitDriverVersion("25.4.0.8.13", aStr, bStr, cStr, dStr));
     59  ASSERT_TRUE(atoi(aStr) == 25 && atoi(bStr) == 4 && atoi(cStr) == 0 &&
     60              atoi(dStr) == 8);
     61 
     62  ASSERT_FALSE(SplitDriverVersion("4.1.8.13.24.35", aStr, bStr, cStr, dStr));
     63  ASSERT_TRUE(atoi(aStr) == 4 && atoi(bStr) == 1 && atoi(cStr) == 8 &&
     64              atoi(dStr) == 13);
     65 
     66  ASSERT_TRUE(SplitDriverVersion("28...74", aStr, bStr, cStr, dStr));
     67  ASSERT_TRUE(atoi(aStr) == 28 && atoi(bStr) == 0 && atoi(cStr) == 0 &&
     68              atoi(dStr) == 74);
     69 
     70  ASSERT_FALSE(SplitDriverVersion("4.1.8.13.24.35", aStr, bStr, cStr, dStr));
     71  ASSERT_TRUE(atoi(aStr) == 4 && atoi(bStr) == 1 && atoi(cStr) == 8 &&
     72              atoi(dStr) == 13);
     73 
     74  ASSERT_TRUE(SplitDriverVersion("35..42.0", aStr, bStr, cStr, dStr));
     75  ASSERT_TRUE(atoi(aStr) == 35 && atoi(bStr) == 0 && atoi(cStr) == 42 &&
     76              atoi(dStr) == 0);
     77 }
     78 
     79 TEST(GfxWidgets, Versioning)
     80 {
     81  ASSERT_TRUE(mozilla::Version("0") < mozilla::Version("41.0a1"));
     82  ASSERT_TRUE(mozilla::Version("39.0.5b7") < mozilla::Version("41.0a1"));
     83  ASSERT_TRUE(mozilla::Version("18.0.5b7") < mozilla::Version("18.2"));
     84  ASSERT_TRUE(mozilla::Version("30.0.5b7") < mozilla::Version("41.0b9"));
     85  ASSERT_TRUE(mozilla::Version("100") > mozilla::Version("43.0a1"));
     86  ASSERT_FALSE(mozilla::Version("42.0") < mozilla::Version("42.0"));
     87  ASSERT_TRUE(mozilla::Version("42.0b2") < mozilla::Version("42.0"));
     88  ASSERT_TRUE(mozilla::Version("42.0b2") < mozilla::Version("42"));
     89  ASSERT_TRUE(mozilla::Version("42.0b2") < mozilla::Version("43.0a1"));
     90  ASSERT_TRUE(mozilla::Version("42") < mozilla::Version("43.0a1"));
     91  ASSERT_TRUE(mozilla::Version("42.0") < mozilla::Version("43.0a1"));
     92  ASSERT_TRUE(mozilla::Version("42.0.5") < mozilla::Version("43.0a1"));
     93  ASSERT_TRUE(mozilla::Version("42.1") < mozilla::Version("43.0a1"));
     94  ASSERT_TRUE(mozilla::Version("42.0a1") < mozilla::Version("42"));
     95  ASSERT_TRUE(mozilla::Version("42.0a1") < mozilla::Version("42.0.5"));
     96  ASSERT_TRUE(mozilla::Version("42.0b7") < mozilla::Version("42.0.5"));
     97  ASSERT_TRUE(mozilla::Version("") == mozilla::Version("0"));
     98  ASSERT_TRUE(mozilla::Version("1b1b") == mozilla::Version("1b1b"));
     99  ASSERT_TRUE(mozilla::Version("1b1b") < mozilla::Version("1b1c"));
    100  ASSERT_TRUE(mozilla::Version("1b1b") < mozilla::Version("1b1d"));
    101  ASSERT_TRUE(mozilla::Version("1b1c") > mozilla::Version("1b1b"));
    102  ASSERT_TRUE(mozilla::Version("1b1d") > mozilla::Version("1b1b"));
    103  ASSERT_TRUE(mozilla::Version("110") < mozilla::Version("110.0.1"));
    104  ASSERT_TRUE(mozilla::Version("110.*") >= mozilla::Version("110.0.1"));
    105 
    106  // Note these two; one would expect for 42.0b1 and 42b1 to compare the
    107  // same, but they do not.  If this ever changes, we want to know, so
    108  // leave the test here to fail.
    109  ASSERT_TRUE(mozilla::Version("42.0a1") < mozilla::Version("42.0b2"));
    110  ASSERT_FALSE(mozilla::Version("42.0a1") < mozilla::Version("42b2"));
    111 }