• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
7 
8 #include "Test.h"
9 
10 #include "SkCommandLineFlags.h"
11 #include "SkString.h"
12 #include "SkTime.h"
13 
14 DEFINE_string2(tmpDir, t, nullptr, "Temp directory to use.");
15 
bumpTestCount()16 void skiatest::Reporter::bumpTestCount() {}
17 
allowExtendedTest() const18 bool skiatest::Reporter::allowExtendedTest() const { return false; }
19 
verbose() const20 bool skiatest::Reporter::verbose() const { return false; }
21 
toString() const22 SkString 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         }
29     }
30     result.append(this->condition);
31     return result;
32 }
33 
GetTmpDir()34 SkString skiatest::GetTmpDir() {
35     const char* tmpDir = FLAGS_tmpDir.isEmpty() ? nullptr : FLAGS_tmpDir[0];
36     return SkString(tmpDir);
37 }
38 
Timer()39 skiatest::Timer::Timer() : fStartNanos(SkTime::GetNSecs()) {}
40 
elapsedNs() const41 double skiatest::Timer::elapsedNs() const {
42     return SkTime::GetNSecs() - fStartNanos;
43 }
44 
elapsedMs() const45 double skiatest::Timer::elapsedMs() const { return this->elapsedNs() * 1e-6; }
46 
elapsedMsInt() const47 SkMSec skiatest::Timer::elapsedMsInt() const {
48     const double elapsedMs = this->elapsedMs();
49     SkASSERT(SK_MSecMax >= elapsedMs);
50     return static_cast<SkMSec>(elapsedMs);
51 }
52