blob: 37515ddf42ab37bf263503ee05cc4a00df4381e8 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
tfarina880914c2014-06-09 12:05:34 -07007
reed@android.comed673312009-02-27 16:24:51 +00008#include "Test.h"
9
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000010#include "SkCommandLineFlags.h"
commit-bot@chromium.org197845a2013-04-19 13:24:28 +000011#include "SkString.h"
commit-bot@chromium.org0506b9d2013-04-22 16:43:07 +000012#include "SkTime.h"
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000013
halcanary96fcdcc2015-08-27 07:41:13 -070014DEFINE_string2(tmpDir, t, nullptr, "Temp directory to use.");
bsalomon@google.coma8e686e2011-08-16 15:45:58 +000015
halcanary87f3ba42015-01-20 09:30:20 -080016void skiatest::Reporter::bumpTestCount() {}
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000017
halcanary87f3ba42015-01-20 09:30:20 -080018bool skiatest::Reporter::allowExtendedTest() const { return false; }
reed@android.comed673312009-02-27 16:24:51 +000019
halcanary87f3ba42015-01-20 09:30:20 -080020bool skiatest::Reporter::verbose() const { return false; }
reed@android.comed673312009-02-27 16:24:51 +000021
halcanary87f3ba42015-01-20 09:30:20 -080022SkString skiatest::Failure::toString() const {
23 SkString result = SkStringPrintf("%s:%d\t", this->fileName, this->lineNo);
24 if (!this->message.isEmpty()) {
25 result.append(this->message);
26 if (strlen(this->condition) > 0) {
27 result.append(": ");
28 }
reed@android.comed673312009-02-27 16:24:51 +000029 }
halcanary87f3ba42015-01-20 09:30:20 -080030 result.append(this->condition);
31 return result;
reed@android.comed673312009-02-27 16:24:51 +000032}
33
halcanary87f3ba42015-01-20 09:30:20 -080034SkString skiatest::GetTmpDir() {
halcanary96fcdcc2015-08-27 07:41:13 -070035 const char* tmpDir = FLAGS_tmpDir.isEmpty() ? nullptr : FLAGS_tmpDir[0];
commit-bot@chromium.org0dc5bd12014-02-26 16:31:22 +000036 return SkString(tmpDir);
djsollen@google.com0945bde2012-11-29 15:28:45 +000037}
benjaminwagnerec4d4d72016-03-25 12:59:53 -070038
39skiatest::Timer::Timer() : fStartNanos(SkTime::GetNSecs()) {}
40
41double skiatest::Timer::elapsedNs() const {
42 return SkTime::GetNSecs() - fStartNanos;
43}
44
45double skiatest::Timer::elapsedMs() const { return this->elapsedNs() * 1e-6; }
46
47SkMSec skiatest::Timer::elapsedMsInt() const {
48 const double elapsedMs = this->elapsedMs();
49 SkASSERT(SK_MSecMax >= elapsedMs);
50 return static_cast<SkMSec>(elapsedMs);
51}