| 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 #include "chrome/browser/diagnostics/diagnostics_model.h" | 5 #include "chrome/browser/diagnostics/diagnostics_model.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace diagnostics { | 12 namespace diagnostics { |
| 13 | 13 |
| 14 // Basic harness to acquire and release the Diagnostic model object. | 14 // Basic harness to acquire and release the Diagnostic model object. |
| 15 class DiagnosticsModelTest : public testing::Test { | 15 class DiagnosticsModelTest : public testing::Test { |
| 16 protected: | 16 protected: |
| 17 DiagnosticsModelTest() | 17 DiagnosticsModelTest() : cmdline_(base::CommandLine::NO_PROGRAM) {} |
| 18 : cmdline_(CommandLine::NO_PROGRAM) { | |
| 19 } | |
| 20 | 18 |
| 21 ~DiagnosticsModelTest() override {} | 19 ~DiagnosticsModelTest() override {} |
| 22 | 20 |
| 23 void SetUp() override { | 21 void SetUp() override { |
| 24 model_.reset(MakeDiagnosticsModel(cmdline_)); | 22 model_.reset(MakeDiagnosticsModel(cmdline_)); |
| 25 ASSERT_TRUE(model_.get() != NULL); | 23 ASSERT_TRUE(model_.get() != NULL); |
| 26 } | 24 } |
| 27 | 25 |
| 28 void TearDown() override { model_.reset(); } | 26 void TearDown() override { model_.reset(); } |
| 29 | 27 |
| 30 scoped_ptr<DiagnosticsModel> model_; | 28 scoped_ptr<DiagnosticsModel> model_; |
| 31 CommandLine cmdline_; | 29 base::CommandLine cmdline_; |
| 32 | 30 |
| 33 DISALLOW_COPY_AND_ASSIGN(DiagnosticsModelTest); | 31 DISALLOW_COPY_AND_ASSIGN(DiagnosticsModelTest); |
| 34 }; | 32 }; |
| 35 | 33 |
| 36 // The test observer is used to know if the callbacks are being called. | 34 // The test observer is used to know if the callbacks are being called. |
| 37 class UTObserver: public DiagnosticsModel::Observer { | 35 class UTObserver: public DiagnosticsModel::Observer { |
| 38 public: | 36 public: |
| 39 UTObserver() | 37 UTObserver() |
| 40 : tests_done_(false), | 38 : tests_done_(false), |
| 41 recovery_done_(false), | 39 recovery_done_(false), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 EXPECT_TRUE(observer.tests_done()); | 99 EXPECT_TRUE(observer.tests_done()); |
| 102 EXPECT_FALSE(observer.recovery_done()); | 100 EXPECT_FALSE(observer.recovery_done()); |
| 103 model_->RecoverAll(&observer); | 101 model_->RecoverAll(&observer); |
| 104 EXPECT_TRUE(observer.recovery_done()); | 102 EXPECT_TRUE(observer.recovery_done()); |
| 105 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, model_->GetTestRunCount()); | 103 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, model_->GetTestRunCount()); |
| 106 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, observer.num_tested()); | 104 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, observer.num_tested()); |
| 107 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, observer.num_recovered()); | 105 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, observer.num_recovered()); |
| 108 } | 106 } |
| 109 | 107 |
| 110 } // namespace diagnostics | 108 } // namespace diagnostics |
| OLD | NEW |