| 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/task_manager/task_manager_browsertest_util.h" | 5 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 void OnTimeout() { | 110 void OnTimeout() { |
| 111 base::MessageLoop::current()->PostTask(FROM_HERE, run_loop_.QuitClosure()); | 111 base::MessageLoop::current()->PostTask(FROM_HERE, run_loop_.QuitClosure()); |
| 112 FAIL() << "Timed out.\n" << DumpTaskManagerModel(); | 112 FAIL() << "Timed out.\n" << DumpTaskManagerModel(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 testing::Message DumpTaskManagerModel() { | 115 testing::Message DumpTaskManagerModel() { |
| 116 testing::Message task_manager_state_dump; | 116 testing::Message task_manager_state_dump; |
| 117 task_manager_state_dump << "Waiting for exactly " << required_count_ | 117 task_manager_state_dump << "Waiting for exactly " << required_count_ |
| 118 << " matches of wildcard pattern \"" | 118 << " matches of wildcard pattern \"" |
| 119 << UTF16ToASCII(title_pattern_) << "\"\n"; | 119 << base::UTF16ToASCII(title_pattern_) << "\"\n"; |
| 120 task_manager_state_dump << "Currently there are " << CountMatches() | 120 task_manager_state_dump << "Currently there are " << CountMatches() |
| 121 << " matches.\n"; | 121 << " matches.\n"; |
| 122 task_manager_state_dump << "Current Task Manager Model is:\n"; | 122 task_manager_state_dump << "Current Task Manager Model is:\n"; |
| 123 for (int i = 0; i < model_->ResourceCount(); i++) { | 123 for (int i = 0; i < model_->ResourceCount(); i++) { |
| 124 task_manager_state_dump | 124 task_manager_state_dump |
| 125 << " > " << UTF16ToASCII(model_->GetResourceTitle(i)) << "\n"; | 125 << " > " << base::UTF16ToASCII(model_->GetResourceTitle(i)) << "\n"; |
| 126 } | 126 } |
| 127 return task_manager_state_dump; | 127 return task_manager_state_dump; |
| 128 } | 128 } |
| 129 | 129 |
| 130 const TaskManagerModel* model_; | 130 const TaskManagerModel* model_; |
| 131 const int required_count_; | 131 const int required_count_; |
| 132 const base::string16 title_pattern_; | 132 const base::string16 title_pattern_; |
| 133 base::RunLoop run_loop_; | 133 base::RunLoop run_loop_; |
| 134 base::OneShotTimer<ResourceChangeObserver> timer_; | 134 base::OneShotTimer<ResourceChangeObserver> timer_; |
| 135 }; | 135 }; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 base::string16 MatchAnyWebView() { return MatchWebView("*"); } | 177 base::string16 MatchAnyWebView() { return MatchWebView("*"); } |
| 178 | 178 |
| 179 base::string16 MatchBackground(const char* title) { | 179 base::string16 MatchBackground(const char* title) { |
| 180 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, | 180 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_BACKGROUND_PREFIX, |
| 181 base::ASCIIToUTF16(title)); | 181 base::ASCIIToUTF16(title)); |
| 182 } | 182 } |
| 183 base::string16 MatchAnyBackground() { return MatchBackground("*"); } | 183 base::string16 MatchAnyBackground() { return MatchBackground("*"); } |
| 184 | 184 |
| 185 } // namespace browsertest_util | 185 } // namespace browsertest_util |
| 186 } // namespace task_manager | 186 } // namespace task_manager |
| OLD | NEW |