Add PerformanceResult class
[platform/core/test/security-tests.git] / src / framework / src / test_results_collector_console.cpp
index 9ad0c04..2c3a737 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
  *    you may not use this file except in compliance with the License.
@@ -73,9 +73,7 @@ void ConsoleCollector::Finish()
 void ConsoleCollector::CollectResult(const std::string& id,
                                      const FailStatus status,
                                      const std::string& reason,
-                                     const bool& isPerformanceTest,
-                                     const std::chrono::system_clock::duration& performanceTime,
-                                     const std::chrono::system_clock::duration& performanceMaxTime)
+                                     const ConstPerformanceResultPtr &performanceResult)
 {
     using namespace DPL::Colors::Text;
     std::string tmp = "'" + id + "' ...";
@@ -83,25 +81,24 @@ void ConsoleCollector::CollectResult(const std::string& id,
     printf("Running test case %-60s", tmp.c_str());
     switch (status) {
     case FailStatus::NONE:
-        if (isPerformanceTest) {
-            if (performanceMaxTime <= std::chrono::microseconds::zero()) {
-                printf(GREEN_RESULT_OK_TIME,
-                        get_milliseconds(performanceTime));
-                break;
-            }
-            else {
-                if (performanceTime > performanceMaxTime)
-                    printf(GREEN_RESULT_OK_TIME_TOO_LONG(
-                            get_milliseconds(performanceTime),
-                            get_milliseconds(performanceMaxTime)));
-                else
-                    printf(GREEN_RESULT_OK_TIME_MAX(
-                            get_milliseconds(performanceTime),
-                            get_milliseconds(performanceMaxTime)));
-                break;
-            }
+        if (!performanceResult) {
+            printf(GREEN_RESULT_OK);
+            break;
         }
-        printf(GREEN_RESULT_OK);
+        if (!performanceResult->IsMaxDuration()) {
+            printf(GREEN_RESULT_OK_TIME,
+                   get_milliseconds(performanceResult->GetDuration()));
+            break;
+        }
+        if (!performanceResult->IsDurationOk()) {
+            printf(GREEN_RESULT_OK_TIME_TOO_LONG(
+                       get_milliseconds(performanceResult->GetDuration()),
+                       get_milliseconds(performanceResult->GetMaxDuration())));
+            break;
+        }
+        printf(GREEN_RESULT_OK_TIME_MAX(
+                   get_milliseconds(performanceResult->GetDuration()),
+                   get_milliseconds(performanceResult->GetMaxDuration())));
         break;
     case FailStatus::FAILED:
         PrintfErrorMessage(" FAILED ", reason);