OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_main.h" | 5 #include "chrome/browser/diagnostics/diagnostics_main.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // How many tests reported failure. | 209 // How many tests reported failure. |
210 int failures() { return failures_; } | 210 int failures() { return failures_; } |
211 | 211 |
212 // Write an informational line of text in white over black. | 212 // Write an informational line of text in white over black. |
213 bool WriteInfoText(const std::wstring& txt) { | 213 bool WriteInfoText(const std::wstring& txt) { |
214 console_->SetColor(SimpleConsole::DEFAULT); | 214 console_->SetColor(SimpleConsole::DEFAULT); |
215 return console_->Write(txt); | 215 return console_->Write(txt); |
216 } | 216 } |
217 | 217 |
218 bool WriteInfoText(const std::string& txt) { | 218 bool WriteInfoText(const std::string& txt) { |
219 return WriteInfoText(UTF8ToWide(txt)); | 219 return WriteInfoText(base::UTF8ToWide(txt)); |
220 } | 220 } |
221 | 221 |
222 // Write a result block. It consist of two lines. The first line | 222 // Write a result block. It consist of two lines. The first line |
223 // has [PASS] or [FAIL] with |name| and the second line has | 223 // has [PASS] or [FAIL] with |name| and the second line has |
224 // the text in |extra|. | 224 // the text in |extra|. |
225 bool WriteResult(bool success, const std::wstring& name, | 225 bool WriteResult(bool success, const std::wstring& name, |
226 const std::wstring& extra) { | 226 const std::wstring& extra) { |
227 if (success) { | 227 if (success) { |
228 console_->SetColor(SimpleConsole::GREEN); | 228 console_->SetColor(SimpleConsole::GREEN); |
229 console_->Write(L"[PASS] "); | 229 console_->Write(L"[PASS] "); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 writer_->WriteInfoText(base::StringPrintf( | 311 writer_->WriteInfoText(base::StringPrintf( |
312 "DONE. %d failure(s)\n\n", writer_->failures())); | 312 "DONE. %d failure(s)\n\n", writer_->failures())); |
313 } else { | 313 } else { |
314 writer_->WriteInfoText(L"DONE\n\n"); | 314 writer_->WriteInfoText(L"DONE\n\n"); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 private: | 318 private: |
319 void ShowResult(DiagnosticsModel::TestInfo* test_info) { | 319 void ShowResult(DiagnosticsModel::TestInfo* test_info) { |
320 bool success = (DiagnosticsModel::TEST_OK == test_info->GetResult()); | 320 bool success = (DiagnosticsModel::TEST_OK == test_info->GetResult()); |
321 writer_->WriteResult(success, UTF16ToWide(test_info->GetTitle()), | 321 writer_->WriteResult(success, base::UTF16ToWide(test_info->GetTitle()), |
322 UTF16ToWide(test_info->GetAdditionalInfo())); | 322 base::UTF16ToWide(test_info->GetAdditionalInfo())); |
323 } | 323 } |
324 | 324 |
325 DiagnosticsModel* model_; | 325 DiagnosticsModel* model_; |
326 TestWriter* writer_; | 326 TestWriter* writer_; |
327 | 327 |
328 DISALLOW_COPY_AND_ASSIGN(TestController); | 328 DISALLOW_COPY_AND_ASSIGN(TestController); |
329 }; | 329 }; |
330 } // namespace | 330 } // namespace |
331 | 331 |
332 // This entry point is called from ChromeMain() when very few things | 332 // This entry point is called from ChromeMain() when very few things |
(...skipping 25 matching lines...) Expand all Loading... |
358 TestController controller(&writer); | 358 TestController controller(&writer); |
359 | 359 |
360 // Run all the diagnostic tests. | 360 // Run all the diagnostic tests. |
361 controller.Run(model); | 361 controller.Run(model); |
362 delete model; | 362 delete model; |
363 | 363 |
364 console->OnQuit(); | 364 console->OnQuit(); |
365 delete console; | 365 delete console; |
366 return 0; | 366 return 0; |
367 } | 367 } |
OLD | NEW |