Merge mozilla-central to autoland. CLOSED TREE
[gecko.git] / gfx / 2d / unittest / Main.cpp
blob0a6c9b0401c2201f6bcbfab7a4ebc76244328dda
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/. */
7 #include "SanityChecks.h"
8 #include "TestPoint.h"
9 #include "TestScaling.h"
10 #include "TestBugs.h"
11 #ifdef WIN32
12 # include "TestDrawTargetD2D.h"
13 #endif
15 #include <string>
16 #include <sstream>
18 struct TestObject {
19 TestBase* test;
20 std::string name;
23 int main() {
24 TestObject tests[] = {
25 {new SanityChecks(), "Sanity Checks"},
26 #ifdef WIN32
27 {new TestDrawTargetD2D(), "DrawTarget (D2D)"},
28 #endif
29 {new TestPoint(), "Point Tests"},
30 {new TestScaling(), "Scaling Tests"} {new TestBugs(), "Bug Tests"}};
32 int totalFailures = 0;
33 int totalTests = 0;
34 std::stringstream message;
35 printf("------ STARTING RUNNING TESTS ------\n");
36 for (int i = 0; i < sizeof(tests) / sizeof(TestObject); i++) {
37 message << "--- RUNNING TESTS: " << tests[i].name << " ---\n";
38 printf(message.str().c_str());
39 message.str("");
40 int failures = 0;
41 totalTests += tests[i].test->RunTests(&failures);
42 totalFailures += failures;
43 // Done with this test!
44 delete tests[i].test;
46 message << "------ FINISHED RUNNING TESTS ------\nTests run: " << totalTests
47 << " - Passes: " << totalTests - totalFailures
48 << " - Failures: " << totalFailures << "\n";
49 printf(message.str().c_str());
50 return totalFailures;