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

Side by Side Diff: chrome/browser/diagnostics/diagnostics_controller_unittest.cc

Issue 684613002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/diagnostics/diagnostics_controller.h" 5 #include "chrome/browser/diagnostics/diagnostics_controller.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "chrome/browser/diagnostics/diagnostics_model.h" 13 #include "chrome/browser/diagnostics/diagnostics_model.h"
14 #include "chrome/browser/diagnostics/diagnostics_writer.h" 14 #include "chrome/browser/diagnostics/diagnostics_writer.h"
15 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" 15 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
16 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chromeos/chromeos_constants.h" 18 #include "chromeos/chromeos_constants.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace diagnostics { 21 namespace diagnostics {
22 22
23 // Basic harness to acquire and release the required temporary environment to 23 // Basic harness to acquire and release the required temporary environment to
24 // run a test in. 24 // run a test in.
25 class DiagnosticsControllerTest : public testing::Test { 25 class DiagnosticsControllerTest : public testing::Test {
26 protected: 26 protected:
27 DiagnosticsControllerTest() : cmdline_(CommandLine::NO_PROGRAM) {} 27 DiagnosticsControllerTest() : cmdline_(CommandLine::NO_PROGRAM) {}
28 28
29 virtual ~DiagnosticsControllerTest() {} 29 ~DiagnosticsControllerTest() override {}
30 30
31 virtual void SetUp() { 31 void SetUp() override {
32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
33 base::FilePath test_data; 33 base::FilePath test_data;
34 PathService::Get(chrome::DIR_TEST_DATA, &test_data); 34 PathService::Get(chrome::DIR_TEST_DATA, &test_data);
35 test_data = test_data.Append(FILE_PATH_LITERAL("diagnostics")); 35 test_data = test_data.Append(FILE_PATH_LITERAL("diagnostics"));
36 test_data = test_data.Append(FILE_PATH_LITERAL("user")); 36 test_data = test_data.Append(FILE_PATH_LITERAL("user"));
37 base::CopyDirectory(test_data, temp_dir_.path(), true); 37 base::CopyDirectory(test_data, temp_dir_.path(), true);
38 profile_dir_ = temp_dir_.path().Append(FILE_PATH_LITERAL("user")); 38 profile_dir_ = temp_dir_.path().Append(FILE_PATH_LITERAL("user"));
39 39
40 #if defined(OS_CHROMEOS) 40 #if defined(OS_CHROMEOS)
41 // Redirect the home dir to the profile directory. We have to do this 41 // Redirect the home dir to the profile directory. We have to do this
42 // because NSS uses the HOME directory to find where to store it's database, 42 // because NSS uses the HOME directory to find where to store it's database,
43 // so that's where the diagnostics and recovery code looks for it. 43 // so that's where the diagnostics and recovery code looks for it.
44 PathService::Get(base::DIR_HOME, &old_home_dir_); 44 PathService::Get(base::DIR_HOME, &old_home_dir_);
45 PathService::Override(base::DIR_HOME, profile_dir_); 45 PathService::Override(base::DIR_HOME, profile_dir_);
46 #endif 46 #endif
47 47
48 cmdline_ = CommandLine(CommandLine::NO_PROGRAM); 48 cmdline_ = CommandLine(CommandLine::NO_PROGRAM);
49 cmdline_.AppendSwitchPath(switches::kUserDataDir, profile_dir_); 49 cmdline_.AppendSwitchPath(switches::kUserDataDir, profile_dir_);
50 cmdline_.AppendSwitch(switches::kDiagnostics); 50 cmdline_.AppendSwitch(switches::kDiagnostics);
51 cmdline_.AppendSwitch(switches::kDiagnosticsRecovery); 51 cmdline_.AppendSwitch(switches::kDiagnosticsRecovery);
52 writer_.reset(); 52 writer_.reset();
53 // Use this writer instead, if you want to see the diagnostics output. 53 // Use this writer instead, if you want to see the diagnostics output.
54 // writer_.reset(new DiagnosticsWriter(DiagnosticsWriter::MACHINE)); 54 // writer_.reset(new DiagnosticsWriter(DiagnosticsWriter::MACHINE));
55 } 55 }
56 56
57 virtual void TearDown() { 57 void TearDown() override {
58 DiagnosticsController::GetInstance()->ClearResults(); 58 DiagnosticsController::GetInstance()->ClearResults();
59 #if defined(OS_CHROMEOS) 59 #if defined(OS_CHROMEOS)
60 PathService::Override(base::DIR_HOME, old_home_dir_); 60 PathService::Override(base::DIR_HOME, old_home_dir_);
61 old_home_dir_.clear(); 61 old_home_dir_.clear();
62 #endif 62 #endif
63 } 63 }
64 64
65 void CorruptDataFile(const base::FilePath& path) { 65 void CorruptDataFile(const base::FilePath& path) {
66 // Just write some random characters into the file tInvaludUsero "corrupt" 66 // Just write some random characters into the file tInvaludUsero "corrupt"
67 // it. 67 // it.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 EXPECT_EQ(DiagnosticsModel::TEST_FAIL_CONTINUE, info->GetResult()); 151 EXPECT_EQ(DiagnosticsModel::TEST_FAIL_CONTINUE, info->GetResult());
152 EXPECT_EQ(DIAG_SQLITE_ERROR_HANDLER_CALLED, info->GetOutcomeCode()); 152 EXPECT_EQ(DIAG_SQLITE_ERROR_HANDLER_CALLED, info->GetOutcomeCode());
153 153
154 DiagnosticsController::GetInstance()->RunRecovery(cmdline_, writer_.get()); 154 DiagnosticsController::GetInstance()->RunRecovery(cmdline_, writer_.get());
155 EXPECT_EQ(DiagnosticsModel::RECOVERY_OK, info->GetResult()); 155 EXPECT_EQ(DiagnosticsModel::RECOVERY_OK, info->GetResult());
156 EXPECT_FALSE(base::PathExists(db_path)); 156 EXPECT_FALSE(base::PathExists(db_path));
157 } 157 }
158 #endif 158 #endif
159 159
160 } // namespace diagnostics 160 } // namespace diagnostics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698