| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 class ResourceChangeObserver : public TaskManagerModelObserver { | 28 class ResourceChangeObserver : public TaskManagerModelObserver { |
| 29 public: | 29 public: |
| 30 ResourceChangeObserver(const TaskManagerModel* model, | 30 ResourceChangeObserver(const TaskManagerModel* model, |
| 31 int required_count, | 31 int required_count, |
| 32 const base::string16& title_pattern) | 32 const base::string16& title_pattern) |
| 33 : model_(model), | 33 : model_(model), |
| 34 required_count_(required_count), | 34 required_count_(required_count), |
| 35 title_pattern_(title_pattern) {} | 35 title_pattern_(title_pattern) {} |
| 36 | 36 |
| 37 virtual void OnModelChanged() override { | 37 void OnModelChanged() override { OnResourceChange(); } |
| 38 OnResourceChange(); | |
| 39 } | |
| 40 | 38 |
| 41 virtual void OnItemsChanged(int start, int length) override { | 39 void OnItemsChanged(int start, int length) override { OnResourceChange(); } |
| 42 OnResourceChange(); | |
| 43 } | |
| 44 | 40 |
| 45 virtual void OnItemsAdded(int start, int length) override { | 41 void OnItemsAdded(int start, int length) override { OnResourceChange(); } |
| 46 OnResourceChange(); | |
| 47 } | |
| 48 | 42 |
| 49 virtual void OnItemsRemoved(int start, int length) override { | 43 void OnItemsRemoved(int start, int length) override { OnResourceChange(); } |
| 50 OnResourceChange(); | |
| 51 } | |
| 52 | 44 |
| 53 void RunUntilSatisfied() { | 45 void RunUntilSatisfied() { |
| 54 // See if the condition is satisfied without having to run the loop. This | 46 // See if the condition is satisfied without having to run the loop. This |
| 55 // check has to be placed after the installation of the | 47 // check has to be placed after the installation of the |
| 56 // TaskManagerModelObserver, because resources may change before that. | 48 // TaskManagerModelObserver, because resources may change before that. |
| 57 if (IsSatisfied()) | 49 if (IsSatisfied()) |
| 58 return; | 50 return; |
| 59 | 51 |
| 60 timer_.Start(FROM_HERE, | 52 timer_.Start(FROM_HERE, |
| 61 TestTimeouts::action_timeout(), | 53 TestTimeouts::action_timeout(), |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 179 |
| 188 base::string16 MatchPrint(const char* title) { | 180 base::string16 MatchPrint(const char* title) { |
| 189 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRINT_PREFIX, | 181 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRINT_PREFIX, |
| 190 base::ASCIIToUTF16(title)); | 182 base::ASCIIToUTF16(title)); |
| 191 } | 183 } |
| 192 | 184 |
| 193 base::string16 MatchAnyPrint() { return MatchPrint("*"); } | 185 base::string16 MatchAnyPrint() { return MatchPrint("*"); } |
| 194 | 186 |
| 195 } // namespace browsertest_util | 187 } // namespace browsertest_util |
| 196 } // namespace task_manager | 188 } // namespace task_manager |
| OLD | NEW |