Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/tests/gtest/TestGfxWidgets.cpp
Line
Count
Source (jump to first uncovered line)
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
0
TEST(GfxWidgets, Split) {
14
0
  char aStr[8], bStr[8], cStr[8], dStr[8];
15
0
16
0
  ASSERT_TRUE(SplitDriverVersion("33.4.3.22", aStr, bStr, cStr, dStr));
17
0
  ASSERT_TRUE(atoi(aStr) == 33 && atoi(bStr) == 4 && atoi(cStr) == 3 && atoi(dStr) == 22);
18
0
19
0
  ASSERT_TRUE(SplitDriverVersion("28.74.0.0", aStr, bStr, cStr, dStr));
20
0
  ASSERT_TRUE(atoi(aStr) == 28 && atoi(bStr) == 74 && atoi(cStr) == 0 && atoi(dStr) == 0);
21
0
22
0
  ASSERT_TRUE(SplitDriverVersion("132.0.0.0", aStr, bStr, cStr, dStr));
23
0
  ASSERT_TRUE(atoi(aStr) == 132 && atoi(bStr) == 0 && atoi(cStr) == 0 && atoi(dStr) == 0);
24
0
25
0
  ASSERT_TRUE(SplitDriverVersion("2.3.0.0", aStr, bStr, cStr, dStr));
26
0
  ASSERT_TRUE(atoi(aStr) == 2 && atoi(bStr) == 3 && atoi(cStr) == 0 && atoi(dStr) == 0);
27
0
28
0
  ASSERT_TRUE(SplitDriverVersion("25.4.0.8", aStr, bStr, cStr, dStr));
29
0
  ASSERT_TRUE(atoi(aStr) == 25 && atoi(bStr) == 4 && atoi(cStr) == 0 && atoi(dStr) == 8);
30
0
31
0
  ASSERT_TRUE(SplitDriverVersion("424.143.84437.3", aStr, bStr, cStr, dStr));
32
0
  ASSERT_TRUE(atoi(aStr) == 424 && atoi(bStr) == 143 && atoi(cStr) == 8443 && atoi(dStr) == 3);
33
0
34
0
  ASSERT_FALSE(SplitDriverVersion("25.4.0.8.", aStr, bStr, cStr, dStr));
35
0
  ASSERT_TRUE(atoi(aStr) == 25 && atoi(bStr) == 4 && atoi(cStr) == 0 && atoi(dStr) == 8);
36
0
37
0
  ASSERT_TRUE(SplitDriverVersion("424.143.8.3143243", aStr, bStr, cStr, dStr));
38
0
  ASSERT_TRUE(atoi(aStr) == 424 && atoi(bStr) == 143 && atoi(cStr) == 8 && atoi(dStr) == 3143);
39
0
40
0
  ASSERT_FALSE(SplitDriverVersion("25.4.0.8..", aStr, bStr, cStr, dStr));
41
0
  ASSERT_TRUE(atoi(aStr) == 25 && atoi(bStr) == 4 && atoi(cStr) == 0 && atoi(dStr) == 8);
42
0
43
0
  ASSERT_FALSE(SplitDriverVersion("424.143.8.3143243.", aStr, bStr, cStr, dStr));
44
0
  ASSERT_TRUE(atoi(aStr) == 424 && atoi(bStr) == 143 && atoi(cStr) == 8 && atoi(dStr) == 3143);
45
0
46
0
  ASSERT_FALSE(SplitDriverVersion("25.4.0.8.13", aStr, bStr, cStr, dStr));
47
0
  ASSERT_TRUE(atoi(aStr) == 25 && atoi(bStr) == 4 && atoi(cStr) == 0 && atoi(dStr) == 8);
48
0
49
0
  ASSERT_FALSE(SplitDriverVersion("4.1.8.13.24.35", aStr, bStr, cStr, dStr));
50
0
  ASSERT_TRUE(atoi(aStr) == 4 && atoi(bStr) == 1 && atoi(cStr) == 8 && atoi(dStr) == 13);
51
0
52
0
  ASSERT_TRUE(SplitDriverVersion("28...74", aStr, bStr, cStr, dStr));
53
0
  ASSERT_TRUE(atoi(aStr) == 28 && atoi(bStr) == 0 && atoi(cStr) == 0 && atoi(dStr) == 74);
54
0
55
0
  ASSERT_FALSE(SplitDriverVersion("4.1.8.13.24.35", aStr, bStr, cStr, dStr));
56
0
  ASSERT_TRUE(atoi(aStr) == 4 && atoi(bStr) == 1 && atoi(cStr) == 8 && atoi(dStr) == 13);
57
0
58
0
  ASSERT_TRUE(SplitDriverVersion("35..42.0", aStr, bStr, cStr, dStr));
59
0
  ASSERT_TRUE(atoi(aStr) == 35 && atoi(bStr) == 0 && atoi(cStr) == 42 && atoi(dStr) == 0);
60
0
}
61
62
0
TEST(GfxWidgets, Versioning) {
63
0
  ASSERT_TRUE(mozilla::Version("0") < mozilla::Version("41.0a1"));
64
0
  ASSERT_TRUE(mozilla::Version("39.0.5b7") < mozilla::Version("41.0a1"));
65
0
  ASSERT_TRUE(mozilla::Version("18.0.5b7") < mozilla::Version("18.2"));
66
0
  ASSERT_TRUE(mozilla::Version("30.0.5b7") < mozilla::Version("41.0b9"));
67
0
  ASSERT_TRUE(mozilla::Version("100") > mozilla::Version("43.0a1"));
68
0
  ASSERT_FALSE(mozilla::Version("42.0") < mozilla::Version("42.0"));
69
0
  ASSERT_TRUE(mozilla::Version("42.0b2") < mozilla::Version("42.0"));
70
0
  ASSERT_TRUE(mozilla::Version("42.0b2") < mozilla::Version("42"));
71
0
  ASSERT_TRUE(mozilla::Version("42.0b2") < mozilla::Version("43.0a1"));
72
0
  ASSERT_TRUE(mozilla::Version("42") < mozilla::Version("43.0a1"));
73
0
  ASSERT_TRUE(mozilla::Version("42.0") < mozilla::Version("43.0a1"));
74
0
  ASSERT_TRUE(mozilla::Version("42.0.5") < mozilla::Version("43.0a1"));
75
0
  ASSERT_TRUE(mozilla::Version("42.1") < mozilla::Version("43.0a1"));
76
0
  ASSERT_TRUE(mozilla::Version("42.0a1") < mozilla::Version("42"));
77
0
  ASSERT_TRUE(mozilla::Version("42.0a1") < mozilla::Version("42.0.5"));
78
0
  ASSERT_TRUE(mozilla::Version("42.0b7") < mozilla::Version("42.0.5"));
79
0
  ASSERT_TRUE(mozilla::Version("") == mozilla::Version("0"));
80
0
81
0
  // Note these two; one would expect for 42.0b1 and 42b1 to compare the
82
0
  // same, but they do not.  If this ever changes, we want to know, so
83
0
  // leave the test here to fail.
84
0
  ASSERT_TRUE(mozilla::Version("42.0a1") < mozilla::Version("42.0b2"));
85
0
  ASSERT_FALSE(mozilla::Version("42.0a1") < mozilla::Version("42b2"));
86
0
}
87