blob: 4e6e02018bce647af5de11835d179c25a820d0f1 [file] [log] [blame]
[email protected]d778d6e2011-08-12 09:47:051// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]e4be2dd2010-12-14 00:44:392// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/diagnostics/diagnostics_test.h"
6
[email protected]57999812013-02-24 05:40:527#include "base/files/file_path.h"
[email protected]e4be2dd2010-12-14 00:44:398#include "base/path_service.h"
9#include "chrome/common/chrome_constants.h"
10#include "chrome/common/chrome_paths.h"
11
[email protected]f22fae42013-07-09 21:11:1112namespace diagnostics {
[email protected]e4be2dd2010-12-14 00:44:3913
[email protected]f22fae42013-07-09 21:11:1114DiagnosticsTest::DiagnosticsTest(const std::string& id,
15 const std::string& title)
16 : id_(id),
17 title_(title),
18 outcome_code_(-1),
19 result_(DiagnosticsModel::TEST_NOT_RUN) {}
[email protected]e4be2dd2010-12-14 00:44:3920
[email protected]f22fae42013-07-09 21:11:1121DiagnosticsTest::~DiagnosticsTest() {}
22
23bool DiagnosticsTest::Execute(DiagnosticsModel::Observer* observer,
24 DiagnosticsModel* model,
25 size_t index) {
26 start_time_ = base::Time::Now();
[email protected]e4be2dd2010-12-14 00:44:3927 result_ = DiagnosticsModel::TEST_RUNNING;
[email protected]e4be2dd2010-12-14 00:44:3928 bool keep_going = ExecuteImpl(observer);
[email protected]f22fae42013-07-09 21:11:1129 if (observer)
[email protected]60756be2013-08-07 05:20:2630 observer->OnTestFinished(index, model);
31 return keep_going;
32}
33
34bool DiagnosticsTest::Recover(DiagnosticsModel::Observer* observer,
35 DiagnosticsModel* model,
36 size_t index) {
37 result_ = DiagnosticsModel::RECOVERY_RUNNING;
38 bool keep_going = RecoveryImpl(observer);
39 result_ = keep_going ? DiagnosticsModel::RECOVERY_OK
40 : DiagnosticsModel::RECOVERY_FAIL_STOP;
41 if (observer)
42 observer->OnRecoveryFinished(index, model);
[email protected]e4be2dd2010-12-14 00:44:3943 return keep_going;
44}
45
[email protected]f22fae42013-07-09 21:11:1146void DiagnosticsTest::RecordOutcome(int outcome_code,
47 const std::string& additional_info,
48 DiagnosticsModel::TestResult result) {
49 end_time_ = base::Time::Now();
50 outcome_code_ = outcome_code;
[email protected]e4be2dd2010-12-14 00:44:3951 additional_info_ = additional_info;
52 result_ = result;
53}
54
55// static
[email protected]f22fae42013-07-09 21:11:1156base::FilePath DiagnosticsTest::GetUserDefaultProfileDir() {
[email protected]650b2d52013-02-10 03:41:4557 base::FilePath path;
[email protected]e4be2dd2010-12-14 00:44:3958 if (!PathService::Get(chrome::DIR_USER_DATA, &path))
[email protected]650b2d52013-02-10 03:41:4559 return base::FilePath();
[email protected]d778d6e2011-08-12 09:47:0560 return path.AppendASCII(chrome::kInitialProfile);
[email protected]e4be2dd2010-12-14 00:44:3961}
[email protected]f22fae42013-07-09 21:11:1162
63std::string DiagnosticsTest::GetId() const { return id_; }
64
65std::string DiagnosticsTest::GetTitle() const { return title_; }
66
67DiagnosticsModel::TestResult DiagnosticsTest::GetResult() const {
68 return result_;
69}
70
71int DiagnosticsTest::GetOutcomeCode() const { return outcome_code_; }
72
73std::string DiagnosticsTest::GetAdditionalInfo() const {
74 return additional_info_;
75}
76
77base::Time DiagnosticsTest::GetStartTime() const { return start_time_; }
78
79base::Time DiagnosticsTest::GetEndTime() const { return end_time_; }
80
[email protected]60756be2013-08-07 05:20:2681bool DiagnosticsTest::RecoveryImpl(DiagnosticsModel::Observer* observer) {
82 return true;
83};
84
85
[email protected]f22fae42013-07-09 21:11:1186} // namespace diagnostics