OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 180 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
181 new MessageLoop::QuitTask, 200); | 181 new MessageLoop::QuitTask, 200); |
182 ui_test_utils::RunMessageLoop(); | 182 ui_test_utils::RunMessageLoop(); |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() { | 186 bool ExtensionBrowserTest::WaitForExtensionHostsToLoad() { |
187 // Wait for all the extension hosts that exist to finish loading. | 187 // Wait for all the extension hosts that exist to finish loading. |
188 // NOTE: This assumes that the extension host list is not changing while | |
189 // this method is running. | |
190 | |
191 NotificationRegistrar registrar; | 188 NotificationRegistrar registrar; |
192 registrar.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, | 189 registrar.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, |
193 NotificationService::AllSources()); | 190 NotificationService::AllSources()); |
194 | 191 |
195 ExtensionProcessManager* manager = | 192 ExtensionProcessManager* manager = |
196 browser()->profile()->GetExtensionProcessManager(); | 193 browser()->profile()->GetExtensionProcessManager(); |
197 for (ExtensionProcessManager::const_iterator iter = manager->begin(); | 194 for (ExtensionProcessManager::const_iterator iter = manager->begin(); |
198 iter != manager->end();) { | 195 iter != manager->end();) { |
199 if ((*iter)->did_stop_loading()) | 196 if ((*iter)->did_stop_loading()) { |
200 ++iter; | 197 ++iter; |
201 else | 198 } else { |
202 ui_test_utils::RunMessageLoop(); | 199 ui_test_utils::RunMessageLoop(); |
| 200 |
| 201 // Test activity may have modified the set of extension processes during |
| 202 // message processing, so re-start the iteration to catch added/removed |
| 203 // processes. |
| 204 iter = manager->begin(); |
| 205 } |
203 } | 206 } |
204 LOG(INFO) << "All ExtensionHosts loaded"; | 207 LOG(INFO) << "All ExtensionHosts loaded"; |
205 | 208 |
206 return true; | 209 return true; |
207 } | 210 } |
208 | 211 |
209 bool ExtensionBrowserTest::WaitForExtensionInstall() { | 212 bool ExtensionBrowserTest::WaitForExtensionInstall() { |
210 int before = extension_installs_observed_; | 213 int before = extension_installs_observed_; |
211 ui_test_utils::RegisterAndWait(NotificationType::EXTENSION_INSTALLED, this, | 214 ui_test_utils::RegisterAndWait(NotificationType::EXTENSION_INSTALLED, this, |
212 kTimeoutMs); | 215 kTimeoutMs); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 case NotificationType::EXTENSION_OVERINSTALL_ERROR: | 257 case NotificationType::EXTENSION_OVERINSTALL_ERROR: |
255 std::cout << "Got EXTENSION_OVERINSTALL_ERROR notification.\n"; | 258 std::cout << "Got EXTENSION_OVERINSTALL_ERROR notification.\n"; |
256 MessageLoopForUI::current()->Quit(); | 259 MessageLoopForUI::current()->Quit(); |
257 break; | 260 break; |
258 | 261 |
259 default: | 262 default: |
260 NOTREACHED(); | 263 NOTREACHED(); |
261 break; | 264 break; |
262 } | 265 } |
263 } | 266 } |
OLD | NEW |