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 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "chrome/browser/diagnostics/diagnostics_metrics.h" | 9 #include "chrome/browser/diagnostics/diagnostics_metrics.h" |
10 #include "chrome/browser/diagnostics/diagnostics_model.h" | 10 #include "chrome/browser/diagnostics/diagnostics_model.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // Specific tests need (minimally) only to: | 22 // Specific tests need (minimally) only to: |
23 // 1- override ExecuteImpl() to implement the test. | 23 // 1- override ExecuteImpl() to implement the test. |
24 // 2- call RecordStopFailure() or RecordFailure() or RecordSuccess() | 24 // 2- call RecordStopFailure() or RecordFailure() or RecordSuccess() |
25 // at the end of the test. | 25 // at the end of the test. |
26 // 3- Optionally call observer->OnProgress() if the test is long. | 26 // 3- Optionally call observer->OnProgress() if the test is long. |
27 // 4- Optionally call observer->OnSkipped() if the test cannot be run. | 27 // 4- Optionally call observer->OnSkipped() if the test cannot be run. |
28 class DiagnosticsTest : public DiagnosticsModel::TestInfo { | 28 class DiagnosticsTest : public DiagnosticsModel::TestInfo { |
29 public: | 29 public: |
30 explicit DiagnosticsTest(DiagnosticsTestId id); | 30 explicit DiagnosticsTest(DiagnosticsTestId id); |
31 | 31 |
32 virtual ~DiagnosticsTest(); | 32 ~DiagnosticsTest() override; |
33 | 33 |
34 // Runs the test. Returning false signals that no more tests should be run. | 34 // Runs the test. Returning false signals that no more tests should be run. |
35 // The actual outcome of the test should be set using the RecordXX functions. | 35 // The actual outcome of the test should be set using the RecordXX functions. |
36 bool Execute(DiagnosticsModel::Observer* observer, DiagnosticsModel* model, | 36 bool Execute(DiagnosticsModel::Observer* observer, DiagnosticsModel* model, |
37 size_t index); | 37 size_t index); |
38 | 38 |
39 // Runs any recovery steps for the test. Returning false signals that no more | 39 // Runs any recovery steps for the test. Returning false signals that no more |
40 // recovery should be attempted. | 40 // recovery should be attempted. |
41 bool Recover(DiagnosticsModel::Observer* observer, DiagnosticsModel* model, | 41 bool Recover(DiagnosticsModel::Observer* observer, DiagnosticsModel* model, |
42 size_t index); | 42 size_t index); |
(...skipping 12 matching lines...) Expand all Loading... |
55 RecordOutcome(0, additional_info, DiagnosticsModel::TEST_OK); | 55 RecordOutcome(0, additional_info, DiagnosticsModel::TEST_OK); |
56 } | 56 } |
57 | 57 |
58 void RecordOutcome(int outcome_code, | 58 void RecordOutcome(int outcome_code, |
59 const std::string& additional_info, | 59 const std::string& additional_info, |
60 DiagnosticsModel::TestResult result); | 60 DiagnosticsModel::TestResult result); |
61 | 61 |
62 static base::FilePath GetUserDefaultProfileDir(); | 62 static base::FilePath GetUserDefaultProfileDir(); |
63 | 63 |
64 // DiagnosticsModel::TestInfo overrides | 64 // DiagnosticsModel::TestInfo overrides |
65 virtual int GetId() const override; | 65 int GetId() const override; |
66 virtual std::string GetName() const override; | 66 std::string GetName() const override; |
67 virtual std::string GetTitle() const override; | 67 std::string GetTitle() const override; |
68 virtual DiagnosticsModel::TestResult GetResult() const override; | 68 DiagnosticsModel::TestResult GetResult() const override; |
69 virtual std::string GetAdditionalInfo() const override; | 69 std::string GetAdditionalInfo() const override; |
70 virtual int GetOutcomeCode() const override; | 70 int GetOutcomeCode() const override; |
71 virtual base::Time GetStartTime() const override; | 71 base::Time GetStartTime() const override; |
72 virtual base::Time GetEndTime() const override; | 72 base::Time GetEndTime() const override; |
| 73 |
73 protected: | 74 protected: |
74 // Derived classes override this method do perform the actual test. | 75 // Derived classes override this method do perform the actual test. |
75 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) = 0; | 76 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) = 0; |
76 | 77 |
77 // Derived classes may override this method to perform a recovery, if recovery | 78 // Derived classes may override this method to perform a recovery, if recovery |
78 // makes sense for the diagnostics test. | 79 // makes sense for the diagnostics test. |
79 virtual bool RecoveryImpl(DiagnosticsModel::Observer* observer); | 80 virtual bool RecoveryImpl(DiagnosticsModel::Observer* observer); |
80 | 81 |
81 const DiagnosticsTestId id_; | 82 const DiagnosticsTestId id_; |
82 std::string additional_info_; | 83 std::string additional_info_; |
83 int outcome_code_; | 84 int outcome_code_; |
84 DiagnosticsModel::TestResult result_; | 85 DiagnosticsModel::TestResult result_; |
85 base::Time start_time_; | 86 base::Time start_time_; |
86 base::Time end_time_; | 87 base::Time end_time_; |
87 }; | 88 }; |
88 | 89 |
89 } // namespace diagnostics | 90 } // namespace diagnostics |
90 #endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_ | 91 #endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_ |
OLD | NEW |