| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_ | 5 #ifndef CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_ |
| 6 #define CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_ | 6 #define CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" |
| 9 #include "base/string16.h" | 10 #include "base/string16.h" |
| 10 #include "chrome/browser/diagnostics/diagnostics_model.h" | 11 #include "chrome/browser/diagnostics/diagnostics_model.h" |
| 11 | 12 |
| 12 class FilePath; | 13 class FilePath; |
| 13 | 14 |
| 14 // Represents a single diagnostic test and encapsulates the common | 15 // Represents a single diagnostic test and encapsulates the common |
| 15 // functionality across platforms as well. | 16 // functionality across platforms as well. |
| 16 // It also Implements the TestInfo interface providing the storage | 17 // It also Implements the TestInfo interface providing the storage |
| 17 // for the outcome of the test. | 18 // for the outcome of the test. |
| 18 // Specific tests need (minimally) only to: | 19 // Specific tests need (minimally) only to: |
| 19 // 1- override ExecuteImpl() to implement the test. | 20 // 1- override ExecuteImpl() to implement the test. |
| 20 // 2- call RecordStopFailure() or RecordFailure() or RecordSuccess() | 21 // 2- call RecordStopFailure() or RecordFailure() or RecordSuccess() |
| 21 // at the end of the test. | 22 // at the end of the test. |
| 22 // 3- Optionally call observer->OnProgress() if the test is long. | 23 // 3- Optionally call observer->OnProgress() if the test is long. |
| 23 // 4- Optionally call observer->OnSkipped() if the test cannot be run. | 24 // 4- Optionally call observer->OnSkipped() if the test cannot be run. |
| 24 class DiagnosticTest : public DiagnosticsModel::TestInfo { | 25 class DiagnosticTest : public DiagnosticsModel::TestInfo { |
| 25 public: | 26 public: |
| 26 // |title| is the human readable, localized string that says that | 27 // |title| is the human readable, localized string that says that |
| 27 // the objective of the test is. | 28 // the objective of the test is. |
| 28 explicit DiagnosticTest(const string16& title); | 29 explicit DiagnosticTest(const string16& title); |
| 29 | 30 |
| 30 virtual ~DiagnosticTest(); | 31 virtual ~DiagnosticTest(); |
| 31 | 32 |
| 32 // Runs the test. Returning false signals that no more tests should be run. | 33 // Runs the test. Returning false signals that no more tests should be run. |
| 33 // The actual outcome of the test should be set using the RecordXX functions. | 34 // The actual outcome of the test should be set using the RecordXX functions. |
| 34 bool Execute(DiagnosticsModel::Observer* observer, DiagnosticsModel* model, | 35 bool Execute(DiagnosticsModel::Observer* observer, DiagnosticsModel* model, |
| 35 size_t index); | 36 size_t index); |
| 36 | 37 |
| 37 virtual string16 GetTitle(); | 38 virtual string16 GetTitle() OVERRIDE; |
| 38 | 39 |
| 39 virtual DiagnosticsModel::TestResult GetResult(); | 40 virtual DiagnosticsModel::TestResult GetResult() OVERRIDE; |
| 40 | 41 |
| 41 virtual string16 GetAdditionalInfo(); | 42 virtual string16 GetAdditionalInfo() OVERRIDE; |
| 42 | 43 |
| 43 void RecordStopFailure(const string16& additional_info) { | 44 void RecordStopFailure(const string16& additional_info) { |
| 44 RecordOutcome(additional_info, DiagnosticsModel::TEST_FAIL_STOP); | 45 RecordOutcome(additional_info, DiagnosticsModel::TEST_FAIL_STOP); |
| 45 } | 46 } |
| 46 | 47 |
| 47 void RecordFailure(const string16& additional_info) { | 48 void RecordFailure(const string16& additional_info) { |
| 48 RecordOutcome(additional_info, DiagnosticsModel::TEST_FAIL_CONTINUE); | 49 RecordOutcome(additional_info, DiagnosticsModel::TEST_FAIL_CONTINUE); |
| 49 } | 50 } |
| 50 | 51 |
| 51 void RecordSuccess(const string16& additional_info) { | 52 void RecordSuccess(const string16& additional_info) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 63 virtual int GetId() = 0; | 64 virtual int GetId() = 0; |
| 64 // Derived classes override this method do perform the actual test. | 65 // Derived classes override this method do perform the actual test. |
| 65 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) = 0; | 66 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) = 0; |
| 66 | 67 |
| 67 string16 title_; | 68 string16 title_; |
| 68 string16 additional_info_; | 69 string16 additional_info_; |
| 69 DiagnosticsModel::TestResult result_; | 70 DiagnosticsModel::TestResult result_; |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 #endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_ | 73 #endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_ |
| OLD | NEW |