Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/browser/diagnostics/diagnostics_test.h

Issue 385144: Introducing the diagnostic model classes... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/diagnostics/diagnostics_model_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_
6 #define CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_
7
8 #include "base/string16.h"
9 #include "chrome/browser/diagnostics/diagnostics_model.h"
10
11 // Represents a single diagnostic test and encapsulates the common
12 // functionality across platforms as well.
13 // It also Implements the TestInfo interface providing the storage
14 // for the outcome of the test.
15 // Specific tests need (minimally) only to:
16 // 1- override ExecuteImpl() to imnplement the test.
17 // 2- call RecordStopFailure() or RecordFailure() or RecordSuccess()
18 // at the end of the test.
19 // 3- Optionally call observer->OnProgress() if the test is long.
20 // 4- Optionally call observer->OnSkipped() if the test cannot be run.
21 class DiagnosticTest : public DiagnosticsModel::TestInfo {
22 public:
23 // |title| is the human readable, localized string that says that
24 // the objective of the test is.
25 explicit DiagnosticTest(const string16& title)
26 : title_(title), result_(DiagnosticsModel::TEST_NOT_RUN) {}
27
28 virtual ~DiagnosticTest() {}
29
30 // Runs the test. Returning false signals that no more tests should be run.
31 // The actual outcome of the test should be set using the RecordXX functions.
32 bool Execute(DiagnosticsModel::Observer* observer, DiagnosticsModel* model) {
33 result_ = DiagnosticsModel::TEST_RUNNING;
34 observer->OnProgress(GetId(), 0, model);
35 return ExecuteImpl(observer);
36 }
37
38 virtual string16 GetTitle() {
39 return title_;
40 }
41
42 virtual DiagnosticsModel::TestResult GetResult() {
43 return result_;
44 }
45
46 virtual string16 GetAdditionalInfo() {
47 return additional_info_;
48 }
49
50 void RecordStopFailure(const string16& additional_info) {
51 RecordOutcome(additional_info, DiagnosticsModel::TEST_FAIL_STOP);
52 }
53
54 void RecordFailure(const string16& additional_info) {
55 RecordOutcome(additional_info, DiagnosticsModel::TEST_FAIL_CONTINUE);
56 }
57
58 void RecordSuccess(const string16& additional_info) {
59 RecordOutcome(additional_info, DiagnosticsModel::TEST_OK);
60 }
61
62 void RecordOutcome(const string16& additional_info,
63 DiagnosticsModel::TestResult result) {
64 additional_info_ = additional_info;
65 result_ = result;
66 }
67
68 protected:
69 // The id needs to be overriden by derived classes and must uniquely
70 // identify this test so other test can refer to it.
71 virtual int GetId() = 0;
72 // Derived classes override this method do perform the actual test.
73 virtual bool ExecuteImpl(DiagnosticsModel::Observer* observer) = 0;
74
75 string16 title_;
76 string16 additional_info_;
77 DiagnosticsModel::TestResult result_;
78 };
79
80 #endif // CHROME_BROWSER_DIAGNOSTICS_DIAGNOSTICS_TEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/diagnostics/diagnostics_model_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698