epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 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 | */ |
tfarina | 880914c | 2014-06-09 12:05:34 -0700 | [diff] [blame] | 7 | |
reed@android.com | ed67331 | 2009-02-27 16:24:51 +0000 | [diff] [blame] | 8 | #include "Test.h" |
| 9 | |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 10 | #include "SkCommandLineFlags.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 11 | #include "SkError.h" |
commit-bot@chromium.org | 197845a | 2013-04-19 13:24:28 +0000 | [diff] [blame] | 12 | #include "SkString.h" |
commit-bot@chromium.org | 0506b9d | 2013-04-22 16:43:07 +0000 | [diff] [blame] | 13 | #include "SkTime.h" |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 14 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 15 | DEFINE_string2(tmpDir, t, nullptr, "Temp directory to use."); |
bsalomon@google.com | a8e686e | 2011-08-16 15:45:58 +0000 | [diff] [blame] | 16 | |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 17 | void skiatest::Reporter::bumpTestCount() {} |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 18 | |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 19 | bool skiatest::Reporter::allowExtendedTest() const { return false; } |
reed@android.com | ed67331 | 2009-02-27 16:24:51 +0000 | [diff] [blame] | 20 | |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 21 | bool skiatest::Reporter::verbose() const { return false; } |
reed@android.com | ed67331 | 2009-02-27 16:24:51 +0000 | [diff] [blame] | 22 | |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 23 | SkString skiatest::Failure::toString() const { |
| 24 | SkString result = SkStringPrintf("%s:%d\t", this->fileName, this->lineNo); |
| 25 | if (!this->message.isEmpty()) { |
| 26 | result.append(this->message); |
| 27 | if (strlen(this->condition) > 0) { |
| 28 | result.append(": "); |
| 29 | } |
reed@android.com | ed67331 | 2009-02-27 16:24:51 +0000 | [diff] [blame] | 30 | } |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 31 | result.append(this->condition); |
| 32 | return result; |
reed@android.com | ed67331 | 2009-02-27 16:24:51 +0000 | [diff] [blame] | 33 | } |
| 34 | |
halcanary | 87f3ba4 | 2015-01-20 09:30:20 -0800 | [diff] [blame] | 35 | SkString skiatest::GetTmpDir() { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 36 | const char* tmpDir = FLAGS_tmpDir.isEmpty() ? nullptr : FLAGS_tmpDir[0]; |
commit-bot@chromium.org | 0dc5bd1 | 2014-02-26 16:31:22 +0000 | [diff] [blame] | 37 | return SkString(tmpDir); |
djsollen@google.com | 0945bde | 2012-11-29 15:28:45 +0000 | [diff] [blame] | 38 | } |
benjaminwagner | ec4d4d7 | 2016-03-25 12:59:53 -0700 | [diff] [blame] | 39 | |
| 40 | skiatest::Timer::Timer() : fStartNanos(SkTime::GetNSecs()) {} |
| 41 | |
| 42 | double skiatest::Timer::elapsedNs() const { |
| 43 | return SkTime::GetNSecs() - fStartNanos; |
| 44 | } |
| 45 | |
| 46 | double skiatest::Timer::elapsedMs() const { return this->elapsedNs() * 1e-6; } |
| 47 | |
| 48 | SkMSec skiatest::Timer::elapsedMsInt() const { |
| 49 | const double elapsedMs = this->elapsedMs(); |
| 50 | SkASSERT(SK_MSecMax >= elapsedMs); |
| 51 | return static_cast<SkMSec>(elapsedMs); |
| 52 | } |