| 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" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // The test observer is used to know if the callbacks are being called. | 38 // The test observer is used to know if the callbacks are being called. |
| 39 class UTObserver: public DiagnosticsModel::Observer { | 39 class UTObserver: public DiagnosticsModel::Observer { |
| 40 public: | 40 public: |
| 41 UTObserver() | 41 UTObserver() |
| 42 : tests_done_(false), | 42 : tests_done_(false), |
| 43 recovery_done_(false), | 43 recovery_done_(false), |
| 44 num_tested_(0), | 44 num_tested_(0), |
| 45 num_recovered_(0) { | 45 num_recovered_(0) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual void OnTestFinished(int index, DiagnosticsModel* model) override { | 48 void OnTestFinished(int index, DiagnosticsModel* model) override { |
| 49 EXPECT_TRUE(model != NULL); | 49 EXPECT_TRUE(model != NULL); |
| 50 ++num_tested_; | 50 ++num_tested_; |
| 51 EXPECT_NE(DiagnosticsModel::TEST_FAIL_STOP, | 51 EXPECT_NE(DiagnosticsModel::TEST_FAIL_STOP, |
| 52 model->GetTest(index).GetResult()) | 52 model->GetTest(index).GetResult()) |
| 53 << "Failed stop test: " << index; | 53 << "Failed stop test: " << index; |
| 54 } | 54 } |
| 55 | 55 |
| 56 virtual void OnAllTestsDone(DiagnosticsModel* model) override { | 56 void OnAllTestsDone(DiagnosticsModel* model) override { |
| 57 EXPECT_TRUE(model != NULL); | 57 EXPECT_TRUE(model != NULL); |
| 58 tests_done_ = true; | 58 tests_done_ = true; |
| 59 } | 59 } |
| 60 | 60 |
| 61 virtual void OnRecoveryFinished(int index, DiagnosticsModel* model) override { | 61 void OnRecoveryFinished(int index, DiagnosticsModel* model) override { |
| 62 EXPECT_TRUE(model != NULL); | 62 EXPECT_TRUE(model != NULL); |
| 63 ++num_recovered_; | 63 ++num_recovered_; |
| 64 EXPECT_NE(DiagnosticsModel::RECOVERY_FAIL_STOP, | 64 EXPECT_NE(DiagnosticsModel::RECOVERY_FAIL_STOP, |
| 65 model->GetTest(index).GetResult()) | 65 model->GetTest(index).GetResult()) |
| 66 << "Failed stop recovery: " << index; | 66 << "Failed stop recovery: " << index; |
| 67 } | 67 } |
| 68 | 68 |
| 69 virtual void OnAllRecoveryDone(DiagnosticsModel* model) override { | 69 void OnAllRecoveryDone(DiagnosticsModel* model) override { |
| 70 EXPECT_TRUE(model != NULL); | 70 EXPECT_TRUE(model != NULL); |
| 71 recovery_done_ = true; | 71 recovery_done_ = true; |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool tests_done() const { return tests_done_; } | 74 bool tests_done() const { return tests_done_; } |
| 75 bool recovery_done() const { return recovery_done_; } | 75 bool recovery_done() const { return recovery_done_; } |
| 76 | 76 |
| 77 int num_tested() const { return num_tested_;} | 77 int num_tested() const { return num_tested_;} |
| 78 int num_recovered() const { return num_recovered_;} | 78 int num_recovered() const { return num_recovered_;} |
| 79 | 79 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 103 EXPECT_TRUE(observer.tests_done()); | 103 EXPECT_TRUE(observer.tests_done()); |
| 104 EXPECT_FALSE(observer.recovery_done()); | 104 EXPECT_FALSE(observer.recovery_done()); |
| 105 model_->RecoverAll(&observer); | 105 model_->RecoverAll(&observer); |
| 106 EXPECT_TRUE(observer.recovery_done()); | 106 EXPECT_TRUE(observer.recovery_done()); |
| 107 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, model_->GetTestRunCount()); | 107 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, model_->GetTestRunCount()); |
| 108 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, observer.num_tested()); | 108 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, observer.num_tested()); |
| 109 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, observer.num_recovered()); | 109 EXPECT_EQ(DiagnosticsModel::kDiagnosticsTestCount, observer.num_recovered()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace diagnostics | 112 } // namespace diagnostics |
| OLD | NEW |