OLD | NEW |
1 // Copyright (c) 2010 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 "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 // Basic harness to adquire and release the Diagnostic model object. | 10 // Basic harness to adquire and release the Diagnostic model object. |
11 class DiagnosticsModelTest : public testing::Test { | 11 class DiagnosticsModelTest : public testing::Test { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 private: | 72 private: |
73 bool done_; | 73 bool done_; |
74 int progress_called_; | 74 int progress_called_; |
75 int finished_; | 75 int finished_; |
76 int id_of_failed_stop_test; | 76 int id_of_failed_stop_test; |
77 }; | 77 }; |
78 | 78 |
79 // We currently have more tests operational on windows. | 79 // We currently have more tests operational on windows. |
80 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
81 const int kDiagnosticsTestCount = 18; | 81 const int kDiagnosticsTestCount = 19; |
82 #elif defined(OS_MACOSX) | 82 #elif defined(OS_MACOSX) |
83 const int kDiagnosticsTestCount = 16; | 83 const int kDiagnosticsTestCount = 16; |
84 #elif defined(OS_POSIX) | 84 #elif defined(OS_POSIX) |
85 const int kDiagnosticsTestCount = 17; | 85 const int kDiagnosticsTestCount = 17; |
86 #endif | 86 #endif |
87 | 87 |
88 // Test that the initial state is correct. | 88 // Test that the initial state is correct. |
89 TEST_F(DiagnosticsModelTest, BeforeRun) { | 89 TEST_F(DiagnosticsModelTest, BeforeRun) { |
90 int available = model_->GetTestAvailableCount(); | 90 int available = model_->GetTestAvailableCount(); |
91 EXPECT_EQ(kDiagnosticsTestCount, available); | 91 EXPECT_EQ(kDiagnosticsTestCount, available); |
92 EXPECT_EQ(0, model_->GetTestRunCount()); | 92 EXPECT_EQ(0, model_->GetTestRunCount()); |
93 EXPECT_EQ(DiagnosticsModel::TEST_NOT_RUN, model_->GetTest(0).GetResult()); | 93 EXPECT_EQ(DiagnosticsModel::TEST_NOT_RUN, model_->GetTest(0).GetResult()); |
94 } | 94 } |
95 | 95 |
96 // Run all the tests, verify that the basic callbacks are run and that the | 96 // Run all the tests, verify that the basic callbacks are run and that the |
97 // final state is correct. | 97 // final state is correct. |
98 TEST_F(DiagnosticsModelTest, RunAll) { | 98 TEST_F(DiagnosticsModelTest, RunAll) { |
99 UTObserver observer; | 99 UTObserver observer; |
100 EXPECT_FALSE(observer.done()); | 100 EXPECT_FALSE(observer.done()); |
101 model_->RunAll(&observer); | 101 model_->RunAll(&observer); |
102 EXPECT_TRUE(observer.done()); | 102 EXPECT_TRUE(observer.done()); |
103 EXPECT_GT(observer.progress_called(), 0); | 103 EXPECT_GT(observer.progress_called(), 0); |
104 EXPECT_EQ(kDiagnosticsTestCount, model_->GetTestRunCount()); | 104 EXPECT_EQ(kDiagnosticsTestCount, model_->GetTestRunCount()); |
105 EXPECT_EQ(kDiagnosticsTestCount, observer.finished()); | 105 EXPECT_EQ(kDiagnosticsTestCount, observer.finished()); |
106 } | 106 } |
OLD | NEW |